Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the name of the generated war file from command line with maven

Tags:

maven

According to the maven war plugin documentation I should be able to set the name of the generated war file with the parameter warName. Is it not possible to do this from the command line with mvn -DwarName=mySpecificName package? When I run maven like this the war file still gets the default name.

My webapp project is part of a multi module project and I only want to change the final name of the war file, not any other projects generated artifact.

I am using maven 3.0.4 and version 2.3 of the war plugin.

like image 912
Ludwig Magnusson Avatar asked Jan 25 '13 07:01

Ludwig Magnusson


People also ask

How do I change my war name in Maven?

use the finalName tag to define/change the name of the war file in the web module that produces the war.


2 Answers

You can achieve the same effect by maven property.

1) Define a property via

       <properties>
           <my.warName>xxx</my.warName>
       </properties>

You can overwrite the default value by "-Dmy.warName=commandlineWarName"

2) Redefine the war name

       <build>
           <finalName>${my.warName}</finalName>
           <!-- ... -->
      </build>
like image 53
Jintian DENG Avatar answered Oct 08 '22 05:10

Jintian DENG


After looking at the code of the war plugin I realize that it is not possible to set the warName parameter from command line. I assumed that all parameters were possible to set from the command line. This assumption was incorrect.

like image 31
Ludwig Magnusson Avatar answered Oct 08 '22 06:10

Ludwig Magnusson