Removing version number from file name with Maven

Bani picture Bani · Feb 8, 2010 · Viewed 49.7k times · Source

I have a project with 5 modules in maven. Right now, when I do a "mvn clean install", it generates an ear containing the two jars, one war and one sar from the other modules.

All the file names contain the version, e.g., projectx-ear-2.0.0.ear, projectx-client-2.0.0.jar, etc.

I need to rename one of the jars and the final ear to omit the version in the file name. It should look like this:

projectx-ear.ear
|
+-- projectx-client.jar
|
+-- projectx-misc-2.0.0.jar
|
+-- projectx-sar-2.0.0.sar
|
\-- projectx-web-2.0.0.web

Right now I'm using the following plugins to build: maven-compiler-plugin and maven-release-plugin

What would be the best way to achieve the results I expect?

Answer

Péter Török picture Péter Török · Feb 8, 2010

You can achieve this by specifying the finalName property in your pom like this:

<build>
    <finalName>${project.artifactId}</finalName>
</build>