【发布时间】:2017-11-14 06:52:00
【问题描述】:
我有一个由模块和子模块组成的 gradle 项目。
| build.gradle (1)
|- common
| build.gradle (2)
|- webutils
| build.gradle (3)
|- spring
| build.gradle
|- security
| build.gradle
这是build.gradle (1)
dependencies {
compile project(':common'), project(':common:webutils')
compile project(':spring'), project(':spring:security')
}
这是build.gradle (2)
dependencies {
compile project(':common:webutils')
}
这是build.gradle (3)
dependencies {
compile("javax.servlet:javax.servlet-api:${javaxServletApiVersion}")
testCompile("javax.servlet:javax.servlet-api:${javaxServletApiVersion}")
testCompile("org.springframework:spring-test:${springVersion}")
testCompile("junit:junit:${junitVersion}")
}
当我尝试使用 ./gradlew clean build 构建 jar 时,它会生成以下 jar:
- /build/libs/libs-0.0.1-SNAPSHOT.jar
- common/build/libs/common-0.0.1-SNAPSHOT.jar
- common/webutils/build/libs/webutils-0.0.1-SNAPSHOT.jar
我期待
- (3) 包含在 (2) 中
- (2)、(3) 包含在 (1) 中
看(1)
" zip.vim version v27
" Browsing zipfile libs-0.0.1-SNAPSHOT.jar
" Select a file with cursor and press ENTER
META-INF/
META-INF/MANIFEST.MF
~
看(2)
" zip.vim version v27
" Browsing zipfile common-0.0.1-SNAPSHOT.jar
" Select a file with cursor and press ENTER
META-INF/
META-INF/MANIFEST.MF
看(3)
" zip.vim version v27
" Browsing zipfile webutils-0.0.1-SNAPSHOT.jar
" Select a file with cursor and press ENTER
META-INF/
META-INF/MANIFEST.MF
com/
com/domain/
com/domain/api/
com/domain/api/common/
com/domain/api/common/webutils/
com/domain/api/common/webutils/URLUtils.class
com/domain/api/common/webutils/RandomUtils.class
~
- 为什么我的罐子 (1) 和 (2) 是空的?
- (3) 中的
compile和testCompile依赖项在哪里没有包含在jar 中?根据documentation-
compile: 编译时依赖 -
testCompile:编译测试的附加依赖项
-
【问题讨论】:
标签: java maven gradle jar build.gradle