How can I force Gradle to set the same version for two dependencies?

Add this section to just above your dependencies block. Groovy/Gradle: configurations.all { resolutionStrategy { force ‘com.google.guava:guava:14.0.1’ force ‘com.google.guava:guava-gwt:14.0.1’ } } Kotlin Script: configurations.all { resolutionStrategy { force(“com.google.guava:guava:14.0.1”) force(“com.google.guava:guava-gwt:14.0.1”) } }

In Gradle, how do I declare common dependencies in a single place?

You can declare common dependencies in a parent script: ext.libraries = [ // Groovy map literal spring_core: “org.springframework:spring-core:3.1”, junit: “junit:junit:4.10” ] From a child script, you can then use the dependency declarations like so: dependencies { compile libraries.spring_core testCompile libraries.junit } To share dependency declarations with advanced configuration options, you can use DependencyHandler.create: libraries = … Read more

How do I exclude all instances of a transitive dependency when using Gradle?

Ah, the following works and does what I want: configurations { runtime.exclude group: “org.slf4j”, module: “slf4j-log4j12” } It seems that an Exclude Rule only has two attributes – group and module. Hence for excluding from only an individual dependency, we can do something like: dependencies { compile (‘org.springframework.data:spring-data-hadoop-core:2.0.0.M4-hadoop22’) { exclude group: “org.slf4j”, module: “slf4j-log4j12” } … Read more