I have a few gradle war tasks in my build file, and I would like to change the webAppDirName
per war task. I tried this:
task myWarTask(type: War) {
ext.webAppDirName = 'src/anotherfolder/webapp' // also tried just webAppDirName
version ""
destinationDir = file("$buildDir/libs")
baseName = 'myWarName'
classpath = configurations.myWarConfiguration
}
But this is still pulling in the contents of src/main/webapp
instead of src/anotherfolder/webapp
Can I configure the webAppDirName
on a per war file basis like this?
There is just one
webAppDirName
property per project, and the War plugin automatically adds a correspondingfrom
to eachWar
task. So the main problem is how to undo thatfrom
. I think the following should work:An alternative is to only use the
War
task type, but not the War plugin. You'll have to configure a few more task properties then, and will lose a few features, mostly related to provided configurations and publishing of the War. Of course you can make up for this with explicit configuration (if necessary). If you are interested in the details, have a look at the source code for the War plugin.PS:
webAppDirName
is not an extra property (ext.
), but a convention property added by theWar
plugin. Extra properties are only meant for ad-hoc use in build scripts. You'd useext.
when writing an extra property, but omit it when reading the property.