Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

maven

I have a project bird with the 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 pom.xml

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

The web module creates a war file named web-1.0-SNAPSHOT.war
How can I configure maven to build it as bird.war?

like image 727
daydreamer Avatar asked Jan 23 '13 20:01

daydreamer


People also ask

Can you rename a WAR file?

You can rename the WAR file if you are using a WAR file for deployment, and you want to use "Workplace XT" or a custom name for the context root of the application. The context root is part of the URI that end users type to access Workplace XT.

Can we change the name of Pom XML?

Maven looks for the pom. xml file, so you should rename it that for it to work. You could use another file name using the -f option. mvn -f parent-pom.

Where does maven create the WAR file?

Using the mvn:war:exploded command, we can generate the exploded WAR as a directory inside the target directory. This is a normal directory, and all the files inside the WAR file are contained inside the exploded WAR directory.


2 Answers

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.

like image 151
Sébastien Le Callonnec Avatar answered Nov 01 '22 23:11

Sébastien Le Callonnec


You need to configure the war plugin:

<project>   ...   <build>     <plugins>       <plugin>         <groupId>org.apache.maven.plugins</groupId>         <artifactId>maven-war-plugin</artifactId>         <version>2.3</version>         <configuration>           <warName>bird.war</warName>         </configuration>       </plugin>     </plugins>   </build>   ... </project> 

More info here

like image 24
Andres Olarte Avatar answered Nov 01 '22 22:11

Andres Olarte