You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Roland Klein <ro...@mtg-marinetechnik.de> on 2007/02/22 17:02:55 UTC
HowTo access project version programmatically in application
Hi,
HowTo access project version programmatically in application?
At the moment we enter the version string manually in one of our classes. Is there a way to access
the project version at runtime?
One of my thoughts are to generate a Version class holding the version string, but is there a more
convenient way?
Thanks in advance
Roland
--
Roland Klein
Tel: +49 40 65803 209
Fax: +49 40 65803 392
roland.klein@mtg-marinetechnik.de
MTG Marinetechnik GmbH - Wandsbeker Koenigstr. 62 - D 22041 Hamburg
GF Dipl.-Ing. Ullrich Keil
Handelsregister: Abt. B Nr. 11 500 - Amtsgericht Hamburg Abt. 66
USt.-IdNr.: DE 1186 70571
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: HowTo access project version programmatically in application
Posted by Kalle Korhonen <ka...@gmail.com>.
Make your version a property, use the same property in your version element
and when generating a manifest. Or, use maven-buildnumber-plugin.
Kalle
On 2/22/07, Roland Klein <ro...@mtg-marinetechnik.de> wrote:
>
> Hi,
>
> HowTo access project version programmatically in application?
>
> At the moment we enter the version string manually in one of our classes.
> Is there a way to access
> the project version at runtime?
> One of my thoughts are to generate a Version class holding the version
> string, but is there a more
> convenient way?
>
> Thanks in advance
> Roland
>
> --
> Roland Klein
> Tel: +49 40 65803 209
> Fax: +49 40 65803 392
> roland.klein@mtg-marinetechnik.de
>
> MTG Marinetechnik GmbH - Wandsbeker Koenigstr. 62 - D 22041 Hamburg
>
> GF Dipl.-Ing. Ullrich Keil
> Handelsregister: Abt. B Nr. 11 500 - Amtsgericht Hamburg Abt. 66
> USt.-IdNr.: DE 1186 70571
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: HowTo access project version programmatically in application
Posted by Roland Klein <ro...@mtg-marinetechnik.de>.
Thanks for Your reply, it works now
Roland
Jason van Zyl schrieb:
> On 22 Feb 07, at 11:02 AM 22 Feb 07, Roland Klein wrote:
>
>> Hi,
>>
>> HowTo access project version programmatically in application?
>>
>
> Every JAR created with Maven embeds a properties which you can use to
> get the version from.
>
> This is what we do:
>
> http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java
>
>
> Jason.
>
>> At the moment we enter the version string manually in one of our
>> classes. Is there a way to access the project version at runtime?
>> One of my thoughts are to generate a Version class holding the version
>> string, but is there a more convenient way?
>>
>> Thanks in advance
>> Roland
>>
>> --Roland Klein
>> Tel: +49 40 65803 209
>> Fax: +49 40 65803 392
>> roland.klein@mtg-marinetechnik.de
>>
>> MTG Marinetechnik GmbH - Wandsbeker Koenigstr. 62 - D 22041 Hamburg
>>
>> GF Dipl.-Ing. Ullrich Keil
>> Handelsregister: Abt. B Nr. 11 500 - Amtsgericht Hamburg Abt. 66
>> USt.-IdNr.: DE 1186 70571
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
Roland Klein
Tel: +49 40 65803 209
Fax: +49 40 65803 392
roland.klein@mtg-marinetechnik.de
MTG Marinetechnik GmbH - Wandsbeker Koenigstr. 62 - D 22041 Hamburg
GF Dipl.-Ing. Ullrich Keil
Handelsregister: Abt. B Nr. 11 500 - Amtsgericht Hamburg Abt. 66
USt.-IdNr.: DE 1186 70571
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: HowTo access project version programmatically in application
Posted by Jason van Zyl <ja...@maven.org>.
On 22 Feb 07, at 11:02 AM 22 Feb 07, Roland Klein wrote:
> Hi,
>
> HowTo access project version programmatically in application?
>
Every JAR created with Maven embeds a properties which you can use to
get the version from.
This is what we do:
http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/
main/java/org/apache/maven/execution/DefaultRuntimeInformation.java
Jason.
> At the moment we enter the version string manually in one of our
> classes. Is there a way to access the project version at runtime?
> One of my thoughts are to generate a Version class holding the
> version string, but is there a more convenient way?
>
> Thanks in advance
> Roland
>
> --
> Roland Klein
> Tel: +49 40 65803 209
> Fax: +49 40 65803 392
> roland.klein@mtg-marinetechnik.de
>
> MTG Marinetechnik GmbH - Wandsbeker Koenigstr. 62 - D 22041 Hamburg
>
> GF Dipl.-Ing. Ullrich Keil
> Handelsregister: Abt. B Nr. 11 500 - Amtsgericht Hamburg Abt. 66
> USt.-IdNr.: DE 1186 70571
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org