This is referenced from the maven-buildnumber-plugin documentation.

http://apollo.ucalgary.ca/tlcprojectswiki/index.php/Public/Project_Versi
oning_-_Best_Practices#Build_Versioning

Where they do the following (assuming, of course, you've placed the info
in your manifest file):


String appServerHome = getServletContext().getRealPath("/");

File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF");
 
Manifest mf = new Manifest();
mf.read(new FileInputStream(manifestFile));

Attributes atts = mf.getMainAttributes();

System.out.println("Version: " +
atts.getValue("Implementation-Version"));
System.out.println("Build: " + atts.getValue("Implementation-Build"));

> -----Original Message-----
> From: Steve Cohen [mailto:[email protected]]
> Sent: Wednesday, January 11, 2012 10:29 AM
> To: [email protected]
> Subject: Re: Howto access project version programmatically within
> application
> 
> On 01/11/2012 10:50 AM, Stephen Connolly wrote:
> >
getClass().getClassLoader().getPackage("").getImplementationVersion()
> >
> 
> I really liked the simplicity of this idea.  Alas,
> ClassLoader.getPackage(String) is a protected method, so this won't
> help.
> 
> Accessible to me is:
> 
> Package.getPackage("").getImplementationVersion(), which according to
> Javadocs sounds like it would do the same thing, but this throws a
> NullPointerException.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]


______________________________________________________________________
This message, including any attachments, is confidential and contains 
information intended only for the person(s) named above. Any other 
distribution, copying or disclosure is strictly prohibited. If you are not the 
intended recipient or have received this message in error, please notify us 
immediately by reply email and permanently delete the original transmission 
from all of your systems and hard drives, including any attachments, without 
making a copy.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to