On 29 Sep 2008, at 13:08, Brett Porter wrote:

2008/9/29 Dominic Mitchell <[EMAIL PROTECTED]>:
What's the easiest way to get at the version number in the POM from Java?

I've been using
getResourceAsStream('META-INF/maven/groupId/artifactId/ pom.properties'); But this doesn't work while I'm developing in Eclipse (only when using the
built jar file).

Yes, this is only generated when the JAR is packaged. It might be best
for your test cases to substitute in a known value here rather than
relying on it, unless you are doing something specific with the
version.

There's nothing particularly important about this — it's just a minor annoyance. We already substitute "[dev]" if we can't read it.

Ideally, I'd like to somehow generate a Java class which contains the
version number.  I thought I should be able to do this using resource
filtering, but I couldn't see a way to configure the resources plugin to
achieve this…

@project.version@ should be substituted in a copy, but resources are
processed after compilation so the timing is not correct. You'd need
to execute a specific plugin in the generate-sources phase.


I'll have a play with this to see if I can get it to do what I want.

Thanks for your quick response!
-Dom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to