Change name of generated war file and duplicate war file

In build.gradle you can set the archive name:

war.archiveName "YOUR_SPECIAL_NAME.war"

gradle reference


Another one, for example:

war {
    baseName = 'service'
    version = '0.0.1-SNAPSHOT-' + System.currentTimeMillis();
}

For gradle version 5 and above, they have deprecated properties 'baseName' and 'archiveName'.

So you can use 'archivesBaseName' instead.

war {
    archivesBaseName = 'name'
}  

task doPack(type: War, dependsOn: []) {
    archiveName "ROOT.war"

That worked for me

Tags:

Gradle