Hi,
Perso, I think It should be well about having something like a
maven-shared-resources in this
http://svn.apache.org/viewvc/maven/shared/trunk/.
A simple library to process resources with filtering (from file and
interpolation from the pom).
This could be used in few plugins :
- maven-resources-plugin
- maven-war-plugin (which as I see contains duplicate code from
maven-resources-plugin)
- in my company plugin (which contains duplicate code too ;-))
- in some others companies plugins (which contains duplicate code too
duplicate smiley ;-)

WDYT ?

--
Olivier

-----Message d'origine-----
De : Wayne Fay [mailto:[EMAIL PROTECTED] 
Envoyé : mardi 23 mai 2006 17:02
À : Maven Users List
Objet : Re: [m2] Getting SNAPSHOT information into a webapp


You might need to just write your own plug-in to get this kind of
properties file output.

Wayne

On 5/23/06, Mark Chaimungkalanont <[EMAIL PROTECTED]> wrote:
> Thanks Kenney. I think what I want is similar to how the 
> pom.properties would normally be generated by Maven. As in, I want 
> some code / cofiguration that can generate a properties file with the 
> "version" in it.
>
> For example, I want something to work like
>
> eg.
> myApp.properties.template (with contents) 
> version.from.maven=${maven.pom.version}-${maven.package.build.date}
>
> to produce:
>
> myApp.properties (with contents)
>
> version.from.maven=1.0-SNAPSHOT-2006-05-22
>
> And so I can place in the myApp.properties in the class path and 
> easily read it?
> -------------------------------------
> ATLASSIAN - http://www.atlassian.com
> Australia's Fastest Growing Software Company 2002-05 [BRW Magazine]
>
> Kenney Westerhof wrote:
> > On Tue, 23 May 2006, Mark Chaimungkalanont wrote:
> >
> > Maven writes a property file in the jar or war at 
> > /META-INF/maven/<groupId>/<artifactId>/pom.properties.
> >
> > For jars you can use a classloader to find that resource, but in the

> > case of a WAR the META-INF is not part of the classpath so you'd 
> > have to use the servlet api to get the path to that file.
> >
> > Code snippet:
> >
> >     public static String getVersion( String groupId, String
artifactId )
> >         throws IOException
> >     {
> >         ClassLoader cl =
Thread.currentThread().getContextClassLoader();
> >         Properties props = new Properties();
> >
> >         String propFileName = "META-INF/maven/" + groupId.replace( 
> > '.', '/' ) + "/" + artifactId + "/pom.properties";
> >         InputStream a = cl.getResourceAsStream( propFileName );
> >         if ( a == null )
> >             throw new IOException( "Cannot find '" + propFileName +
"'" );
> >         props.load( a );
> >         return props.getProperty( "version" );
> >     }
> >
> >
> > -- Kenney
> >
> >
> >> Guys,
> >>
> >> We're using Maven2 and wanted to know the best way to get version 
> >> information (including the SNAPSHOT timestamp, e.g. 
> >> 1-0-SNAPSHOT-20050622 or sth) into a webapp that was built with the

> >> "mvn package"?
> >>
> >> My guess is that there is a property ${maven.snapshot.version} or 
> >> something that we can use to generate a properties file so that the

> >> app can read this information. Perhaps a filter copy plugin against

> >> one of the goals?
> >>
> >> Does anything know any references around this area? Have anyone got

> >> examples they can share?
> >>
> >> Thanks,
> >>
> >> Mark C
> >>
> >> -------------------------------------------------------------------
> >> --
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
> > --
> > Kenney Westerhof
> > http://www.neonics.com
> > GPG public key: http://www.gods.nl/~forge/kenneyw.key
> >
> > --------------------------------------------------------------------
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



This e-mail, any attachments and the information contained therein ("this 
message") are confidential and intended solely for the use of the addressee(s). 
If you have received this message in error please send it back to the sender 
and delete it. Unauthorized publication, use, dissemination or disclosure of 
this message, either in whole or in part is strictly prohibited.
********************************************************************** 
Ce message électronique et tous les fichiers joints ainsi que  les informations 
contenues dans ce message ( ci après "le message" ), sont confidentiels et 
destinés exclusivement à l'usage de la  personne à laquelle ils sont adressés. 
Si vous avez reçu ce message par erreur, merci  de le renvoyer à son émetteur 
et de le détruire. Toutes diffusion, publication, totale ou partielle ou 
divulgation sous quelque forme que se soit non expressément autorisées de ce 
message, sont interdites.
********************************************************************** 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to