如何从 Gradle 中排除 jar 中的模块或组? [英] How to exclude modules or groups in a jar from Gradle?
本文介绍了如何从 Gradle 中排除 jar 中的模块或组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个 gradle 脚本,我想在其中忽略或排除 jar 文件中的某些模块或组.
I am trying to write a gradle script where i want to ignore or exclude certain modules or groups from a jar file.
我的代码:
dependencies {
compile fileTree(dir: "$buildDir/native-libs", include: 'native-libs.jar')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/test.jar')
}
所以,从 test.jar 文件中,我想排除 'com.xyz.abc' ,但我不知道如何编写脚本.
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.
推荐答案
尝试排除传递依赖项,如此处:
Try excluding transitive dependencies as described here:
您可以通过配置或依赖排除传递依赖:
You can exclude a transitive dependency either by configuration or by dependency:
例 52.14.排除传递依赖
Example 52.14. Excluding transitive dependencies
build.gradle
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'
}
}
这篇关于如何从 Gradle 中排除 jar 中的模块或组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文