tags:

views:

68

answers:

1

Hi, i've a maven plugin composed of some mojos. Suppose there is myproject.FirstMojo declared as @goal first and myproject.SecondMojo declared as @goal second

what I want to do is inject first mojo as property of second mojo. What I've tried is declare it the following way :

/**
 * @component role="myproject.FirstMojo"
 */
private FirstMojo first;

Unfortunatly, when doing so, I get a Component descriptor cannot be found in the component repository: error.

What should I do ?

+2  A: 

You can use:

/** @component role="org.apache.maven.plugin.Mojo" role-hint="groupId:artifactId:version:second" */
private FirstMojo first;

Note that they have to be in the same plugin, and you must replace the group, artifact and version with your values. This will likely involve filtering your source code for the correct version, which makes it a bit complicated.

I would highly recommend factoring out the functionality you need into a separate class (perhaps a Plexus component if you need access to some components in there), or an abstract base class.

Brett Porter
I will in fact follow your advice and not rely upon nexus dependency resolution, but instead factore code out for better organization. Thanks anyway for the reply.
Riduidel