Georg Heiler
Georg Heiler

Reputation: 17676

gradle multi project build override dependencies in child

In a gradle multi project build:

root << applies: dependency{ 'org:module:version1' }
|- foo (version1) is ok here
|- bar (version1) not ok here, I need to use version 2

Is there a way to achieve this behaviour?

Upvotes: 0

Views: 994

Answers (1)

Juan Moreno
Juan Moreno

Reputation: 2785

An alternative you can use is the strictly keyword. In your bar module you can write something like:

dependencies {
    //Other dependencies
    compile("org:module") {
        version {
            strictly version2
        }
        because("Only version2 works in this module")
    }
}

Also, if you check your bar module dependency graph with:

./gradlew -q dependencies

You'll get an output like this:

compileClasspath - Compile classpath for source set 'main'.
+--- project :
|    +--- org.sample:dependency:1.0
|    +--- org.sample:other-dependency:1.0
|    \--- org:module:{strictly version2} -> version2

Upvotes: 1

Related Questions