Apache Maven Using plugin configuration


Plugins can be configured by annotating fields with @Parameter. The MOJO is then injected with the configuration.

@Mojo(name = "greet")
public final class GreetMojo extends AbstractMojo {

    @Parameter(required = true)
    public String name;

    public void execute() throws MojoExecutionException, MojoFailureException {
        getLog().info("Hello " + name);

The name parameter can be configured in the POM:


If the greet goal is run as a standalone goal the name parameter can be defined as property on the command line:

mvn <plugin name>:greet -Dname=Geri