You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Steve Cohen <sc...@javactivity.org> on 2012/01/11 15:03:41 UTC

Howto access project version programmatically within application

A solution to this question appears to have been offered here, in 2007.

http://maven.40175.n5.nabble.com/HowTo-access-project-version-programmatically-in-application-td82542.html

It references a page explaining how to do it.  That page is now gone:

http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java

Does this page or another more advanced way to do this now exist?

Thanks.

---------------------------------------------------------------------
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 within application

Posted by Matt Narrell <ma...@gmail.com>.
Agreed.

I filter-copy a properties file with the following:

project.name=${project.name}
project.version=${project.version}
build.date=${build.date}
...

Then I can load this file and have at it.

matt

On Jan 11, 2012, at 7:48 AM, Mark H. Wood wrote:

> On Wed, Jan 11, 2012 at 09:07:29AM -0600, Steve Cohen wrote:
>> It appears that this entire class and the interface it is based on are 
>> deprecated, in favor of org.apache.maven.rtinfo.RuntimeInformation and 
>> org.apache.maven.rtinfo.internal.DefaultRuntimeInformation.
>> 
>> But this non-deprecated version of the interface/impl REMOVE the 
>> getApplicationVersion() method.
>> 
>> What's going on here and what is the approved method for getting the 
>> application version now?
> 
> What he said.
> 
> Dunno about *approved*, but in a JAR (or WAR?) in
> META-INF/maven/${groupId}/${artifactId} you'll find pom.properties
> which contains a 'version' property:
> 
>  $ cat pom.properties 
>  #Generated by Maven
>  #Mon Aug 29 13:19:24 EDT 2011
>  version=1.0-SNAPSHOT
>  groupId=edu.iupui.ulib.dspace
>  artifactId=casAuthn
> 
> I know that at least one product deserializes this file to discover
> its own version number.
> 
> One could use resource filtering to produce a customized
> allAboutMe.properties explicitly, containing anything Maven knows and
> is willing to provide to a filter.
> 
> But I too would like to know what the supported method is, and where
> that is documented.
> 
> -- 
> Mark H. Wood, Lead System Programmer   mwood@IUPUI.Edu
> Asking whether markets are efficient is like asking whether people are smart.


---------------------------------------------------------------------
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 within application

Posted by "Mark H. Wood" <mw...@IUPUI.Edu>.
On Wed, Jan 11, 2012 at 09:07:29AM -0600, Steve Cohen wrote:
> It appears that this entire class and the interface it is based on are 
> deprecated, in favor of org.apache.maven.rtinfo.RuntimeInformation and 
> org.apache.maven.rtinfo.internal.DefaultRuntimeInformation.
> 
> But this non-deprecated version of the interface/impl REMOVE the 
> getApplicationVersion() method.
> 
> What's going on here and what is the approved method for getting the 
> application version now?

What he said.

Dunno about *approved*, but in a JAR (or WAR?) in
META-INF/maven/${groupId}/${artifactId} you'll find pom.properties
which contains a 'version' property:

  $ cat pom.properties 
  #Generated by Maven
  #Mon Aug 29 13:19:24 EDT 2011
  version=1.0-SNAPSHOT
  groupId=edu.iupui.ulib.dspace
  artifactId=casAuthn

I know that at least one product deserializes this file to discover
its own version number.

One could use resource filtering to produce a customized
allAboutMe.properties explicitly, containing anything Maven knows and
is willing to provide to a filter.

But I too would like to know what the supported method is, and where
that is documented.

-- 
Mark H. Wood, Lead System Programmer   mwood@IUPUI.Edu
Asking whether markets are efficient is like asking whether people are smart.

Re: Howto access project version programmatically within application

Posted by Rainer Pruy <Ra...@Acrys.COM>.
Hm, is this really heading into the direction you intended with your 
question originally?

