You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Torsten Curdt <tc...@apache.org> on 2005/10/11 12:21:38 UTC

adding subversion revision to manifest

I've come up with a simple maven plugin that adds
the subversion revision to the manifest. So with


     public static Map getJarRevisions() throws IOException {
         final String[] jars = System.getProperty 
("java.class.path").split(
                 System.getProperty("path.separator"));
         final Map revisions = new HashMap(jars.length);
         for (int i = 0; i < jars.length; i++) {
             final JarFile jar = new JarFile(jars[i]);
             final Manifest manifest = jar.getManifest();
             final String revision = (String)  
manifest.getMainAttributes().getValue("Revision");
             revisions.put(jars[i], revision);
         }

       return revisions;
     }

You know *exactly* what jars are in your path.
Only add it to your maven.xml like this:

   <postGoal name="jar:jar">
     <attainGoal name="revision:add"/>
   </postGoal>

It is currently available at:

  http://people.apache.org/~tcurdt/maven-revision-plugin.tgz

It's for maven1 but just wraps a simple class
so a version for maven2 should be pretty straight
forward.

If people think this is useful I am sure we can
improve it and put it somewhere properly.

cheers
--
Torsten

RE: adding subversion revision to manifest

Posted by "RK Somasundaram (rks)" <rk...@cisco.com>.
Hi -

Is this available as a Maven2 plugin?

Thanks,

Rk
x77309 

-----Original Message-----
From: Torsten Curdt [mailto:tcurdt@apache.org] 
Sent: Tuesday, October 11, 2005 3:22 AM
To: Maven Users List
Subject: adding subversion revision to manifest

I've come up with a simple maven plugin that adds the subversion
revision to the manifest. So with


     public static Map getJarRevisions() throws IOException {
         final String[] jars = System.getProperty
("java.class.path").split(
                 System.getProperty("path.separator"));
         final Map revisions = new HashMap(jars.length);
         for (int i = 0; i < jars.length; i++) {
             final JarFile jar = new JarFile(jars[i]);
             final Manifest manifest = jar.getManifest();
             final String revision = (String)
manifest.getMainAttributes().getValue("Revision");
             revisions.put(jars[i], revision);
         }

       return revisions;
     }

You know *exactly* what jars are in your path.
Only add it to your maven.xml like this:

   <postGoal name="jar:jar">
     <attainGoal name="revision:add"/>
   </postGoal>

It is currently available at:

  http://people.apache.org/~tcurdt/maven-revision-plugin.tgz

It's for maven1 but just wraps a simple class so a version for maven2
should be pretty straight forward.

If people think this is useful I am sure we can improve it and put it
somewhere properly.

cheers
--
Torsten

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org