I'd like to put revision number on main page of webapp, how can i do that using maven?
P.S. Its two part question, how to get revision number and how to write it into selected file in the project.
To find information about the history of a file or directory, use the svn log command. svn log will provide you with a record of who made changes to a file or directory, at what revision it changed, the time and date of that revision, and, if it was provided, the log message that accompanied the commit.
As you saw in the section called “Revisions”, revision numbers in Subversion are pretty straightforward—integers that keep getting larger as you commit more changes to your versioned data.
"svn info --show-item revision" will give the current revision to which the current directory is updated.
This plugin is designed to give you a build number. So when you might make 100 builds of version 1.0-SNAPSHOT, you can differentiate between them all.
The maven build number plugin is the way to go. An example of how to use it is here:
http://www.mojohaus.org/buildnumber-maven-plugin/usage.html
You would use this together with the maven jar plugin to print the SVN commit number to your manifest.
This is a better solution than using a file that contains the SVN commit number, because that adds more moving parts than is really necessary.
If you are using subversion, you can use this plugin to make the SVN revision number available as a maven property
http://code.google.com/p/maven-svn-revision-number-plugin/
I combine this with jar plugin to add the SVN revision to the MANIFEST.MF file for our jar's and war's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With