You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "G. B." <gb...@laposte.net> on 2006/05/24 14:19:33 UTC

Version of current Mojo

Hi,

How can I, inside my class that extends AbstractMojo, print my own version.

thanks.
Guillaume
--
View this message in context: http://www.nabble.com/Version+of+current+Mojo-t1674737.html#a4540163
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Version of current Mojo

Posted by Trygve Laugstøl <tr...@inamo.no>.
G. B. wrote:
> Hi,
> 
> How can I, inside my class that extends AbstractMojo, print my own version.
> 
> thanks.
> Guillaume
> --
> View this message in context: http://www.nabble.com/Version+of+current+Mojo-t1674737.html#a4540163
> Sent from the Maven - Users forum at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> 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: Version of current Mojo

Posted by "G. B." <gb...@laposte.net>.

Trygve Laugstøl-5 wrote:
> 
> 
> InputStream is = 
> this.getClass().getResource("/META-INF/maven/groupid/artifactid/pom.properties")
> 
> 
oh yess I forgot about that file. Thanks a lot!
Guillaume
--
View this message in context: http://www.nabble.com/Version+of+current+Mojo-t1674737.html#a4549212
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Version of current Mojo

Posted by Trygve Laugstøl <tr...@apache.org>.
G. B. wrote:
> Hi,
> 
> How can I, inside my class that extends AbstractMojo, print my own version.

(This applies to all Maven-built JAR artifacts)

Maven will add a properties file containing a few very useful bits from 
the POM into a properties file that you can load like this:

InputStream is = 
this.getClass().getResource("/META-INF/maven/groupid/artifactid/pom.properties")

Properties properties = new Properties();
properties.load()

System.out.println("My version is: " + properties.getProperty("version") );

--
Trygve

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Version of current Mojo

Posted by "G. B." <gb...@laposte.net>.

javed mandary wrote:
> 
> Add this as global variable to your MOJO:
>     /**
>      * @parameter expression="${project}"
>      * @required
>      */
>     private MavenProject project;
> 
> 
> Then get your version number simply by performing:
> project.getVersion();
> 
> 

thanks but that will give me the version of the project I'm processing, not
the version of the processor(mojo that is processing the project) itself...

Guillaume
--
View this message in context: http://www.nabble.com/Version+of+current+Mojo-t1674737.html#a4540460
Sent from the Maven - Users forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Version of current Mojo

Posted by javed mandary <ja...@gmail.com>.
Add this as global variable to your MOJO:
    /**
     * @parameter expression="${project}"
     * @required
     */
    private MavenProject project;


Then get your version number simply by performing:
project.getVersion();

cheers,
      Javed

On 5/24/06, G. B. <gb...@laposte.net> wrote:
>
>
> Hi,
>
> How can I, inside my class that extends AbstractMojo, print my own
> version.
>
> thanks.
> Guillaume
> --
> View this message in context:
> http://www.nabble.com/Version+of+current+Mojo-t1674737.html#a4540163
> Sent from the Maven - Users forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>