Gradle, different versions of direct and transitive dependencies

504 views Asked by At

Suppose application module build.gradle

dependencies {
    implementation "com.example.http:core:5.1"
    implementation "com.example.common:network:1.0"
}

And http core third party project buid.gradle

dependencies {
    implementation "com.example.common:network:2.0"
}

(so http's .pom has dependency of network 2.0 inside)

In this case gradle will choise network module of version 2.0 for both application and http modules.
But how can I make gradle use both versions of network: 1.0 as direct application and 2.0 as transitive http dependencies?

1

There are 1 answers

1
DelfikPro On

There is a technique for resolving clashing dependencies called shadow jar.

Conviniently enough, there is an awesome gradle plugin for building these.