5

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,544
  • 3
  • 6
  • 20
pheromix
  • 18,213
  • 29
  • 88
  • 158
  • 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

3 Answers3

6

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
  • 67,715
  • 15
  • 98
  • 113
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,664
  • 11
  • 59
  • 87
1

just add following lines inside your pom.xml file and It works 100%

       <configuration>                      
             <finalName>customized project name</finalName>
       </configuration>

these lines must put inside the plugin brackets like as:-

  <build>
        <plugins>
            <plugin>        
                <configuration>                     
                       <finalName>customized project name</finalName>
                </configuration>
            </plugin>
        </plugins>
    </build>