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
maven parameters configuration mojo


source to share


No one has answered this question yet

See similar questions:

3
Is it possible to define a mojo that takes a list of objects as a parameter?
1
Java Maven Mojo: Complex Map Attribute

or similar:

1011
How do I add local jar files to a Maven project?
866
How to solve "Executing plugins not covered by lifecycle config" for Spring Data Maven Builds
768
What is Maven Snapshot and why do we need it?
670
How do I tell Maven to use the latest dependency?
665
Force maven update
663
Differences Between Dependencies and Management in Maven
646
Working with "Xerces hell" in Java / Maven?
111
What is MOJO in Maven?
1
failed to pass map type to variables to achieve maven target via command line
0
Exclude lines in Maven map



All Articles
Loading...
X
Show
Funny
Dev
Pics