The api your are looking at is more for maven internal use (or for 
dealing with maven world (poms, etc.).
If your "application" is into this direction you might find interesting 
hints with maven plugin development.

If you have in mind some kind of application that just happens to use 
maven as a build platform,
then the solution is not in the first place maven specific.
(The version of the maven project needs not necessarily be the version 
of the application,
but providing such info to your application is application specif in the 
first place.)

You need to consider in what form said information is to be bundled with 
your application.
(e.g. readable from jar manifest or other resource,  read from pom 
included with jar,  provided by a dedicated class to name a few)
Second step would be how you access it from there.

So, probably you can drop a word or more on the use case involved.

Rainer

On 11.01.2012 16:07, Steve Cohen wrote:
> It appears that this entire class and the interface it is based on are 
> deprecated, in favor of org.apache.maven.rtinfo.RuntimeInformation and 
> org.apache.maven.rtinfo.internal.DefaultRuntimeInformation.
>
> But this non-deprecated version of the interface/impl REMOVE the 
> getApplicationVersion() method.
>
> What's going on here and what is the approved method for getting the 
> application version now?
>
>
> On 01/11/2012 08:59 AM, Steve Cohen wrote:
>> Thanks.
>> But according to this:
>> http://maven.apache.org/ref/3.0.4-SNAPSHOT/apidocs/org/apache/maven/execution/DefaultRuntimeInformation.html 
>>
>>
>>
>> the getApplicationVersion() method has been deprecated, with no
>> indication as to what I should use instead.
>>
>> Also, it seems that this introduces a dependency on Maven itself within
>> the application. What jar would this be?
>>
>> Thanks again.
>>
>> On 01/11/2012 08:12 AM, Guillaume Polet wrote:
>>> Just google org/apache/maven/execution/DefaultRuntimeInformation.java .
>>>
>>> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven/maven-core/2.0.5/org/apache/maven/execution/DefaultRuntimeInformation.java?av=h 
>>>
>>>
>>>
>>>
>>> Cheers,
>>> Guillaume
>>>
>>> Le 11/01/2012 15:03, Steve Cohen a écrit :
>>>> A solution to this question appears to have been offered here, in 
>>>> 2007.
>>>>
>>>> http://maven.40175.n5.nabble.com/HowTo-access-project-version-programmatically-in-application-td82542.html 
>>>>
>>>>
>>>>
>>>>
>>>> It references a page explaining how to do it. That page is now gone:
>>>>
>>>> http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java 
>>>>
>>>>
>>>>
>>>>
>>>> Does this page or another more advanced way to do this now exist?
>>>>
>>>> Thanks.
>>>>
>
>
>
> ---------------------------------------------------------------------
> 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


Re: Howto access project version programmatically within application

Posted by Steve Cohen <sc...@javactivity.org>.
It appears that this entire class and the interface it is based on are 
deprecated, in favor of org.apache.maven.rtinfo.RuntimeInformation and 
org.apache.maven.rtinfo.internal.DefaultRuntimeInformation.

But this non-deprecated version of the interface/impl REMOVE the 
getApplicationVersion() method.

What's going on here and what is the approved method for getting the 
application version now?


On 01/11/2012 08:59 AM, Steve Cohen wrote:
> Thanks.
> But according to this:
> http://maven.apache.org/ref/3.0.4-SNAPSHOT/apidocs/org/apache/maven/execution/DefaultRuntimeInformation.html
>
>
> the getApplicationVersion() method has been deprecated, with no
> indication as to what I should use instead.
>
> Also, it seems that this introduces a dependency on Maven itself within
> the application. What jar would this be?
>
> Thanks again.
>
> On 01/11/2012 08:12 AM, Guillaume Polet wrote:
>> Just google org/apache/maven/execution/DefaultRuntimeInformation.java .
>>
>> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven/maven-core/2.0.5/org/apache/maven/execution/DefaultRuntimeInformation.java?av=h
>>
>>
>>
>> Cheers,
>> Guillaume
>>
>> Le 11/01/2012 15:03, Steve Cohen a écrit :
>>> A solution to this question appears to have been offered here, in 2007.
>>>
>>> http://maven.40175.n5.nabble.com/HowTo-access-project-version-programmatically-in-application-td82542.html
>>>
>>>
>>>
>>> It references a page explaining how to do it. That page is now gone:
>>>
>>> http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java
>>>
>>>
>>>
>>> Does this page or another more advanced way to do this now exist?
>>>
>>> Thanks.
>>>



---------------------------------------------------------------------
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 within application

Posted by Steve Cohen <sc...@javactivity.org>.
Thanks.
But according to this:
http://maven.apache.org/ref/3.0.4-SNAPSHOT/apidocs/org/apache/maven/execution/DefaultRuntimeInformation.html

the getApplicationVersion() method has been deprecated, with no 
indication as to what I should use instead.

Also, it seems that this introduces a dependency on Maven itself within 
the application.  What jar would this be?

Thanks again.

On 01/11/2012 08:12 AM, Guillaume Polet wrote:
> Just google org/apache/maven/execution/DefaultRuntimeInformation.java .
>
> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven/maven-core/2.0.5/org/apache/maven/execution/DefaultRuntimeInformation.java?av=h
>
>
> Cheers,
> Guillaume
>
> Le 11/01/2012 15:03, Steve Cohen a écrit :
>> A solution to this question appears to have been offered here, in 2007.
>>
>> http://maven.40175.n5.nabble.com/HowTo-access-project-version-programmatically-in-application-td82542.html
>>
>>
>> It references a page explaining how to do it. That page is now gone:
>>
>> http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java
>>
>>
>> Does this page or another more advanced way to do this now exist?
>>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>


---------------------------------------------------------------------
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 within application

Posted by Guillaume Polet <gu...@gmail.com>.
Just google org/apache/maven/execution/DefaultRuntimeInformation.java .

http://grepcode.com/file/repo1.maven.org/maven2/org.apache.maven/maven-core/2.0.5/org/apache/maven/execution/DefaultRuntimeInformation.java?av=h

Cheers,
Guillaume

Le 11/01/2012 15:03, Steve Cohen a écrit :
> A solution to this question appears to have been offered here, in 2007.
>
> http://maven.40175.n5.nabble.com/HowTo-access-project-version-programmatically-in-application-td82542.html 
>
>
> It references a page explaining how to do it.  That page is now gone:
>
> http://svn.apache.org/repos/asf/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultRuntimeInformation.java 
>
>
> Does this page or another more advanced way to do this now exist?
>
> Thanks.
>
> ---------------------------------------------------------------------
> 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