gradleApi() adds amongst others httpclient-4.2.2.jar to the classpath.
This version does not have the property you use.
But as gradleApi() just adds the files from the gradle installation, they are not listed in the output of “dependencies” task and are also not subject to version conflict resolution.
Anyway, I guess it would be a bad idea to use a newer version of a lib that is shipped with Gradle in a gradle plugin, this might lead to runtime conflicts.
I’d use the shipped version if possible.
But maybe I’m wrong and the plugins have isolated ClassLoaders and just the building is problematic, I’m not sure.
Thank you very much. Now I understand. I case someone runs into a similar problem, I find your suggestion of listing the hidden gradleApi() dependencies invaluable:
task libtest << {
configurations.testCompile.files.each { println it }
}
That’s how we can confirm that httpclient-4.2.2 is pulled into the dependencies tree by gradle (the gradle dependencies command does not show this).
In fact, when executing the tasks gradle correctly uses the dependencies of the plugin, this issue only applies to the tests.
Imho, forcing others to use certain versions is not valid option since you cannnot always change that. Moreover, gradleApi handles dependencies internally, so even if you change your libraries in your gradle installation it still forces you to the default versions.