Each pom.xml
have:
<groupId>com.vendor</groupId>
<artifactId>product</artifactId>
<version>1.0.13.0-dev</version> <!-- THIS FIELD -->
<packaging>war</packaging>
version
piece is useful to bunch with application so user can see and report them.
But I dislike code duplication and look for a way to avoid putting property file with version info to VCS (Git/SVN) because each time I bump version I must commit into two places (pom.xml
and version.properties
).
Which way can I make version properties from pom.xml
programmatically available in Java application?
Have a look at the Maven Resources Plugin. In your
version.properties
(should be in theresources
folder), define a line likeversion=${project.version}
. Make sure to turn on filtering for the plugin (all described in detail at the link above) and you should be good to go!Just run
mvn resources:resources
(ormvn compile
) and check the generated file.My personal production solution below.
pom.xml:
base.jsp:
proj.properties:
applicationContext.xml:
or just
You can simply configure the maven-war-plugin, maven-jar-plugin, maven-ear-plugin like the following:
Reading information from manifest.mf can be done using jacabi.
Found a solution to use the maven-war-plugin to be more elegant.
footer.jsp then had: