You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Eric Rotick <pc...@gmail.com> on 2009/07/26 17:11:07 UTC

maven-plugin-plugin parser problem

Hi all,

I've been writing some plugins and all is OK. I've now been told to
integrate these into the system which means comments, documentation etc. Now
the plugins no longer work ;-(

I've found out why and done some more digging and I can see there are
several other problems in a similar area to do with qdox but I haven't found
this one so I thought I document it here for others to see.

If we take the following example
>
> package example;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
/**
 *  @goal sayhi
 */
public class ExamplePluginMojo extends AbstractMojo {
    public void execute( ) throws MojoExecutionException {
        getLog( ).info( "Hello world!" );
    }
}

everything works as you would expect.

Now if I add some comments

/*************************************************************/
/* Package that this class is in                             */
/*************************************************************/

package example;

/*************************************************************/
/* Other packages to import                                  */
/*************************************************************/

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
/**
 *  @goal sayhi
 */
public class ExamplePluginMojo extends AbstractMojo {
    public void execute( ) throws MojoExecutionException {
        getLog( ).info( "Hello world!" );
    }
}

everything compiles but the plugin fails to run. This is down to the
implementation value in plugin.xml not including the package. The error is

Internal error in the plugin manager executing goal
'example:example-plugin:0.1:sayhi': Unable to find the mojo 'sayhi' (or one
of its required components) in the plugin 'example:example-plugin'
ExamplePluginMojo

A snippet from plugin.xml

...
  <mojos>
    <mojo>
      <goal>sayhi</goal>
      <description>/

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
/**</description>
      <requiresDirectInvocation>false</requiresDirectInvocation>
      <requiresProject>true</requiresProject>
      <requiresReports>false</requiresReports>
      <aggregator>false</aggregator>
      <requiresOnline>false</requiresOnline>
      <inheritedByDefault>true</inheritedByDefault>
      *<implementation>ExamplePluginMojo</implementation>*
      <language>java</language>
      <instantiationStrategy>per-lookup</instantiationStrategy>
      <executionStrategy>once-per-session</executionStrategy>
      <parameters/>
    </mojo>
  </mojos>
...

The mess in the description section is a clue as to what is going wrong. It
is worth noting that it is only the comments relating to the package which
cause the problem.

I've since found the maven-plugin-anno plugin which seems to overcome this
problem but there are some compatability issues so I can't use that either.

The workaround it to forget the comments! The team leader thinks I've
invented this one to annoy him ;-)

Eric

Re: maven-plugin-plugin parser problem

Posted by Eric Rotick <pc...@gmail.com>.
If you use either /* .. */ or // type comments the plugin runs but the
description is still wrong. The workaround is simple but the parser picks up
other javadoc style comments in error. This has to be wrong.

Eric

On Sun, Jul 26, 2009 at 5:17 PM, Heinrich Nirschl <
heinrich.nirschl@gmail.com> wrote:

> On Sun, Jul 26, 2009 at 5:11 PM, Eric Rotick<pc...@gmail.com> wrote:
> >
> > /*************************************************************/
> > /* Package that this class is in                             */
> > /*************************************************************/
>
> I guess, it would already help if your comments do not start with
> "/**". For example, try to put a space after the first asterisk.
>
> - Henry
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: maven-plugin-plugin parser problem

Posted by Heinrich Nirschl <he...@gmail.com>.
On Sun, Jul 26, 2009 at 5:11 PM, Eric Rotick<pc...@gmail.com> wrote:
>
> /*************************************************************/
> /* Package that this class is in                             */
> /*************************************************************/

I guess, it would already help if your comments do not start with
"/**". For example, try to put a space after the first asterisk.

- Henry

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org