Gradle 'war' plugin how to change name of an archive
Please refer to this documentation : Spring Boot Gradle reference
To sum up: when applying the Spring Boot gradle plugin together with war
plugin, the war
task is disabled by default and "replaced" by the SpringBoot bootWar
task.
So if you want to configure the war artefact, you will need to configure the bootWar
task instead of base war
task :
bootWar {
baseName = 'service'
archiveName 'service.war'
}
Additional notes:
- in Gradle 5.x ,
archiveName
has been deprecated, and you should usearchiveFileName
instead - if you set the
archiveName
property you don't need to setbaseName
property
M. Ricciuti answer is correct, with the caveat that even though archiveName
has been deprecated in Gradle 5.x, Spring Boot is still using it in 2.1.6.RELEASE. For example, if the bootWar task was configured with the new archiveFileName
property like this:
bootWar {
archiveFileName 'service.war'
}
you will get this error:
Could not find method archiveFileName() for arguments [service.war] on task ':bootWar' of type org.springframework.boot.gradle.tasks.bundling.BootWar.
Use archiveName
for now. See Spring BootWar class Java doc for details. They may add archiveFileName
in the future.