[ 
http://jira.codehaus.org/browse/MNG-2824?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_92264
 ] 

Laurent Fontvielle commented on MNG-2824:
-----------------------------------------

It is possible to use the following workaround:

1.declare the parameter:
    /**
     * @parameter expression="${plugin.mojos}"
     * @required
     * @readonly
     */
    protected List pluginMojos;

2.In the plugin code, you can access the PluginDescriptor instance with this 
code:
       MojoDescriptor mojoDescriptor = (MojoDescriptor) pluginMojos.get(0);
       PluginDescriptor plugin = mojoDescriptor.getPluginDescriptor();
 


> Value of parameter with expression=${plugin} is always null in Mojo
> -------------------------------------------------------------------
>
>                 Key: MNG-2824
>                 URL: http://jira.codehaus.org/browse/MNG-2824
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Plugin API
>    Affects Versions: 2.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4
>         Environment: I believe it happens everywhere since it's a logic 
> problem in code
>            Reporter: Jiaqi Guo
>         Attachments: MNG-2824-maven-core.patch, MNG-2824-maven-core.patch
>
>
> Parameter with expression="${plugin}" in a Mojo is always null at runtime. 
> Looking at 
> http://svn.apache.org/repos/asf/maven/components/tags/maven-2.0.4/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java,
>  line 169 ~ 242, I realized that an "else if" check for "${plugin}" is 
> missing. So if expression is "plugin", line 233 will be executed. 
> expression.substring( 1 ) becomes "lugin" and pluginDescriptor.getLugin() 
> will be called by ReflectionValueExtractor, and returns null because it's 
> invalid. More detail has been discussed in mailing list: 
> http://www.nabble.com/Can-anyone-explain-this-code-tf3218981s177.html
> The fix is simple. I can just add another condition check for 
> "plugin".equals(expression).
> The problem has been there since 2.0 release but it doesn't exist in trunk. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to