Reusing resolution strategy between Gradle projects

(Erik Ripley) #1


Given multiple Gradle projects which use a similar set of dependencies, I often see errors like this (which are usually transitive dependencies that I haven’t specifically defined).

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> A conflict was found between the following modules:
   - com.something:example:1.2.3
   - com.something:example:1.2.2
   - com.something:example:1.2.1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at

The typical way to resolve this error would be to add force com.something:example:1.2.3 (latest) to the resolution strategy in build.gradle and then try running the compileJava task again until all conflicts are resolved.
I’m wondering if it would be a good practice to define a general resolution strategy which could be somehow applied by all the projects and then if there are additional conflicts, those would be resolved in build.gradle as usual. If this is a fair approach, would a good place to apply the general resolution strategy be in a Gradle plugin or is there a better choice?

Another question would be, since I have a consistent way I want to resolve these conflicts each time, can Gradle determine what the conflicts are and then I could generate the list of versions to force rather than discovering the conflicts by trial and error?


(Dimitar Dimitrov) #2

Just stick it in allprojects block in your root and it should work. It is a fairly normal thing to do.