While using the maven-buildnumber-plugin 1.0 beta 4, it seems that I can get the svn revision unless I use a <format>
tag within the configuration. Once I use <format>
and <item>buildnumber</item>
tag, I get an auto-incrementing number, but it no longer corresponds to svn revision and I don't know how to get it back. Is there a way to use the svn revision number within the <format>
? The documentation isn't very clear.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
The buildnumber-maven-plugin is pretty darn quirky, which is probably why it's still a beta. The format is only for those items you wish to apply a Java message format to and in most cases, it only useful with timestamps and literal strings. If you don't need a timestamp don't use the format option when getting the Subversion revision number. If you use the format, then like you indicated, it'll give you a build number that always increments by one rather than the SCM version number.
If you do need the timestamp or have other items your deriving from the buildnumber plugin as well as the Subversion revision, do each one as a separate executions. Here's an example of how to get the Subverison revision number and the build timestamp using two separate executions of the plugin:
The key to making this work is using the buildNumberPropertyName element. Checkout the plugin's Usage page for more information about the usefulness of the Java message format is for.
I did run into the same problem and for a few moments I thought the solution suggested by @Jean-Rémy Revy works..but it didn't for some reason.
It turns out that in buildnumber-maven-plugin-1.2 they have added support for a special property called scmVersion. As of now v1.2 is not available in the maven repository though the plugin's website suggests it is GA. So you will need to checkout the source (http://svn.codehaus.org/mojo/tags/buildnumber-maven-plugin-1.2/ )and build it ( $ mvn install ). This will also install the plugin in your local repository.
After this just do this:
There is a compelling reason why that has been done by the plugin developer. A recommended way to get the project's build timestamp is as follows:
So all you need is to get a revision number which can be done quite well with a single invocation of the buildnumber-maven-plugin according to its documentation.
P.S. Having one execution instead of two (as was offered) saves near one second each time the plugin is invoked ;)
By the looks of it no. If you use the format configuration then you are bound to using one of the default items.
From here:
And then from here:
Also if you look at the code for the mojo here a couple things support this:
And:
By the sounds of it you are asking for a new feature (not a bad idea by the way). I would submit it as such here.