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”标记,则一切正常
ExampleMojo.java
@Mojo(name = "example-gole")
公共类ExampleMojo扩展AbstractMojo {
@Parameter(property = "employee")
private Employee employee;
@Override
public void execute() throws MojoExecutionException {
getLog().info(employee);
}
}
执行方法对所有属性显示空输出
Employee.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配置来自其调用者。
答案 0 :(得分:0)
现在正在为我工作。使用“插件”“配置”标签代替“执行”“配置”标签
<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>
</execution>
</executions>
<configuration>
<employee>
<firstName>MyFirstName</firstName>
<middleName>MyMiddleName</middleName>
<lastName>MyLastName</lastName>
</employee>
</configuration>
</plugin>
</plugins>