How can I change the name of war?
I already tried (I found these params in documentation https://docs.gradle.org/4.10.2/dsl/org.gradle.api.tasks.bundling.War.html)
war {
baseName = 'service'
archiveName 'service.war'
}
However, this is not working. I am still getting a name with a snapshot version.
./build/libs/search-0.0.1-SNAPSHOT.war
I am using Gradle 4.10 and Spring Boot 2.1.2.RELEASE.
project(':web') { apply plugin: 'war' war { archiveName 'hello-gradle. war' } dependencies { compile project(':core') providedCompile 'javax. servlet:servlet-api:2.5' providedCompile 'org.
First, open the project directory by right-clicking on the project name and click at show in explorer option. Step 2: Close the android studio, and go to the window explorer of the project directory and rename the root folder with a new name.
The War plugin extends the Java plugin to add support for assembling web application WAR files. It disables the default JAR archive generation of the Java plugin and adds a default WAR archive task.
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:
archiveName
has been deprecated, and you should use archiveFileName
insteadarchiveName
property you don't need to set baseName
propertyM. 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With