Own maven plugin with nested complex objects and default values -
while developing of maven-plugins, came upon idea have more structured way provide configurations, i'm not sure there way works.
is possible have mojo, has instances basesettings
, mavensettings
used in way, or forced "polute" these fields directly 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 have generic properties bundled own "space", makes mojos smaller, , code more structured.
edit: want have kind of execution-configuration:
<configuration> <basesettings> <verbose>true</verbose> </basesettings> <!-- mavensettings omitted, want "auto-use-default" here --> <othercomplexsettings> <complexvalue1>value1</complexvalue1> </othercomplexsettings> </configuration> <executions> <execution> <id>goal1-call</id> <goals> <goal>mojo1</goal> </goals> <configuration> <othercomplexsettings> <complexvalue1>override-value1</complexvalue1> </othercomplexsettings> </configuration> </execution> <execution> <id>goal2-call</id> <goals> <goal>mojo2</goal> </goals> <configuration> <!-- part of mojo2 --> <anothercomplexsettings> <complexvalue3>value3</complexvalue3> </anothercomplexsettings> </configuration> </execution> <execution> <id>goal3-call</id> <goals> <goal>mojo3</goal> </goals> <configuration> <othercomplexsettings> <complexvalue1>override-value012</complexvalue1> </othercomplexsettings> </configuration> </execution> <execution> <id>goal4-call</id> <goals> <goal>mojo4</goal> </goals> </execution> </executions>
Comments
Post a Comment