Build build in the Maven project


I would like to generate a Java build using Maven, where the generated .jar file name was the same as the last revision number of the SVN repository.


Example: My last generated build has the following numbering: And during the whole month of January there were several commits in the repository and now I want to generate a new build with the last revision   of the repository, which in this case would be

How do I do this? I use Jenkins continuous integration and would like them to be integrated.

I did some research, but I did not succeed. Is there a plugin in maven that I put in the pom.xml file that has this feature?

asked by anonymous 22.01.2014 / 21:08

2 answers


There are several plugins to do what you want.

A quick Google search returned me:

Build Number Maven Plugin

Just set up the plugin :


That will feed the variable buildNumber .


Maven SVN Revision Number Plugin

Same thing. Plugin configuration + prefix:


And the revision number will be available in prefix.revision


In both cases it's also worth setting the SCM :


Tip: Since you're taking time to automate the process, we recommend add the build version to Manifest . Placing the build number in the Manifest and storing a checksum of the generated artifact gives you confidence on the build version (just adding the version to the file name is good for cataloging, but does not guarantee much since the artifact can be renamed).

23.01.2014 / 16:22

The simplest and "manual" way

The simplest practice for getting an artifact with the VCS revision of the file name is put the desired revision in the version set to pom.xml . Although it is a "manual" procedure, this helps to maintain some consistency.

Versions Maven Plugin can help with this task a little.

Using the releases plugin

There is also the Maven Release Plugin that could be useful depending on how your process. It is able to create a tag in SVN and update the version of the poms.

Changing the "final" name of the artifact in Maven

In Maven, you can set the <finalName> tag to its pom.xml so that after the build the final artifact has the name you want. See documentation here .

By default, maven adds the pom version as follows:


Then you could define some other property, for example:


And Jenkins could be configured to pass the ${revisao_svn} parameter to Maven.

If you use a hook like the of this page

a>, then you will have the revision number in a property.

Finally, you just have to configure build parameters as explained this link . According to this answer this is perfectly possible.

Note : I currently do not have an environment to test all this, so unless someone gives you a more detailed solution, you'll have to uncover the details of the procedure.     

23.01.2014 / 13:40