Gradle使用不同的资源和类进行多次战争 [英] Gradle make multiple war with different resources and classes
问题描述
我有一个Java Web项目,我使用Gradle构建项目,项目结构如下。
I have a Java web project, and I use Gradle to build project, the project structure as follow.
我希望使用Gradle构建2个战争,main.war和api.war,以及战争结构如下。
I want use Gradle to build 2 wars, main.war and api.war, and the wars structure as follow.
我尝试了很多次来构建这两场战争,但是当main.war正确时,api.war是错误的,当api.war正确时,main.war是错误的。
I have try many times to build these 2 wars, but when main.war is correct the api.war is wrong, when api.war is correct the main.war is wrong.
任何人都可以给我一些帮助吗?
Could anyone give me some helps? Thanks.
项目结构:
project structure:
project-root
|--src
|--api
|--resources
|--api.xml
|--webapp
|--WEB-INF
|--web.xml(api)
|--main
|--java
|--xxx.xxx.api
|--xxx.xxx.model
|--some other packages
|--resources
|--main.xml
|--webapp
|--websrc
|--js
|--style
|--WEB-INF
|--web.xml(main)
|--index.html
我想要的战争结构:
The wars structure I want:
main.war
|--websrc
|--js
|--style
|--WEB-INF
|--classes
|--all packages exclude api package
|--main.xml
|--web.xml(main)
|--index.html
api.war
|--WEB-INF
|--classes
|--xxx.xxx.api
|--xxx.xxx.model
|--api.xml
|--web.xml(api)
我的gradle文件:
My gradle file:
task create_main_war(type: War, dependsOn: classes) {
baseName = "main"
rootSpec.exclude("**/api/**")
}
task create_api_war(type: War, dependsOn: classes) {
baseName = "api"
SourceSets {
main.resources.srcDirs += "src/api/resources"
}
webAppDirName = "src/api/webapp
rootSpec.exclude("**/main.xml")
rootSpec.exclude("**/someOtherPackages/**")
}
推荐答案
close,please view the forums.gradle.org question: http://forums.gradle.org/gradle/topics/ gradle-make-multiple-war-with-different-resources-and-classes
close, please view the forums.gradle.org question : http://forums.gradle.org/gradle/topics/gradle-make-multiple-war-with-different-resources-and-classes
这篇关于Gradle使用不同的资源和类进行多次战争的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!