Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude modules or groups in a jar from Gradle?

I am trying to write a gradle script where i want to ignore or exclude certain modules or groups from a jar file.

My Code :

dependencies {

    compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
    compile fileTree(dir: 'libs', include: ['*.jar'])     
    compile files('libs/test.jar')

  }

So , from test.jar file i want to exclude 'com.xyz.abc' , but i don't find how do i write the script.

Please let me know , suggest me some good solution.

like image 883
Deeptiman Patnaik Avatar asked Dec 25 '22 12:12

Deeptiman Patnaik


1 Answers

Try excluding transitive dependencies as described here:

You can exclude a transitive dependency either by configuration or by dependency:

Example 52.14. Excluding transitive dependencies

build.gradle

configurations {
    compile.exclude module: 'commons'
    all*.exclude group: 'org.gradle.test.excludes', module: 'reports'
}

dependencies {
    compile("org.gradle.test.excludes:api:1.0") {
        exclude module: 'shared'
    }
}
like image 147
random Avatar answered Dec 30 '22 12:12

random