Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » How to pass the Git tag value to a Maven build run by Eclipse to embed into the WAR file manifest?(Integrating Git/Maven/Eclipse to use tags.)
How to pass the Git tag value to a Maven build run by Eclipse to embed into the WAR file manifest? [message #1829352] Wed, 01 July 2020 19:11
Craig Cothren is currently offline Craig CothrenFriend
Messages: 1
Registered: July 2020
Junior Member
I use bash shell to build our web archive (WAR) file for deployment. It is very useful for the version as defined from Git repository tagging to be available from the WAR manifest to determine the origin of the WAR. Via the shell script, it looks like this...

export TAGGEDVERSION="`git describe --tags --abbrev=0`"
export SIGNATURE="`git describe --tags --abbrev=0`:`git rev-parse --abbrev-ref HEAD`:`git rev-parse --short=11 HEAD`"
mvn "-Dbuild.number=${SIGNATURE}" "-Dbuild.version=${TAGGEDVERSION}" clean package

These values correlate with our POM to set the manifest...

<manifestEntries>
    <MyApp-Version>${build.version}</MyApp-Version>
    <MyApp-BuildNumber>${build.number}</MyApp-BuildNumber>
    <MyApp-BuildTimestamp>${maven.build.timestamp}</MyApp-BuildTimestamp>
</manifestEntries>

I can then query the manifest...

unzip -q -c target/application.war META-INF/MANIFEST.MF

...and see where it came from...

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: jDoe
Build-Jdk: 1.8.0_251
MyApp-BuildNumber: 5.1.0rc2:HLP-2993:bac98886a53
MyApp-BuildTimestamp: 2020-07-01T14:57:41Z
MyApp-Version: 5.1.0rc2

But the majority of our developers use Eclipse to build and test, which I am unfamiliar with.

How can I do the equivalent settings from Git through Maven to the manifest using Eclipse?
Previous Topic:Having both global and local .gitignore
Next Topic: Creation of repositories in the Eclipse workspace is not recommended
Goto Forum:
  


Current Time: Thu Jun 24 18:05:54 GMT 2021

Powered by FUDForum. Page generated in 0.02633 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top