问题描述
我有一个Gradle多项目设置,我希望将所有依赖和输出JAR收集到顶层的ZIP中。我有一些工作,但我最终在ZIP文件中有重复。我在中找不到任何有用的信息
- 如何删除重复项?
- 是否还有其他方法? li>
结构
项目
./multi-project/build.gradle
./multi-project/settings.gradle
./multi-project/bar
./multi-project/bar/ build.gradle
./multi-project/foo
./multi-project/foo/build.gradle
顶级build.gradle
apply plugin:'java'
allprojects {
apply plugin:'java'
repositories {
mavenCentral()
}
}
任务buildDist (类型:Zip){
from subprojects.configurations.compile into'jars'
from subprojects.jar.outputs.files into'jars'
}
Settings.gradle
include':foo '
include':bar'
foo和bar的低级build.gradle文件(两者相同)
pre code $ dependency {
compile'org.springframework:spring-beans:4.1.0.RELEASE'
}
当我从顶层运行gradle:buildDist时,ZIP会重复
unzip -l build / distributions / multi-project.zip
存档:build / distributions / multi-project .zip
长度日期时间名称
--------- ---------- ----- ----
0 2014-09 -09 20:17 jars /
701334 2014-09-09 19:53 jars / spring-beans-4.1.0.RELEASE.jar
62050 2014-07-05 21:09 jars / commons- logging-1.1.3.jar
1005039 2014-09-09 19:53 jars / spring-core-4.1.0.RELEASE.jar
701334 2014-09-09 19:53 jars / spring- beans-4.1.0.RELEASE.jar
62050 2014-07-05 21:09 jars / co mmons-logging-1.1.3.jar
1005039 2014-09-09 19:53 jars / spring-core-4.1.0.RELEASE.jar
301 2014-09-09 20:12 jars / bar.jar
301 2014-09-09 20:12 jars / foo.jar
任务buildDist(类型:Zip){
到'jars'
来自{subprojects.configurations.runtime}
from {subprojects.jar}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
要查看特定Gradle任务类型的所有配置选项,请参阅 Gradle Build Language Reference 。
I have a gradle multi-project setup for which I wish to collect all the dependent and output JARs into a ZIP at the top level. I've got something working, however I end up with duplicates in the ZIP file. I've not found anything useful in the official documentation on multi project setups
- How can I remove the duplicates?
- Is there another approach I should take?
Structure
./multi-project
./multi-project/build.gradle
./multi-project/settings.gradle
./multi-project/bar
./multi-project/bar/build.gradle
./multi-project/foo
./multi-project/foo/build.gradle
Top level build.gradle
apply plugin: 'java'
allprojects {
apply plugin: 'java'
repositories {
mavenCentral()
}
}
task buildDist(type: Zip) {
from subprojects.configurations.compile into 'jars'
from subprojects.jar.outputs.files into 'jars'
}
Settings.gradle
include ':foo'
include ':bar'
Lower level build.gradle files for foo and bar (both same)
dependencies {
compile 'org.springframework:spring-beans:4.1.0.RELEASE'
}
When I run gradle :buildDist from the top level the ZIP has duplicates
unzip -l build/distributions/multi-project.zip
Archive: build/distributions/multi-project.zip
Length Date Time Name
--------- ---------- ----- ----
0 2014-09-09 20:17 jars/
701334 2014-09-09 19:53 jars/spring-beans-4.1.0.RELEASE.jar
62050 2014-07-05 21:09 jars/commons-logging-1.1.3.jar
1005039 2014-09-09 19:53 jars/spring-core-4.1.0.RELEASE.jar
701334 2014-09-09 19:53 jars/spring-beans-4.1.0.RELEASE.jar
62050 2014-07-05 21:09 jars/commons-logging-1.1.3.jar
1005039 2014-09-09 19:53 jars/spring-core-4.1.0.RELEASE.jar
301 2014-09-09 20:12 jars/bar.jar
301 2014-09-09 20:12 jars/foo.jar
task buildDist(type: Zip) {
into 'jars'
from { subprojects.configurations.runtime }
from { subprojects.jar }
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
To see all configuration options for a particular Gradle task type, consult the Gradle Build Language Reference.
这篇关于分配ZIP中的多项目gradle重复依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!