Forcing a dependency still takes latest version

(George Stockfisch) #1

I’m trying a few ways to force a dependency in a multiproject build, and failing. I have first level dependencies stated as


compile (group: '', name: 'guava', version:"${dependency_guava_version}" ){force = true}


compile project(':project1') { transitive = false}

versions.gradle contains:

               = "12.0"

I have even tried custom resolution strategies(this is just 1, I have tried a few others):

dependencies.all { dep ->
        if( != "myproject" ){
            configs.resolutionStrategy.force "${}:${}:${dep.version}"

In the dependency tree I get ±-- myproject:project1-SNAPSHOT |


but later on in the same output I get ±-- myproject:project2-SNAPSHOT ±-- myproject:project1-SNAPSHOT |

±-- -> 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) #2

had similar problems. Deleting cache solved it for me and clean too.

(Peter Niederwieser) #3

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 ""

For details see the Gradle User Guide and the Gradle Build Language Reference (starting from the ‘Configuration’ type).

(George Stockfisch) #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( != "myproject" ){
            configs.resolutionStrategy.force "${}:${}:${dep.version}"

(George Stockfisch) #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.

(Peter Niederwieser) #6

I’ve fixed the syntax. If you think this is a Gradle bug, a self-contained reproducible example would help a lot.