Maven Mojo Mapping Complex Objects

I am trying to write a maven plugin including mapping a custom class in mvn config options. Does anyone know what the equivalent Human class looks like: http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Mapping_Complex_Objects

<configuration>
     <person>
          <firstName>Jason</firstName>
          <lastName>van Zyl</lastName>
     </person>
</configuration>

      

My custom mojo looks like this:

/**
 * @parameter property="person"
 */
protected Person person;

      

public class Person {
    protected String firstName;
    protected String lastName;
}

      

but I always get the following error: Unable to parse mojo config ... for parameter person: unable to instantiate class ... $ Person

Can anyone help me?


EDIT:

Mojo class with Person (including default constructor, getter and setter) as inner class.

public class BaseMojo extends AbstractMojo {

/**
 * @parameter property="ios.person"
 */
protected Person person;

public class Person {
    /**
     * @parameter property="ios.firstName"
     */
    protected String firstName;

    /**
     * @parameter property="ios.lastName"
     */
    protected String lastName;

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public Person() {

    }
}

      

+3


source to share





All Articles