Idea开发maven插件
CustomMavenMojo:表示该插件的服务目标
compile:表示该插件的生效周期阶段
false:表示是否依托于一个项目才能运行该插件
"${name}":表示插件参数,使用插件的时候会用得到 expression=
:代表该参数不能省略
maven install
<plugin>
<groupId>org.example</groupId>
<artifactId>TestMojo</artifactId>
<version>2</version>
<configuration>
<name>tianjingle</name>
</configuration>
<executions>
<execution>
//在install阶段执行
<phase>install</phase>
<goals>
//这块可以添加多个
<goal>tianjingle</goal>
</goals>
</execution>
</executions>
</plugin>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.8</version>
</dependency>
"tianjingle") //相当于@goal注释 (name =
public class TestMojo extends AbstractMojo {
//相当于@parameter注释
false,defaultValue = "tianjingle",property = "name") (readonly =
private String name;
public void execute() throws MojoExecutionException, MojoFailureException {
System.out.println("test mojo .....");
System.out.println("---"+name);
}
}
评论