I want to access information like implementation version stored in the jar file. This seems to work quite well, in any technique but always based on the classloader.
If i want to test in my maven environment, of course i cannot use the surefire plugin, because this is prior to packaging in jar. Thus I must use failsafe plugin.
But then neither of the technique works, most probably, because of some dark magic concerning classloaders.
The simplest way to get implementation version is just
this.getClass().getPackage().getImplementationVersion()
which reads from META-INF/MANIFEST.MF
in the jar
which looks sth like
Name: eu/simuline/octave/
Extension-name: eu.simuline.octave
Specification-Version: 0.7
Implementation-Version: 0.7-SNAPSHOT
Maybe extension is not needed, what is needed is the section name
which is derived from the package name in an obvious way (trailing slash seems vital;-) ).
But as said, this works only in productive context,
not within tests with failsafe plugin.
Then the java code returns 0.7-SNAPSHOT
, else it just returns null
,
which means according to the api docs, that the version is unknown... well.
What can I do to include meta info in maven tests???