One of the dependencies declared in my project has a transitive dependency on 'com.google.guava:guava:15.0'
. But my application deployed on WAS/Weblogic doesn't work due to a CDI issue which has been fixed in 'com.google.guava:guava:15.0:cdi1.0'
. (same version, but with classifier) I need to tell gradle to use this jar during build and packaging. I am trying to figure on how we can ovrride this transitive dependency with a jar specific version classifier.
Tried the following approches:
compile 'com.google.guava:guava:15.0:cdi1.0'
. But both jars got included in the resultant WAR.Added the dependency explicitly and defined a resolution strategy:
configurations.all {
resolutionStrategy {
force 'com.google.guava:guava:15.0:cdi1.0'
}
}
Even this didn't work.
Defined a resolution strategy to check and change the version.
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group + ":" + details.requested.name == 'com.google.guava:guava') {
details.useVersion "15.0:cdi1.0"
//details.useTarget "com.google.guava:guava:15.0:cdi1.0"
}
}
}
Even this didn't work.
Need your suggestions on how this issue can be tackled.
Currently classifiers are not yet taken into account when it comes to resolutionStrategies. A workaround for you might excluding the transitive Guava library when declaring your dependencies and adding the Guava cdi1.0
version explicitly:
dependencies {
compile ("org.acme:someDependency:1.0"){
exclude group: 'com.google.guava', module: 'guava'
}
compile "com.google.guava:guava:15.0:cdi1.0"
}