我想在maven插件中配置一些复杂的对象..比如 -
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.helloworld</groupId>
<artifactId>hw</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>com.test.my.maven.plugin</groupId>
<artifactId>my-maven-plugin</artifactId>
<version>1.0.0</version>
<extensions>true</extensions>
<configuration>
<myObject>
<name>mike</name>
<age>23</age>
<props>
<property>
<key>test</key>
<value>testValue</value>
</property>
</props>
</myObject>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是我想要使用这些配置的样本mojo -
public class testMojo extends AbstractMojo{
@Parameter
private Map<String, Object> myObject;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
String name = (String)myObject.get("name");
String age = (String)myObject.get("age");
Properties props = (Properties)myObject.get("props");
}
}
但它为myObject提供了null值。 我尝试过按照here创建一个类 即便它给我零值。 我怎样才能在maven mojo中进行这种复杂的映射?