Gradle War Plugin – Change output WAR filename

In Gradle, the WAR plugin will generate the final WAR file with the following pattern:


${baseName}-${appendix}-${version}-${classifier}.${extension}

Example :
hello.1.0.war

To change the default WAR filename, update war.archiveName. For example :

build.gradle

project(':web') {

    apply plugin: 'war'

    war {
	archiveName 'hello-gradle.war'
    }
	
    dependencies {
        compile project(':core')
	providedCompile 'javax.servlet:servlet-api:2.5'
	providedCompile 'org.apache.tomcat:tomcat-jsp-api:7.0.55'
        //...
    }
}

Build it…


$ gradle :web:war 

Output, a hello-gradle. war file will be generated in the following folder :


{project}\web\build\libs\hello-gradle.war

References

  1. Gradle – The War Plugin
  2. Gradle DSL References – WAR Plugin

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
George Morcos??????? Recent comment authors
newest oldest most voted
???????
Guest
???????

Hi! Thanks for article!
How to change destination dir of .war?

George Morcos
Guest
George Morcos

archiveName has been deprecated in Gradle 5