maven及依赖
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
插件开发
/**
* 自定义的maven插件
*/
@Mojo(name = "hello", defaultPhase = LifecyclePhase.PACKAGE )
public class HelloPlugin extends AbstractMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
System.err.println("hello...");
}
}
使用插件
<plugin>
<groupId>com.pengsn</groupId>
<artifactId>hello</artifactId>
<version>0.0.1-SNAPSHOT</version>
</plugin>