Maven: How to rename the war file for the project?

By | July 16, 2019

Question

I have a project bird with following components in pom.xml

   <groupId>com.myorg</groupId>
    <artifactId>bird</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>bird</name>

    <modules>
        <module>persistence</module>
        <module>business</module>
        <module>service</module>
        <module>web</module>
    </modules>

and the web module as

   <parent>
        <artifactId>bird</artifactId>
        <groupId>com.myorg</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>web</artifactId>
    <packaging>war</packaging>  

web module creates the war file named web-1.0-SNAPSHOT.war
How can I, using maven rename this to bird.war?

Solution

You can use the following in the web module that produces the war:

<build>
  <finalName>bird</finalName>
 . . .
</build>

This leads to a file called bird.war to be created when goal “war:war” is used.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *