1.1 KiB
1.1 KiB
Sample on how to generate a comprehensive version info including Git-commit-ids and build-times.
Versioninfo is generated in the output-jar and also as Java-class for comsumption e.g. in user-output.
- Ensure your project is in a Git-repositiory (with at least one commit)
- Put
BuildVersion.javain a new foldertemplatesunder the `src/main´-directory and modify as needed. - Add
<resources>and<plugins>from this pom.xml to your pom.xml - Add
<myapp.version>1.0</myapp.version>to the<properties>section. This will be used as main "end-user" version . - Run
mvn resources:resourcesto generate the final buildversion - Now you can add something like
System.out.println(BuildVersion.BUILD);to your code to show the version to the user.
With this also a git.properties file will be included in the output-JAR.
Note: In BuildVersion.java don't put @chars before a template-field, otherwise it won't be processed correctly!
See git-commit-id-plugin for more