'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.



Solution 1:[1]

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'
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PrasadU