Hi,
I'm trying to do some pretty advanced things with custom plugins with
@Components.

Basically, I want to use the same mojo with slight variations, and I want
to be able to inject those variations via the pom (or via the <packaging>
perhaps as well).  The plugin already defines a custom lifecycle, so I am
ok if I have to define that lifecycle twice, I just don't want to have to
define the 12+ mojos twice for almost the exact same thing.

Essentially, I have a mojo that define a @Component:

@Component
Parser parser;


I then I have two implementations of that Parser interface:

@Component(role=Parser.class, hint="simple")
public class SimpleParser implements Parser

and

@Component(role=Parser.class, hint="complex")
public class ComplexParser implements Parser


I know that on the mojo itself, could tell the mojo which one to use (by
setting it like this: @Component(hint = "complex")

but what I really want is to force the user to define the hint in the pom
or command line.  But as far as I can tell, there is no way to do this.  Is
there a way around this other than making two separate mojos, which then
defeats the purpose of using plexus at all here as far as I can tell,
because  I may as well just define the implementation explicitly (albeit,
plexus would still be useful for test code, I suppose).

Can I use an expression for the hint, and perhaps pass that as a separate
parameter somehow?

Any help or suggestions would be appreciated.

-Ben



-- 
Ben Tatham
Sr. Software Engineer
Nanometrics Inc.
+1 613-592-6776 x254
http://www.nanometrics.ca

Reply via email to