The MavenProject is not a component that is injected by the container. It's 
handled by the PluginParameterExpressionEvaluator[1] which looks at all the 
non-@component things and sets their values once the Mojo instance is 
constructed.

[1]: 
https://github.com/apache/maven-3/blob/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java

On Nov 27, 2012, at 10:26 PM, Barrie Treloar <[email protected]> wrote:

> While trying to sort out
> http://maven.40175.n5.nabble.com/Retrieving-the-project-source-directories-from-MavenProject-td5733602.html
> 
> I was hacking his code and found that
> Java 1.5 @Component MavenProject returns null
> 
> But when I changed it to use JavaDoc @parameter
> expression="${project}" it works fine.
> 
> http://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html
> gives an example
>    @Component
>    private MavenProject project;
> 
> http://maven.apache.org/plugin-tools/maven-plugin-annotations/apidocs/org/apache/maven/plugins/annotations/Component.html
> says MavenProject can be accessed via @Component
> 
> I've not used the Java 1.5 annotations before.
> Does anyone know why this might be?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder & CTO, Sonatype
Founder,  Apache Maven
http://twitter.com/jvanzyl
---------------------------------------------------------

happiness is like a butterfly: the more you chase it, the more it will
elude you, but if you turn your attention to other things, it will come
and sit softly on your shoulder ...

-- Thoreau 





Reply via email to