When Maven builds a jar, it writes a file named pom.properties to:
/META-INF/maven/<groupId>/<artifactId>/pom.properties
It looks like this:
#Generated by Maven
#Thu Sep 13 15:43:41 PDT 2007
version=2.0
groupId=org.apache.maven.plugins
artifactId=maven-ant-plugin
You can just read this file directly to access the version, using
ClassLoader.getResourceAsStream(). Or you can create your own
properties file somewhere else and filter it, as suggested by
Heinrich.
Wayne
On 1/22/08, Heinrich Nirschl <[EMAIL PROTECTED]> wrote:
> On Jan 22, 2008 5:38 PM, Rex Huang <[EMAIL PROTECTED]> wrote:
> > for example, I had a Version.java
> > public class Version {
> > private static String VERSION = "${buildNumber}";
> > public static String getVersion() {
> > return VERSION;
> > }
> > }
> >
> > I need to set version number when compile, so I use filter to change the
> > version information in java file.
> >
> > Rex
>
> The easiest way is to do the filtering with a real resource (e.g. a
> property file) and to read this resource in your java code.
>
> ---------------------------------------------------------------------
> 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]