Sample for generating version infos from GIT commits with Maven
Go to file
Michael Hoess 1e87216797 Add pom.xml and example code as well as README.md 2020-10-10 23:09:47 +02:00
src/main Add pom.xml and example code as well as README.md 2020-10-10 23:09:47 +02:00
.gitignore Add pom.xml and example code as well as README.md 2020-10-10 23:09:47 +02:00
README.md Add pom.xml and example code as well as README.md 2020-10-10 23:09:47 +02:00
pom.xml Add pom.xml and example code as well as README.md 2020-10-10 23:09:47 +02:00

README.md

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.java in a new folder templates under 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:resources to 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