Problem with fine-tuning transitive dependency management


(Tino Nitze) #1

Hi Folks

I’ve got a challenge that I apparently can’t solve myself. I have switched off transitive dependency resolution globally and want to have it enabled for solely one dependency (my core project). Additionally I also want this transitive resolution to only affect the “first level” - meaning the transitive policy shall not be applied to any of the parent project’s dependencies.

my simplified build.gradle:

apply plugin: 'java'
  configurations.all {
            transitive = false
        }
  dependencies {
    compile ("foo:bar:1.3.0-SNAPSHOT") {
        transitive = true
    }
}

If I remove the configurations.all global switch - it works and tries to pull the dependencies, BUT not just foo:bar’s but also recursively its dependencies.

Question is: a) Why does the override of configurations.all.transitive through the artifacts own configuration not work? and b) How can I limit the dependency resolution depth to lets say “1”?

Hope I made myself understandable …

Thanks for any help or hints on that!

Tino


(Peter Niederwieser) #2

ad a) I think this is a left-over from Ivy, which works in this way.

ad b) The simplest solution is to declare the first level dependencies yourself, for example via a client module dependency:

dependencies {

compile module("“foo:bar:1.3.0-SNAPSHOT”) {

dependency “some:dep:1.0”

dependency “other:dep:2.0”

}

}


(Tino Nitze) #3

hm. I guess with a) I can live. Solution to b) would result in listing the same endless dependencies that are basically given by the core lib project and used in all sub projects in which we would always have to manually synchronize any changed core dependencies. Well, I got no choice here I guess.

Thanks for your help anyway… ~Tino


(Peter Niederwieser) #4

In a multi-project build, you would declare this once in a parent build script.