You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Scott Carter <ca...@gmail.com> on 2008/11/07 00:15:39 UTC

Writing Plugins : how to access context variables

I am writing a Maven2 plugin where I need to be able to determine the
basedir for the pom that is running.  I know that in a POM you can refer to
${basedir} for this value, but how would you access this value at a code
level in a plugin?  Does someone have a code example of this?

Thanks in advance

Re: Writing Plugins : how to access context variables

Posted by Dan Tran <da...@gmail.com>.
Inject MavenProject component into your mojo.

then call project.getBasedir() i think

-D

On Thu, Nov 6, 2008 at 3:15 PM, Scott Carter <ca...@gmail.com> wrote:
> I am writing a Maven2 plugin where I need to be able to determine the
> basedir for the pom that is running.  I know that in a POM you can refer to
> ${basedir} for this value, but how would you access this value at a code
> level in a plugin?  Does someone have a code example of this?
>
> Thanks in advance
>

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


Re: Writing Plugins : how to access context variables

Posted by sinplicity <ca...@gmail.com>.
I got it now, had the annotation in the wrong place.  Thank you for the help

sinplicity wrote:
> 
> I see how you are using the annotation, but the basedir String is still
> null.  How do you actually get the basedir value set in the String?
> 
> 
> Olivier Lamy wrote:
>> 
>> Try with :
>> 
>>     /**
>>      * The current project base directory.
>>      *
>>      * @parameter expression="${basedir}"
>>      * @required
>>      */
>>     private String basedir;
>> 
>> --
>> Olivier
>> 
>> 2008/11/7 Scott Carter <ca...@gmail.com>:
>>> I am writing a Maven2 plugin where I need to be able to determine the
>>> basedir for the pom that is running.  I know that in a POM you can refer
>>> to
>>> ${basedir} for this value, but how would you access this value at a code
>>> level in a plugin?  Does someone have a code example of this?
>>>
>>> Thanks in advance
>>>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Writing-Plugins-%3A-how-to-access-context-variables-tp20371807p20372248.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Writing Plugins : how to access context variables

Posted by sinplicity <ca...@gmail.com>.
I see how you are using the annotation, but the basedir String is still null. 
How do you actually get the basedir value set in the String?


Olivier Lamy wrote:
> 
> Try with :
> 
>     /**
>      * The current project base directory.
>      *
>      * @parameter expression="${basedir}"
>      * @required
>      */
>     private String basedir;
> 
> --
> Olivier
> 
> 2008/11/7 Scott Carter <ca...@gmail.com>:
>> I am writing a Maven2 plugin where I need to be able to determine the
>> basedir for the pom that is running.  I know that in a POM you can refer
>> to
>> ${basedir} for this value, but how would you access this value at a code
>> level in a plugin?  Does someone have a code example of this?
>>
>> Thanks in advance
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Writing-Plugins-%3A-how-to-access-context-variables-tp20371807p20372124.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Writing Plugins : how to access context variables

Posted by Olivier Lamy <ol...@apache.org>.
Try with :

    /**
     * The current project base directory.
     *
     * @parameter expression="${basedir}"
     * @required
     */
    private String basedir;

--
Olivier

2008/11/7 Scott Carter <ca...@gmail.com>:
> I am writing a Maven2 plugin where I need to be able to determine the
> basedir for the pom that is running.  I know that in a POM you can refer to
> ${basedir} for this value, but how would you access this value at a code
> level in a plugin?  Does someone have a code example of this?
>
> Thanks in advance
>

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