3

I generated a war file by executing this command in the root directory of my Spring project : mvn package

The resulting war file is called hib-1.0.0-BUILD-SNAPSHOT.war

I figured out that the first word hib is the project's artifactId.

How can I specify a custom name for the generated war file?

Vlad L
  • 1,410
  • 3
  • 5
  • 18
pheromix
  • 16,775
  • 24
  • 79
  • 150
  • Possible duplicate of [How to build a WAR project in Maven giving a customized name when installed to local repository and deployed to remote repositories](http://stackoverflow.com/questions/29768137/how-to-build-a-war-project-in-maven-giving-a-customized-name-when-installed-to-l) – Mickael Aug 17 '16 at 13:47
  • Possible duplicate of [Controlling maven final name of jar artifact](http://stackoverflow.com/questions/4238944/controlling-maven-final-name-of-jar-artifact) – Tunaki Aug 17 '16 at 17:35

2 Answers2

5

You can set the variable finalName in the build section of the pom.xml in your project:

<build>
    <finalName>myname</finalName>
</build>

So the war will be renamed to myname.war

Jens
  • 63,364
  • 15
  • 92
  • 104
3

You can supply final name in build,

<build>
    <finalName>my-project</finalName>
</build>

It will create my-project.war when you package the application. By default it will consider following tags to name(my-project-0.0.1-SNAPSHOT.war) the war file,

<groupId>com.in</groupId>
<artifactId>my-project</artifactId>
<version>0.0.1-SNAPSHOT</version>

Other than that you can always rename your war file before deploying it.

akash
  • 22,224
  • 10
  • 57
  • 85