考虑以下build.gradle脚本:
apply plugin: 'java'
sourceSets {
common
admin
importer
}
dependencies {
commonCompile 'org.hibernate:hibernate:3.5.4-Final'
commonCompile 'org.springframework:spring-hibernate3:2.0.8'
adminCompile // How to add dependency on commonJar task here?
adminCompile ...
importerCompile // How to add dependency on commonJar task here?
importerCompile ...
}
task commonJar(type: Jar) {
from sourceSets.common.output
}
task adminWar(type: War) {
classpath sourceSets.admin.output
classpath configurations.adminCompile
...
}
task importerWar(type: War) {
classpath sourceSets.importer.output
classpath configurations.importerCompile
...
}
我想向adminWar
和importerWar
添加一个依赖项,以便commonJar会生成一个Jar,如果它不存在,adminWar
和{{1}将包含.jar以及.jar对其类路径的依赖关系。我不能为我的生活弄清楚如何做到这一点,但感觉它很简单。
谢谢。