Brian E. Fox wrote:
> Plugins can't really be extended. What is most likely happening is that the metadata that tells plexus what to inject is not included in your plugin. There is a plugin/tool out there that supposedly allows you to extend plugins by merging the metadata, but I forget the name.
>
> -----Original Message-----
> From: walid joseph Gedeon [mailto:
wgedeon@...]
> Sent: Tuesday, April 29, 2008 10:37 AM
> To: Maven Developers List
> Subject: Can plugins be extended?
>
> Hello all,
> After failing to customize the compiler pluging (by passing
> <compileSourceRoots /> in the maven-compiler-plugin <configuration />); I've
> went onto trying to extend the maven-compiler-plugin CompileMojo to just set
> that variable.
>
> It looks like I've missed something: the injected parameters of the super
> classes are not being set (e.g. the parameter compilerId, or the component
> compilerManager in AbstractCompilerMojo are null).
> Is there a flag that enables injection of parameters in super classes? Or is
> the issue something else?
>
> Thanks :-)
> Walid.
>
> Note: a component definition maps the custom-compile goal to the <compile />
> phase.
>
> o====x maven-customcompile-plugin Mojo: x====o
> /**
> * @goal custom-compile
> * @phase compile
> * @requiresDependencyResolution runtime
> */
> public class CustomCompilerMojo extends CompilerMojo {
> // ...
>
> /**
> * @parameter
> */
> private List<String> compileSourceRoots;
>
> protected List<String> getCompileSourceRoots()
> {
> return compileSourceRoots;
> }
>
> public void execute() throws MojoExecutionException,
> CompilationFailureException
> {
> super.execute();
> }
> }
>
> o====x Project POM: x====o
> <!-- ... -->
> <build>
> <plugins>
> <plugin>
> <groupId>fr.gedeon</groupId>
> <artifactId>maven-customcompile-plugin</artifactId>
> <extensions>true</extensions>
> <configuration>
> <compileSourceRoots>
> <directory>Dev/src/java</directory>
> </compileSourceRoots>
> </configuration>
> </plugin>
> </plugins>
> </build>
>
> o====x Partial Trace: x====o
> [DEBUG] Configuring mojo
> 'fr.gedeon:maven-customcompile-plugin:1.0-SNAPSHOT:custom-compile' -->
> [DEBUG] (f) compileSourceRoots = [Dev/src/java]
> [DEBUG] (f) project = org.apache.maven.project.MavenProject@82bcf39e
> [DEBUG] -- end configuration --
> [INFO] [bem:custom-compile]
> [DEBUG] Using compiler 'null'.
>
>> ^ this is from getLog().debug( "Using compiler '" + compilerId +
>>
> "'." );
>
>> in AbstractCompilerMojo
>>
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] FATAL ERROR
> [INFO]
> ------------------------------------------------------------------------
> [INFO] null
> [INFO]
> ------------------------------------------------------------------------
> [DEBUG] Trace
> java.lang.NullPointerException
> at
> org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:267)
>
>> ^ I suppose this is compiler = compilerManager.getCompiler(
>>
> compilerId );
>
>> with compilerManager = null
>>
> at
> org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
> at
> org.apache.maven.plugin.CompileBemMojo.execute(CompileBemMojo.java:37)
> ...
>