1
我试图从java多项目中构建EAR。 有三种不同的WAR项目和多个JAR项目在这个项目。当我建立项目JAR的所有相关性导入到耳LIB和WAR的所有依赖项目导入到他们各自的WEB-INF/lib目录。但所有WAR项目使用许多常见的依赖项。有了这一切依赖关系,结果EAR变得非常大(> 100 MB)。有没有办法将所有的依赖关系添加到一个EAR文件中,而在WAR文件中没有。根据战争文件构建Gradle ear
我EAR的build.gradle看起来如下..
apply plugin: 'ear'
apply plugin: 'java'
configurations {
earLib.extendsFrom runtime
earLib.transitive = true
}
description = 'JavaEE6 Assembly'
dependencies {
deploy project(path: ':WAR1', configuration: 'archives')
deploy project(path: ':WAR2', configuration: 'archives')
deploy project(path: ':WAR3', configuration: 'archives')
earlib project(':CommonJAR1')
earlib project(':CommonJAR2')
// Writing as below does not work in this case
// earLib group: 'io.springfox', name: 'springfox-swagger2', version:'2.1.1'
}
ear {
archiveName='EARNAME.ear'
libDirName 'lib'
into("META-INF"){
from("META-INF")
}
}
以下是
apply plugin: 'war'
description = 'WAR2'
dependencies {
compile project(':CommonJAR1')
compile group: 'commons-beanutils', name: 'commons-beanutils', version:'1.9.2'
compile group: 'org.springframework', name: 'spring-jdbc', version:'4.0.5.RELEASE'
compile group: 'org.springframework', name: 'spring-core', version:'4.0.5.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version:'4.0.5.RELEASE'
compile group: 'org.springframework', name: 'spring-webmvc', version:'4.0.5.RELEASE'
compile group: 'org.springframework', name: 'spring-oxm', version:'4.0.5.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version:'4.0.5.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version:'4.0.5.RELEASE'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version:'2.2.3'
compile group: 'org.json', name: 'json', version:'20090211'
compile(group: 'org.springframework', name: 'spring-context', version:'4.0.5.RELEASE') {
exclude(module: 'commons-logging')
}
compile group: 'org.aspectj', name: 'aspectjrt', version:'1.7.4'
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.5'
compile(group: 'log4j', name: 'log4j', version:'1.2.15') {
exclude(module: 'mail')
exclude(module: 'jms')
exclude(module: 'jmxtools')
exclude(module: 'jmxri')
}
compile group: 'javax.inject', name: 'javax.inject', version:'1'
compile group: 'javax.servlet', name: 'jstl', version:'1.2'
runtime group: 'io.springfox', name: 'springfox-swagger2', version:'2.1.1'
runtime group: 'org.springframework', name: 'spring-web', version:'4.0.5.RELEASE'
runtime group: 'org.slf4j', name: 'jcl-over-slf4j', version:'1.7.5'
runtime group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.5'
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
providedCompile group: 'javax.servlet.jsp', name: 'jsp-api', version:'2.1'
}
我曾尝试任何来源的那些我的WAR文件中的build.gradle一个可以找到相同的,但没有工作。请建议。该项目将部署在WAS 8.5