George
(George Stockfisch)
October 21, 2013, 8:57pm
1
I’m trying a few ways to force a dependency in a multiproject build, and failing. I have first level dependencies stated as
project1.gradle
compile (group: 'com.google.guava', name: 'guava', version:"${dependency_guava_version}" ){force = true}
project2.gradle
compile project(':project1') { transitive = false}
versions.gradle contains:
ext.dependency_guava_version
= "12.0"
I have even tried custom resolution strategies(this is just 1, I have tried a few others):
dependencies.all { dep ->
if( dep.group != "myproject" ){
configs.resolutionStrategy.force "${dep.group}:${dep.name}:${dep.version}"
}
}
In the dependency tree I get ±-- myproject:project1-SNAPSHOT |
±-- com.google.guava:guava:12.0
but later on in the same output I get ±-- myproject:project2-SNAPSHOT ±-- myproject:project1-SNAPSHOT |
±-- com.google.guava:guava:12.0 -> 13.0.1
Why is it taking version 13.0.1 now? I forced the version in porject 1, so shouldn’t it always take the forced version?
P_Gouv
(P Gouv)
October 21, 2013, 11:24pm
2
had similar problems. Deleting cache solved it for me and clean too.
You just forced the version for the ‘compile’ configuration of ‘project1’. If you want to force the version for the entire build, you can use something like:
configurations.all {
resolutionStrategy {
force "com.google.guava:guava:12.0"
}
}
For details see the Gradle User Guide and the Gradle Build Language Reference (starting from the ‘Configuration’ type).
George
(George Stockfisch)
October 22, 2013, 2:41pm
4
Cleaning the cache didn’t fix this sadly.
And Peter I did try to add it to all projects, I didn’t include enough, since my dependencies.all line is inside the confugurations.all.
configurations.all { configs ->
dependencies.all { dep ->
if( dep.group != "myproject" ){
configs.resolutionStrategy.force "${dep.group}:${dep.name}:${dep.version}"
}
}
}
George
(George Stockfisch)
October 22, 2013, 2:52pm
5
Also, the code you posted throws an error, with Gradle 1.8
* What went wrong:
A problem occurred evaluating script.
> Could not find property 'resolutionStrategy' on configuration container.
I’ve fixed the syntax. If you think this is a Gradle bug, a self-contained reproducible example would help a lot.