A_G
A_G

Reputation: 2370

Exclude Gradle transitive dependencies

I am trying to exclude a nested transitive dependency from the gradle build. The dependency structure looks like

+---org.apache.beam:beam-sdks-java-core:2.33.0-custom

+---META-INF/maven/org.apache.commons/commons-compress/

enter image description here

I excluded the dependency by following the accepted solution from gradle exclude a transitive dependency but it didnt work for me.

implementation('core-lib:tag') {
    implementation('org.apache.beam:beam-sdks-java-core:2.33.0-custom') {
        exclude group: 'org.apache.commons'
    }
}

This doesnt exclude the dependency. When I change this to * the dependencies are still not excluded.

implementation('core-lib:tag') {
    implementation('org.apache.beam:beam-sdks-java-core:2.33.0-custom') {
        exclude group: '*', module:'*'
    }
}

Any suggestions on how can i exclude this dependency? Its pulling in an older version.

Upvotes: 1

Views: 10642

Answers (2)

monkunashi
monkunashi

Reputation: 41

If you want to remove the one in the image, all you need to do is specify that one specifically. If you leave it off, it will exclude the entire group; so you add the specific name so it only excludes that one.

implementation('core-lib:tag') {
    exclude group: 'org.apache.commons', module: 'commons-compress'
}

Upvotes: 0

PrasadU
PrasadU

Reputation: 2438

it should be as below - optionally you can add module see https://docs.gradle.org/current/userguide/dependency_downgrade_and_exclude.html#sec:excluding-transitive-deps

implementation('core-lib:tag') {
    exclude group: 'org.apache.commons'
}

Upvotes: 2

Related Questions