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

时间:2015-11-12 12:04:22

标签: android android-gradle build.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.

1 个答案:

答案 0 :(得分:5)

尝试按照here所述排除传递依赖关系:

您可以通过配置或依赖项排除传递依赖关系:

例52.14。排除传递依赖

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