The example of map attribute for a mojo mentioned in maven.apache.org is quite simple as it defines a Map with a String as a key and as a value as specified below :
/**
* My Map.
*/
@Parameter
private Map myMap;
and it's assigned configuration would look like this :
<myMap>
<key1>value1</key1>
<key2>value2</key2>
</myMap>
What I am trying to achieve is a more advanced map which takes a String as a key and my own defined class Person as value:
/**
* My Advanced Map.
*/
@Parameter
private Map<String,Person> myMap;
The Person class is located in the same package as my MOJO and it looks like:
public class Person {
private String name;
private int age;
public void setName( String name )
{
this.name = name;
}
public void setAge( int age )
{
this.age = age;
}
public String getName( )
{
return this.name;
}
public int getAge( )
{
return this.age ;
}
}
I assume that the configuration for my MOJO would look like :
<myMap>
<firstPerson>
<person>
<name>steve</name>
<age>26</age>
</person>
</firstPerson>
<secondPerson>
<person>
<name>meruem</name>
<age>1</age>
</person>
</secondPerson>
</myMap>
Running this MOJO with the above configuration will create the map with the defined keys but I always get null values : {firstPerson=null,secondPerson=null}
Currently, I don't know whether I am doing something wrong or if the example is even supported as no documentation has been found that describes an 'advanced' map attribute and my last resort for now would be browsing the sources.