Using Gradle 2.1, assuming a multi module build with the following direct dependencies:
junit:junit <- projectB <- projectC
whereby projectB uses ResolutionStrategy.eachDependency {} to exchange junit’s transitive dependency to something else. To my surprise the dependency tree looks like this:
------------------------------------------------------------
Project :projectB
------------------------------------------------------------
compile - Compile classpath for source set 'main'.
+--- junit:junit:4.11
|
\--- org.hamcrest:hamcrest-core:1.3 -> something:else:0.0.0 FAILED
\--- project :projectA
------------------------------------------------------------
Project :projectC
------------------------------------------------------------
compile - Compile classpath for source set 'main'.
\--- project :projectB
+--- junit:junit:4.11
|
\--- org.hamcrest:hamcrest-core:1.3
\--- project :projectA
Note how the transitive dependency only gets changed for projectB, but not for projectC. The only way to solve this, is by applying the same ResolutionStrategy to both projects. Besides coupling my projects, it also means that each project needs to re-evaluate each dependency. The same is true for forced versions.
Is there a way to configure ResolutionStrategy to take upstreams ResolutionStrategy into account? Producing an ‘inheritance’ of transitive dependencies from project dependencies the same way exclusions work.