Posted By

ff1959 on 12/21/09


Tagged

java maven WAR MANIFEST


Versions (?)

Access build number from MANIFEST


 / Published in: Java
 

How to access the build number in the WAR file (generated by the Maven build number plugin) from Java.

  1. String appServerHome = getServletContext().getRealPath("/");
  2.  
  3. File manifestFile = new File(appServerHome, "META-INF/MANIFEST.MF");
  4.  
  5. Manifest mf = new Manifest();
  6. mf.read(new FileInputStream(manifestFile));
  7.  
  8. Attributes atts = mf.getMainAttributes();
  9.  
  10. System.out.println("Version: " + atts.getValue("Implementation-Version"));
  11. System.out.println("Build: " + atts.getValue("Implementation-Build"));

Report this snippet  

You need to login to post a comment.