2012-12-04 105 views
2

我使用gradle這個-1.3版本構建FAT罐子,用下面的屬性此使用gradle這個

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

依賴關係如下建立 FAT罐子排除在FAT罐子unneccesarry罐子

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" 
} 

但以罐爲基準包含以下罐子作爲參考

jay,
jline,
個 JNI,
JNR,
的JRuby,
JUnit中,
junit3.8.1

但我不希望包括這些罐子

回答

2

可以通過添加這排除依賴底部構建:

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

這將遍歷所有配置的依賴關係,並排除m你不想包含的模塊。

如果要排除所有傳遞依賴,更容易傳遞性設置爲false編譯配置:

configurations.compile.transitive = false 
+0

像... !!它開始工作......! – Rajendra