---------- Forwarded message ----------
From: Wayne Fay <[EMAIL PROTECTED]>
Date: May 23, 2006 10:02 AM
Subject: Re: [m2] Getting SNAPSHOT information into a webapp
To: Maven Users List <users@maven.apache.org>

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.propertieswould 
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]



--
-Gautham Pamu

Reply via email to