You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Paul Gier <pg...@redhat.com> on 2007/02/22 17:00:50 UTC

Get the scm settings from plugin

I would like to be able to access the scm settings (connection, tag, 
etc) in the pom.xml from within a plugin.  Is this possible?  It seems 
like there should be an easy way to get access to all of the pom 
configuration from within a plugin, but I haven't found it yet.  I tried 
looking in project.properties, but it was empty.  Is project.properties 
used for anything?

Thanks!

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


Re: Get the scm settings from plugin

Posted by Dan Tran <da...@gmail.com>.
all you need is to have access to 'project' instance and use it to get pom's
info.

put the below fragment in your mojo


/**

* *@parameter* expression="${project}"

* *@readonly
*

*/

*protected* MavenProject project;



On 2/22/07, Paul Gier <pg...@redhat.com> wrote:
>
> I would like to be able to access the scm settings (connection, tag,
> etc) in the pom.xml from within a plugin.  Is this possible?  It seems
> like there should be an easy way to get access to all of the pom
> configuration from within a plugin, but I haven't found it yet.  I tried
> looking in project.properties, but it was empty.  Is project.properties
> used for anything?
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Get the scm settings from plugin

Posted by David Jackman <Da...@fastsearch.com>.
It's not documented anywhere that I know of.  I've been sitting on the
source code with this project.properties problem and figured out how
most things come out.  I should create a wiki page for it--a mapping of
pom elements to their respective Maven-model types.

..David..
 

-----Original Message-----
From: Paul Gier [mailto:pgier@redhat.com] 
Sent: Thursday, February 22, 2007 11:04 AM
To: Maven Users List
Subject: Re: Get the scm settings from plugin

Thanks, it works!
Does that work for the other objects in the model?
For example if I also want to get the license information can I use
${project.license} to get a License object from model?
Is that functionality documented anywhere?

David Jackman wrote:
> It seems project.properties will always be empty (I've been working on

> that issue in the "Mojo accessing project properties" thread in this 
> forum).
>
> However, what you want isn't in the properties anyway.  What you want 
> is the project.scm value.  Declare your plugin field like this:
>
>     /**
>      * Source control information.
>      * @parameter expression="${project.scm}"
>      * @required
>      * @readonly
>      */
>     private org.apache.maven.model.Scm scm;
>  
> You'll need to add maven-model as a dependency to your plugin as well:
>         <dependency>
>             <groupId>org.apache.maven</groupId>
>             <artifactId>maven-model</artifactId>
>             <version>2.0.4</version>
>         </dependency>
>
> That should be enough to get the scm information in your plugin.
>
> ..David..
>
> -----Original Message-----
> From: Paul Gier [mailto:pgier@redhat.com]
> Sent: Thursday, February 22, 2007 9:01 AM
> To: users@maven.apache.org
> Subject: Get the scm settings from plugin
>
> I would like to be able to access the scm settings (connection, tag,
> etc) in the pom.xml from within a plugin.  Is this possible?  It seems

> like there should be an easy way to get access to all of the pom 
> configuration from within a plugin, but I haven't found it yet.  I 
> tried looking in project.properties, but it was empty.  Is 
> project.properties used for anything?
>
> 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


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


Re: Get the scm settings from plugin

Posted by Paul Gier <pg...@redhat.com>.
Thanks, it works!
Does that work for the other objects in the model?
For example if I also want to get the license information can I use 
${project.license} to get a License object from model?
Is that functionality documented anywhere?

David Jackman wrote:
> It seems project.properties will always be empty (I've been working on
> that issue in the "Mojo accessing project properties" thread in this
> forum).
>
> However, what you want isn't in the properties anyway.  What you want is
> the project.scm value.  Declare your plugin field like this:
>
>     /**
>      * Source control information.
>      * @parameter expression="${project.scm}"
>      * @required
>      * @readonly
>      */
>     private org.apache.maven.model.Scm scm;
>  
> You'll need to add maven-model as a dependency to your plugin as well:
>         <dependency>
>             <groupId>org.apache.maven</groupId>
>             <artifactId>maven-model</artifactId>
>             <version>2.0.4</version>
>         </dependency>
>
> That should be enough to get the scm information in your plugin.
>
> ..David..
>
> -----Original Message-----
> From: Paul Gier [mailto:pgier@redhat.com] 
> Sent: Thursday, February 22, 2007 9:01 AM
> To: users@maven.apache.org
> Subject: Get the scm settings from plugin
>
> I would like to be able to access the scm settings (connection, tag,
> etc) in the pom.xml from within a plugin.  Is this possible?  It seems
> like there should be an easy way to get access to all of the pom
> configuration from within a plugin, but I haven't found it yet.  I tried
> looking in project.properties, but it was empty.  Is project.properties
> used for anything?
>
> 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: Get the scm settings from plugin

Posted by David Jackman <Da...@fastsearch.com>.
It seems project.properties will always be empty (I've been working on
that issue in the "Mojo accessing project properties" thread in this
forum).

However, what you want isn't in the properties anyway.  What you want is
the project.scm value.  Declare your plugin field like this:

    /**
     * Source control information.
     * @parameter expression="${project.scm}"
     * @required
     * @readonly
     */
    private org.apache.maven.model.Scm scm;
 
You'll need to add maven-model as a dependency to your plugin as well:
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-model</artifactId>
            <version>2.0.4</version>
        </dependency>

That should be enough to get the scm information in your plugin.

..David..

-----Original Message-----
From: Paul Gier [mailto:pgier@redhat.com] 
Sent: Thursday, February 22, 2007 9:01 AM
To: users@maven.apache.org
Subject: Get the scm settings from plugin

I would like to be able to access the scm settings (connection, tag,
etc) in the pom.xml from within a plugin.  Is this possible?  It seems
like there should be an easy way to get access to all of the pom
configuration from within a plugin, but I haven't found it yet.  I tried
looking in project.properties, but it was empty.  Is project.properties
used for anything?

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