You can append the version with the Jar file name, but what if the client change it?
So, I have found that the best way is to inject a file inside the Jar file contains all necessary attributes as Version Number, Build Number and Build date.
How to do that?
Simply, create a file inside /src/main/resources/ (I called it version.properties).
In this file write the following:
version = ${project.version} build.no = ${build.version} build.date = ${timestamp}
Go to pom.xml and set the following properties:
<properties> <build.version>2.1.91</build.version> <timestamp>${maven.build.timestamp}</timestamp> <maven.build.timestamp.format>HH:mm dd.MM.yyyy</maven.build.timestamp.format> </properties>
in the same file go to
<resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources>
Finished ?! Now when you generate the Jar file you will find the version.properties file in the root of the jar file as follow:
version = project version build.no = 1.2.3 build.date = 10:20 1.2.2015
No comments:
Post a Comment