Own maven plugin with nested complex objects and default values

Home / Uncategorized / Own maven plugin with nested complex objects and default values

Question:
while developing some of my maven-plugins, I came upon the idea to have a more structured way to provide configurations, but I’m not sure there is a way which works.

Is it possible to have a MOJO, that has instances from BaseSettings and MavenSettings used in this way, or am I forced to "polute" these fields directly into my MOJOs?
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;

public abstract class SomeSpecialAbstractMojo extends AbstractMojo{

@Parameter
protected BaseSettings baseSettings = new BaseSettings();

@Parameter
protected MavenSettings mavenSettings = new MavenSettings();
}


import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;

public class MavenSettings {

@Parameter(name = "project", property = "project", readonly = true, required = true)
protected MavenProject project;

@Component
protected MavenProjectHelper projectHelper;
}


import org.apache.maven.plugins.annotations.Parameter;

public class BaseSettings {

@Parameter(name = "skip", defaultValue = "false")
protected boolean skip = false;

@Parameter(name="verbose", defaultValue = "true")
protected boolean verbose = true;
}

The idea was to have some generic properties bundled into their own "space", which makes my MOJOs smaller, and my code more structured.

EDIT: I want to have this kind of execution-configuration:

true



value1




goal1-call

mojo1



override-value1




goal2-call

mojo2




value3




goal3-call

mojo3



override-value012




goal4-call

mojo4



Answer:

Read more

Leave a Reply

Your email address will not be published. Required fields are marked *