Use revision number as artifact version number?

96 views
Skip to first unread message

Phillip Hellewell

unread,
Sep 30, 2010, 11:55:21 AM9/30/10
to maven-svn-revisi...@googlegroups.com
Hi,

Is it possible to use the revision number as the artifcat version number, similar to how you can use it for the artifact name as shown here:

http://maven-svn-revision-number-plugin.googlecode.com/svn/site/examples/artifact_name.html

I'm guessing no, because I don't think there is nothing like a <finalVersion> tag.

Phillip

Oleg Estekhin

unread,
Sep 30, 2010, 1:44:00 PM9/30/10
to maven-svn-revisi...@googlegroups.com
Hi
 
Do you want to use the svn revision as a <version> value inside a pom or just as the only version-related part of the final artifact name? The latter is easily done, of course, by modifying the <finalVersion> pattern.
 
On the former – I am pretty sure it is impossible in a single-module project as the maven will read and resolve the groupId/artifactId/version coordinates before executing any plugins so the properties will not be available yet. It could work in a multi-module project where parent executes the plugin and a child uses svn revision properties as part of its own <version> value, but I have not tried that and with all that parallel build stuff going in upcoming maven 3 even if it works now it could break in the future.
From my maven experience, I would recommend against using any properties in the artifact’s own version at all.

Phillip Hellewell

unread,
Sep 30, 2010, 3:36:50 PM9/30/10
to maven-svn-revisi...@googlegroups.com
Hmm, when I try to put in a <finalVersion> it gives an "Unrecognized tag" error.  Are you sure that is a valid tag?

If worst comes to worst, I think I can just modify it before running maven, using a separate script.  That may serve my purpose.

Phillip

Oleg Estekhin

unread,
Sep 30, 2010, 4:20:31 PM9/30/10
to maven-svn-revisi...@googlegroups.com
I am sorry, I have mis-printed the existing <finalName> tag as in the example with the hypothetical <finalVersion> from your mail – mindless copy-pasting is bad. So what I meant is that you can easily change the artifact name so it will contain only name and svn revision.
 
If you need some way to update the artifact version automatically then you should look at versions plugin (http://mojo.codehaus.org/versions-maven-plugin/ , mostly used for dependency versions updates) and release plugin (http://maven.apache.org/plugins/maven-release-plugin/ , updates the artifact version automatically as part of the release process).
Other than that, usually the artifact version is updated manually by some project member/manager when the project team feels like it.
 
Why do you want to use svn revision as the artifact version? This information is too transient to serve as a long-term unique identifier, for example if you for any reason will switch to another repository without importing history from the initial repository then the svn revision will start from 0 again.

Phillip Hellewell

unread,
Sep 30, 2010, 4:57:52 PM9/30/10
to maven-svn-revisi...@googlegroups.com
Thanks, I will look into some of those plugins to see if they will work for me.  Most of what I have read leads me to believe the version cannot be modified by a plugin, but we'll see :)

The truth is I don't want to use the svn revision as the artifact version, but rather the svn tag.  The main reason is so the developer never has to worry about updating the version in the pom; it's just automatic.  A tag name should work as a valid long-term identifier, and not have the problem you mentioned with just using the svn revision.

So what exactly is it about a hand-entered version number that makes it so long-term?  How can a hand-entered version number be used to track down which code was used to build it?  That is what I would really like to know :)

Phillip
Reply all
Reply to author
Forward
0 new messages