Thanks in advance for any help.
What I want to achieve is project version (Implementation-Version
) is printed in a class when it is initiated so that I can trace the version from log file.
I build a JAR file containing the following classes:
com.company.core.common.ClassA
com.company.core.security.ClassB
com.company.core.sql.ClassC
In constructor of com.company.core.sql.ClassC
, I want to call System.out.println()
to print out the Implementation-Version
stored in META-INF/MANIFEST.MF
file by calling this.class.getPackage().getImplementationVersion()
, but it is getting null
value when the class is initiated via Maven test class.
My MANIFEST.MF
file contains the following details:
Manifest-Version: 1.0
Implementation-Title: Company Core Library
Implementation-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: simon
Implementation-Vendor-Id: com.company.core
Build-Time: 2017-02-18T15:07:33Z
Class-Path: lib/sqljdbc42-4.2.jar lib/log4j-api-2.7.jar lib/log4j-core
-2.7.jar lib/json-20160810.jar lib/junit-4.12.jar lib/hamcrest-core-1
.3.jar
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_102
Implementation-Vendor: Company
Name: com/company/core/
Implementation-Vendor-Id: com.company.core
Implementation-Title: Company Core Library
Implementation-Version: 1.0
Implementation-Vendor: Company
Would I be able to get the Implementation-Version
in Maven test class?
If yes, what have I missed out here?
Thanks.
Regards, Simon.