Changing name of WAR file produced by maven build step?

I'm trying to change the name of the WAR file produced by a Maven build step in Teamcity which is essentially 'maven clean package'.

For various reasons, changing the WAR filename in Teamcity is preferable to e.g. editing the pom.xml file - we need the name it always spits out now (myapp-version.war) in most cases, but I need my Teamcity build step to spit out myapp-version-buildnumber.war.

I've tried to set Maven's build.finalName property as a Build Parameter and by using -D on the command line and neither works.  Can anyone help?  Here's a screenshot of my Build Paramter, which looks like a better way to do this than command line options, if possible.

build-finalName.gif

2 comments
Comment actions Permalink

Trying now:

system.maven.project.build.finalName     %maven.project.artifactId%-%maven.project.version%-%build.number%

But, waiting half an hour on the build queue.  :(

Edit: didn't work either.

0
Comment actions Permalink

Gordon,

Unfortunately, Maven does not allow to override finalName value directly from command line and TeamCity is of little help here.

You should add custom property to your pom.xml with reasonable default e.g.

<myCustomName>${artifactId}-${version}</myCustomName>

Use it as final name:

<build>
<finalName>${myCustomName}</finalName>
...
</build>

and then override it (command line, custom profile, anything)

-DmyCustomName=%maven.project.artifcatId%-%build.number%
0

Please sign in to leave a comment.