maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael O'Cleirigh <>
Subject Re: Read project version from pom
Date Tue, 23 Mar 2010 15:17:27 GMT
Hi Shahzad,

There is a way to write the project version as a manifest property when 
the jar is created by maven.

I saw this example today which would be how to do it:

<Implementation-Version>${project.version} ${buildNumber} - 

Checkout the SpringVersion class on how you can access the 
Implementation-Version manifest property inside your code:

public class SpringVersion {

      * Return the full version string of the present Spring codebase,
      * or <code>null</code> if it cannot be determined.
      * @see java.lang.Package#getImplementationVersion()
     public static String getVersion() {
         Package pkg = SpringVersion.class.getPackage();
         return (pkg != null ? pkg.getImplementationVersion() : null);


Hope this is useful for you,


> Hi all,
> I would like the ability to read the project's version number from pom in my java code
as I need to insert that version number in the text file I generate as a result of my code.
I am NOT writing a maven plugin but a standalone java project that uses maven as a build/dependency
> At this point, I can only think of one way of doing that and that is using the properties-maven-plugin
to output the<properties>  section from the pom into a text file and in my<properties>
 seciton I reference the project's version as ${project.version}
> Can you suggest or think of a better solution?
> thanks
> --------------------------------------------
> Shahzad Qureshi
> Systems Analyst/Programmer
> Applications Directorate | La direction générale des applications
> Chief Information Officer Branch | Direction générale du dirigeant principal de l'information
> Environment Canada | Environnement Canada
> Telephone | Téléphone 416-739-4702
> Government of Canada | Gouvernement du Canada
> Website | Site Web

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message