Receiving jar version from parent pom.xml

Multi tool use


Receiving jar version from parent pom.xml
I have problem getting the jar version from the pom.xml.
in the past I added to my project pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
and in my code I used:
getClass().getPackage().getImplementationVersion()
to retrieve the jar version.
my problem started when I switch to use parent pom, so I moved my org.apache.maven.plugins to the parent pom and connected my pom to my parent pom. but now the:
getClass().getPackage().getImplementationVersion()
does not work any more!
How can I retrieve the jar version using parent pom?
Actually Java runtime has nothing with pom. So your JAR being generated w/ and w/o parent POM differ from each other. So you have to check both manifests. I'm sure that properly configured maven-jar-plugin do put proper versions (as well as other entries) into manifest.
– user3159253
Apr 2 '14 at 14:17
If you moved the configuration to the parent, then you need to make sure you built the parent and it's in the artifact repository (mvn clean install). Then, make sure the module POM specifies the version of the parent POM built and installed in the repo. We use this pattern of defining manifests in the parent POM and it works well.
– user944849
Apr 2 '14 at 17:37
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
did you update project after changing the parent pom?
– Taks
Apr 2 '14 at 14:12