Januson
Januson

Reputation: 4841

Gradle: How to allow only specific transitive dependency

I would like to globally disable all transitive dependencies. I am using the following and it works fine.

configurations.all {
    transitive = false
}

Problem is that I need to allow transitive dependencies for one specific dependency. Is there a way to do this?

I tried variations of the following but with no success.

compile("my:dep:xxx") {
    transitive = true
}

Upvotes: 2

Views: 469

Answers (1)

ToYonos
ToYonos

Reputation: 16833

Try that :

configurations.all {
    dependencies.matching { it.group != 'my' || it.name != 'dep' }.all {
        transitive = false
    }
}

Upvotes: 1

Related Questions