我正在使用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作为参考
松鸦,
的JLine,
JNI,
JNR,
JRuby的,
JUnit的,
junit3.8.1
但我不想包括这些罐子
答案 0 :(得分:3)
您可以通过将依赖项添加到构建的底部来排除依赖项:
configurations.all*.dependencies*.withType(ModuleDependency)*.each {
it.exclude group: "org.jline", module: "jline"
it.exclude ...
}
这将迭代所有配置的依赖关系,并排除您不想包含的模块。
如果要排除所有传递依赖项,则编译配置的传递性更容易设置为false:
configurations.compile.transitive = false