gradle custom war task webAppDirName
gradle, war
Solution
There is just one `webAppDirName` property per project, and the War plugin automatically adds a corresponding `from` to each `War` task. So the main problem is how to undo that `from`. I think the following should work:
apply plugin: "war"
webAppDirName = "non/existing/dir"
task myWarTask(type: War) {
from "src/anotherfolder/webapp"
...
}
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 the `War` plugin. Extra properties are only meant for ad-hoc use in build scripts. You'd use `ext.` when writing an extra property, but omit it when reading the property.
Problem
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?