pom.xml
<pluginManagement>
<plugins>
<plugin>
<groupId>com.example.groupid</groupId>
<artifactId>artifact-example-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<id>mojo-plugin-id</id>
<goals>
<goal>example-gole</goal>
</goals>
<phase>integration-test</phase>
<configuration>
<employee>
<firstName>MyFirstName</firstName>
<middleName>MyMiddleName</middleName>
<lastName>MyLastName</lastName>
</employee>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
上面的配置标签值在 java 类中设置为 null(java 类如下),但是如果我删除了“pluginManagement”标签,一切正常
示例Mojo.java
@Mojo(name = "example-gole")
公共类 ExampleMojo 扩展 AbstractMojo {
@Parameter(property = "employee")
private Employee employee;
@Override
public void execute() throws MojoExecutionException {
getLog().info(employee);
}
}
execute 方法向所有属性显示空输出
雇员.java
public class Employee implements Serializable {
private static final long serialVersionUID = 1L;
private String firstName;
private String middleName;
private String lastName;
// consider constructor, getter and setter, hashcode, eqauls, toString is available
}
更多信息
创建自定义 maven 插件,上面的 java 类来自 maven 插件,但上面的 pom.xml 配置来自其调用者。
长风秋雁
相关分类