This message was deleted.
# community-support
s
This message was deleted.
v
Is it maybe the
gradleProperty
produced provider that has no value as you set the Gradle property for bugpatterns, but not the one for nullaway?
m
Hi @Vampire, thanks for your reply. I’m not sure I understand your question, can you explain
v
I have no idea what
createCastedProvider
does. But you use
project.getProviders().gradleProperty
in what you showed to get the value of a project property. The requested project properties for
getEnableBugpatterns
and
getEnableNullAway
are most probably different I assume. So if you change everything to
getEnableBugpatterns
and it works while with
getEnableNullAway
it fails with empty provider, my assumption is, that the project property for the former is set while the one for the latter is not.
m
Actually, I found something, the only difference is the default value, the “nullaway” one is “false” which means the
if
inside the
Callable
in the following code evaluates to false. This is surprising as I saw in @melix blog post that this is possible for conditional addition of dependencies :
Copy code
private void addDependencyProvider(
    Project project, String configuration, Property<Boolean> property, String dependency) {
  project
      .getDependencies()
      .addProvider(
          configuration,
          project.provider(
              (Callable<Object>)
                  () -> {
                    if (property.get()) {
                      return dependency;
                    } else {
                      return null;
                    }
                  }));
}
m
It is. However I need to update my blog post, because I found that depending on the situation, returning
null
may or may not work. So nowadays, I'm using
addAllLater
and systematically return a list of dependencies, which can be empty.
(this has to be done on
Configuration
instead of
DependencyHandler
)
m
I will give it a try, thanks a lot!