Hi all,

I'm following the online documentation to write a plugin
(http://maven.apache.org/guides/mini/guide-configuring-plugins.html).
I have

package sample.plugin;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;

/**
 * Says "Hi" to the user.
 *
 * @goal sayhi
 * @phase generate-sources
 */
public class GreetingMojo extends AbstractMojo {
  /**
   * The greeting to display.
   *
   * @parameter expression="${sayhi.greeting}" default-value="Hello World!"
   */
  private String greeting;

  /**
   * @execute phase="generate-sources"
   */
  @Override
  public void execute() throws MojoExecutionException {
    getLog().info(greeting);
  }
}

This works if I invoke the plugin directly (i.e. mvn greeting:sayhi).
I have it configured as

<build><plugins><plugin>
  <groupId>org.example.maven.plugins</groupId>
  <artifactId>greeting-maven-plugin</artifactId>
  <version>0.1-SNAPSHOT</version>
  <configuration>
    <greeting>Howdy!</greeting>
  </configuration>
</plugin></plugins></build>

so it prints "Howdy!". Excellent, so far.

But despite the "@phase generate-sources" and "@execute
generate-sources" I cannot get it to run in the generate-sources phase
by simply invoking something like "mvn compile". (I'm using Maven
3.0.3 and maven-plugin-api 3.0.)

How do I get the greeting plugin to run (by default) in a particular
phase? (I know I can use <executions> to configure it explicitly but
the documentation seems to indicate I can configure a default phase.)

Cheers,
Hilco

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to