You can load the pom properties off the class path so every maven built
artifact in your class path has version information.
Don't copy and paste this but it gives you the idea...
InputStream in
getClass().getResourceAsStream("META-INF/maven/path/to/pom.properties");
Properties p = new Properties();
p.load(in);
String version = p.getProperty("version");
Cheers
Michael
On Monday 20 August 2007 23:09, Tim Kettler wrote:
> Create a new directory (for example 'src/main/classtemplates') and put
> you class template under the correct package directory in there.
>
> Then declare a additional resource in your pom:
>
> [...]
> <resources>
> <resource>
> <directory>src/main/classtemplates</directory>
> <filtering>true</filtering>
> <targetPath>target/generated-sources</targetPath>
> </resource>
> </resources>
> [...]
>
> and use the buildhelper-maven-plugin from mojo.codehaus.org to declare
> the additional source directory, so the compile plugin picks it up:
>
> [...]
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>build-helper-maven-plugin</artifactId>
> <executions>
> <execution>
> <id>add-source</id>
> <phase>process-resources</phase>
> <goals>
> <goal>add-source</goal>
> </goals>
> <configuration>
> <sources>
> <source>target/generated-sources</source>
> </sources>
> </configuration>
> </execution>
> </executions>
> </plugin>
> [...]
>
> -Tim
>
> bakito schrieb:
> > How is this done? Can you please give an example. I can not get it
> > working using filtering java files like filtering resources.
> >
> > bakito
> >
> > Andrew Williams-5 wrote:
> >> You could configure the filtering to filter your java code as well as
> >> standard resources, though I don't know if that is what you want.
> >>
> >> Andy
> >>
> >> On 22 Jul 2007, at 22:56, Francois Fernandes wrote:
> >>> Hi list,
> >>>
> >>> for some time now I've been looking for a easy way to generate a
> >>> simple class containing version information of our artifact. I know
> >>> that it is possible to filter resources. But to avoid any resource
> >>> loading issues I would like maven to generate such a class.
> >>> Does anyone have a idea how to solve this? I'm sure that using
> >>> resource filtering of a specific class template and then attaching
> >>> the generated source(-folder) using the build-helper-maven-plugin,
> >>> but is this a elegant way?
> >>>
> >>> thanks
> >>>
> >>> Francois
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> 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]
--
Michael McCallum
Enterprise Engineer
mailto:[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]