gpt4 book ai didi

gradle - 使用 gradle 排除 FAT jar 中不必要的 jar

转载 作者:行者123 更新时间:2023-12-03 03:10:21 25 4
gpt4 key购买 nike

我正在使用 gradle-1.3 版本构建 FAT jar 并构建
使用以下属性的 FAT jar

jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it)
}

依赖项如下
dependencies {
compile fileTree(dir:'/trunk/Solutions/Seismic/Source/Binaries/CommonFunctions/build/libs', include: '*.jar')
compile "org.apache.hadoop:hadoop-core:1.0.3"
compile "commons-collections:commons-collections:3.2.1"
compile "commons-configuration:commons-configuration:1.6"
compile "commons-discovery:commons-discovery:0.2"
compile "commons-lang:commons-lang:2.4"
compile "commons-logging:commons-logging:1.1.1"
compile "commons-logging:commons-logging:1.0.4"
compile "log4j:log4j:1.2.16"
compile "com.vividsolutions:jts:1.8"
compile "commons-net:commons-net:1.4.1"
compile "org.apache.hadoop:hadoop-core:1.0.3"
compile "commons-httpclient:commons-httpclient:3.0.1"
compile "org.mortbay.jetty:servlet-api:2.5-20081211"
compile "org.apache.hbase:hbase:0.94.0"
compile "org.apache.zookeeper:zookeeper:3.4.3"
}

但仍然由 jar 包含在以下 jar 中作为引用

周杰伦,
杰线,
杰尼,
小号,
朱比,
朱尼特,
junit3.8.1

但我不想包括这些 jar

最佳答案

您可以通过将其添加到构建的底部来排除依赖项:

configurations.all*.dependencies*.withType(ModuleDependency)*.each {
it.exclude group: "org.jline", module: "jline"
it.exclude ...
}

这将遍历所有配置的依赖关系并排除您不想包含的模块。

如果你想排除所有传递依赖,在编译配置中将传递性设置为 false 会更容易:
configurations.compile.transitive = false

关于gradle - 使用 gradle 排除 FAT jar 中不必要的 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13706094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com