I’m trying to build multiple war files at once; i mean create different versions of the same product. Each version has custom resources and java code.
Moving from an ant build, i accomplish in gradle to create a task to copy, first, the custom resources and java files from a ‘custom’ folder to the standard locations so gradle compiles and wars the desired product; one specific version.
In ant i have a task that calls the build n times, one for each version and i get all wars needed in one build.
In gradle i can call graglew -Pversion=myversion war, multiple times, but what i want is to call gradlew only one time and get all artifacts.
Searching took me to the android gradle plugin that seems to do that, it gets product and flavour blocks and builds different product versions. I think i need something like that for building war artifacts.(or any other)
Maybe copying resources/java files is the wrong way and i need another approach, please give and advice on to handle this multi-configuration build.
You can’t use the same mechanism that Android uses for war projects yet. You don’t need to copy things into the convention locations for Gradle to build the war, you can add any number of War tasks to build the different versions of your war. e.g.,
apply plugin: 'war'
// setup dependencies
task oneVersionOfWar(type: War) {
classifier = 'oneVersion'
from("custom") // adds contents of 'custom' into root of war
}
task anotherVersionOfWar(type: War) {
classifier = 'anotherVersion'
webInf {
from("somewhere") // copies contents of 'somewhere' into the WEB-INF directory of the war
}
}