But you have to be aware of the downside: You cannot upgrade the compiler-plugin anymore without creating a new version of your plugin. Any plugin is loaded once and the first one wins. Nice effects in reactor builds ;-)
walid joseph Gedeon wrote: > Indeed! Thanks :-) > > So, for the summary, here are the steps that provided my solution: > > 1) in the pom, added maven-inherit-plugin, as described in > the plugin > documentation. > > 2) in the mojo, in my case I needed to extend a goal with a > different name: > /** > * @extendsPlugin maven-compiler-plugin > * @extendsGoal compile > * @goal custom-compile > * @phase compile > */ > public class CustomCompileMojo extends CompilerMojo { //... > > 3) in the pom, the dependency requires a type to be specified: > <dependency> <groupId>org.apache.maven.plugins</groupId> > <artifactId>maven-compiler-plugin</artifactId> > <type>maven-plugin</type> > <version>2.0.2</version> > </dependency> > > I'm thinking all of this (a summary) would be good as an item > in the "Maven > Plugins Cookbook"... something like "How to extend an > existing plugin?" > What's the accepted way of getting it up there? I wouldnt > mind writing it. > > W. > > On Tue, Apr 29, 2008 at 6:49 PM, VELO <[EMAIL PROTECTED]> wrote: > >> Try add type to dependency: >> <type>maven-plugin</type> >> >> >> VELO >> >> >> On Tue, Apr 29, 2008 at 1:46 PM, walid joseph Gedeon >> <[EMAIL PROTECTED]> wrote: >> >>> It seems to want to do what I need... but I can't seem to get rid >>> of this error: >>> >>> [ERROR] BUILD ERROR >>> [INFO] >>> > -------------------------------------------------------------- > ---------- >>> [INFO] maven-compiler-plugin plugin is not a dependency >>> >>> eventhough I do have it in my pom... >>> >>> <dependency> >>> <groupId>org.apache.maven.plugins</groupId> >>> <artifactId>maven-compiler-plugin</artifactId> >>> <version>2.0.2</version> >>> </dependency> >>> >>> Looking at the code, it seems to also want to allow "compiler", but >>> tried that too with no luck... >>> Still digging, but if anyone has an idea, all hints are appreciated >>> :-) >>> >>> W >>> >>> >>> On Tue, Apr 29, 2008 at 6:39 PM, VELO <[EMAIL PROTECTED]> wrote: >>> >>>> I use it, works! >>>> >>>> VELO >>>> >>>> On Tue, Apr 29, 2008 at 11:45 AM, Benoit Decherf < >>>> [EMAIL PROTECTED]> >>>> wrote: >>>> >>>>> Here is the plugin: >>>>> > http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/ >>>>> >>>>> Benoit >>>>> >>>>> >>>>> 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:[EMAIL PROTECTED] 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 = >>>> [EMAIL PROTECTED] >>>>>> [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(AbstractC > ompilerMojo.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) >>>>>> ... --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]