Search code examples
spring-bootgradlewar

Gradle 'war' plugin how to change name of an archive


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.


Solution

  • 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 use archiveFileName instead
    • if you set the archiveName property you don't need to set baseName property