One of the requirement in my project was to create an entry of last SCM Revision number in web
application property file every time a release build is done. So that we can show this while user logged in as
support and also add this in logging for tracking purpose. We achieved the same using
Add svn revision number maven plugin in your project plugin Management section of pom (in case of parent child maven modules add this in parent pom file)
svn-revision-number-maven-plugin
.Add svn revision number maven plugin in your project plugin Management section of pom (in case of parent child maven modules add this in parent pom file)
POM File Svn Revision Number Maven Plugin Configuration
POM.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<pluginmanagement> | |
<plugins> | |
.... | |
.... | |
.... | |
<plugin> | |
<groupid> | |
com.google.code.maven-svn-revision-number-plugin | |
</groupid> | |
<artifactid>svn-revision-number-maven-plugin</artifactid> | |
<version>1.13</version> | |
<executions> | |
<execution> | |
<goals> | |
<goal>revision</goal> | |
</goals> | |
</execution> | |
</executions> | |
<configuration> | |
<entries> | |
<entry> | |
<prefix>prefix</prefix> | |
</entry> | |
</entries> | |
</configuration> | |
<dependencies> | |
<dependency> | |
<groupid>org.tmatesoft.svnkit</groupid> | |
<artifactid>svnkit</artifactid> | |
<version>1.7.11</version> | |
</dependency> | |
</dependencies> | |
</plugin> | |
.... | |
.... | |
.... | |
</plugins> | |
</pluginmanagement> |
In case of parent child relation add following in the child project POM
Child Project Pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>com.google.code.maven-svn-revision-number-plugin</groupId> | |
<artifactId>svn-revision-number-maven-plugin</artifactId> | |
</plugin> |
Web Project Property File
build.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build.path=${prefix.path} | |
build.revision.number=${prefix.revision} | |
build.committed.revision.number=${prefix.committedRevision} | |
build.committed.date=${prefix.committedDate} |
Final result will be some thing like this
result.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build.path=branches/1.0.0/xyz-project | |
build.revision.number=16523 | |
build.committed.revision.number=16521 | |
build.committed.date=2014-05-02 17:57:02 +0530 (Fri, 02 May 2014) |
3 Comments
hello, I am facing problem using the code, my project having 4 modules, my question is where to store .properties file..because..where should its position
ReplyDeleteI tried below way to store properties file in one of the child module.but not worked for me..thanks in advance
ReplyDelete${basedir}/src/main/resources
build.properties
true
Its the same place where you should be defining property file..
DeleteIs your pom file includes property files to be updated, in resource section. If not please add them and try again.
Post a Comment