我有一个包含下一个模块的项目:
"app-core" (packaging - jar)
"servlet A" (packaging - war) depends on "app-core"
"servlet B" (packaging - war) depends on "app-core"
当我执行Gradle构建任务时,我有下一张图片:
"servlet A" - contains inside a copy of "app-core"
和
"servlet B" - contains inside a copy of "app-core"
但我最初的目标是只拥有每个模块的单个副本:“app-core”,“servlet A”,“servlet B”(servlet A和B在其类路径中应该具有“app-core”)
我的gradle脚本“app-core”:
version = '0.1'
dependencies {
compile 'org.hibernate:hibernate-core:4.3.0.Final'
compile 'org.hibernate:hibernate-ehcache:4.3.0.Final'
compile 'org.springframework:spring-jdbc:4.0.0.RELEASE'
compile 'org.springframework:spring-orm:4.0.0.RELEASE'
compile 'com.microsoft:sqljdbc4:4.0'
compile 'org.reflections:reflections:0.9.9-RC1'
runtime 'org.hsqldb:hsqldb:2.3.1'
}
模块A:
version = '0.1'
apply plugin: 'war'
dependencies {
compile project(':app-core')
}
模块B:
version = '0.1'
apply plugin: 'war'
dependencies {
compile project(':app-core')
}
最后是root build:
version = '0.1'
subprojects {
apply plugin: 'idea'
apply plugin: 'java'
sourceCompatibility = '1.7'
targetCompatibility = '1.7'
repositories {
mavenCentral()
mavenLocal()
maven {
url "http://repo.spring.io/release"
}
}
dependencies {
compile 'org.apache.logging.log4j:log4j-api:2.0-beta9'
compile 'org.apache.logging.log4j:log4j-core:2.0-beta9'
compile 'org.slf4j:slf4j-log4j12:1.7.5'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.2.2'
compile 'com.jayway.jsonpath:json-path:0.9.1'
compile 'com.jayway.jsonpath:json-path-assert:0.9.1'
compile 'org.springframework:spring-core:4.0.0.RELEASE'
compile 'org.springframework:spring-context:4.0.0.RELEASE'
compile 'org.springframework:spring-aop:4.0.0.RELEASE'
testCompile 'org.springframework:spring-test:4.0.0.RELEASE';
testCompile 'com.googlecode.catch-exception:catch-exception:1.2.0'
testCompile 'org.testng:testng:6.8.7'
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile 'org.easytesting:fest-assert:1.4'
testCompile 'org.hamcrest:hamcrest-all:1.3'
testCompile 'org.unitils:unitils-core:3.3'
}
}
settings.gradle
include ':app-core',
':servletA',
':servletB'
对于此事的任何建议,我将不胜感激。