Can plugins be extended?

View: New views
15 Messages — Rating Filter:   Alert me  

Can plugins be extended?

by walid joseph Gedeon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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)
...

RE: Can plugins be extended?

by Nick Stolwijk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is a known issue [1]. Short answer: no, it is not possible. Long answer: maven-inherit-plugin [2] I don't have any experience with it, but you could give it a try.

Hth,

Nick S.

[1] http://jira.codehaus.org/browse/MNG-3042
[2] http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/


-----Original Message-----
From: walid joseph Gedeon [mailto:wgedeon@...]
Sent: Tue 4/29/2008 16:37
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)
...


RE: Can plugins be extended?

by Brian E Fox :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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)
...

Re: Can plugins be extended?

by walid joseph Gedeon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks! I'll give it a try.

On Tue, Apr 29, 2008 at 4:40 PM, <nicklist@...> wrote:

> This is a known issue [1]. Short answer: no, it is not possible. Long
> answer: maven-inherit-plugin [2] I don't have any experience with it, but
> you could give it a try.
>
> Hth,
>
> Nick S.
>
> [1] http://jira.codehaus.org/browse/MNG-3042
> [2] http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/
>
>
> -----Original Message-----
> From: walid joseph Gedeon [mailto:wgedeon@...]
> Sent: Tue 4/29/2008 16:37
> 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)
> ...
>
>

Re: Can plugins be extended?

by Benoit Decherf-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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: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)
> ...
>  


Re: Can plugins be extended?

by Marvin Froeder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I use it, works!

VELO

On Tue, Apr 29, 2008 at 11:45 AM, Benoit Decherf <decherfb@...>
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: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)
> > ...
> >
> >
>
>

Re: Can plugins be extended?

by walid joseph Gedeon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <velo.br@...> wrote:

> I use it, works!
>
> VELO
>
> On Tue, Apr 29, 2008 at 11:45 AM, Benoit Decherf <decherfb@...>
> 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: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)
> > > ...
> > >
> > >
> >
> >
>

Re: Can plugins be extended?

by Marvin Froeder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try add type to dependency:
<type>maven-plugin</type>


VELO

On Tue, Apr 29, 2008 at 1:46 PM, walid joseph Gedeon <wgedeon@...>
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 <velo.br@...> wrote:
>
> > I use it, works!
> >
> > VELO
> >
> > On Tue, Apr 29, 2008 at 11:45 AM, Benoit Decherf <decherfb@...
> > >
> > 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: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)
> > > > ...
> > > >
> > > >
> > >
> > >
> >
>
>

Re: Can plugins be extended?

by walid joseph Gedeon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 <velo.br@...> wrote:

> Try add type to dependency:
> <type>maven-plugin</type>
>
>
> VELO
>
>
> On Tue, Apr 29, 2008 at 1:46 PM, walid joseph Gedeon <wgedeon@...>
> 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 <velo.br@...> wrote:
> >
> > > I use it, works!
> > >
> > > VELO
> > >
> > > On Tue, Apr 29, 2008 at 11:45 AM, Benoit Decherf <
> > > decherfb@...>
> > > 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: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)
> > > > > ...
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Re: Can plugins be extended?

by walid joseph Gedeon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Please ignore my last question :-) I should have read the "How to
contribute" ;-)

On Tue, Apr 29, 2008 at 7:02 PM, walid joseph Gedeon <wgedeon@...>
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 <velo.br@...> wrote:
>
> > Try add type to dependency:
> > <type>maven-plugin</type>
> >
> >
> > VELO
> >
> >
> > On Tue, Apr 29, 2008 at 1:46 PM, walid joseph Gedeon <wgedeon@...>
> > 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 <velo.br@...> wrote:
> > >
> > > > I use it, works!
> > > >
> > > > VELO
> > > >
> > > > On Tue, Apr 29, 2008 at 11:45 AM, Benoit Decherf <
> > > > decherfb@...>
> > > > 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: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(AbstractCompilerMoj