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

Reply via email to