Tutorial by Examples

An artifact built by Maven can be declared as a Maven plugin by specifying the packaging as maven-plugin in the pom.xml. <packaging>maven-plugin</packaging> You need to declare a dependency on the plugin API and annotations. <dependency> <groupId>org.apache.maven&lt...
Goals are implemented by creating a MOJO. This is a class file annotated with annotations from maven-plugin-annotations. @Mojo(name = "hello") public final class HelloWorldMojo extends AbstractMojo { public void execute() throws MojoExecutionException, MojoFailureException { ...
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 Mojo...
The plugin can, among others, access information about the current Maven project being built. @Mojo(name = "project") public final class ProjectNameMojo extends AbstractMojo { @Parameter(defaultValue = "${project}", readonly = true, required = true) private MavenPro...
@Mojo(name = "hi", defaultPhase = LifecyclePhase.COMPILE)
@Parameter(defaultValue = "${project.build.directory}") private File buildDirectory;

Page 1 of 1