Gradle, How To Disable All Transitive Dependencies

Solution 1:

I ended up using:

configurations.all {
    transitive = false
}

Solution 2:

If you want to have just one configuration block for all configurations you can use spread-dot operator to express this.

configurations {
    // other configurations e.g. - compile.exclude module: 'commons-logging'
    all*.transitive = false
}

Solution 3:

In my case, I had a project (gradle module) depedency. I used the following to exclude the transitive dependencies in Gradle 3:

implementation(project(':<module_name>')) {
    transitive = false
}

Or in Kotlin script:

implementation(project(':<module_name>')) {
    isTransitive = false
}