Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Maven Plugin parameter value as default value of another parameter

Do someone know if it's possible to set a maven plugin parameter default value to the value of another parameter of the same Mojo ?

@Parameter(required = true, defaultValue = "1")
private int param1;

// works fine
@Parameter(defaultValue = "${project.basedir}")
private File param2;

// here I want param3 to be default to param1 if not set
// @Parameter(defaultValue = "${param1}") doesn't work
// @Parameter(defaultValue = "${project.param1}") doesn't work
// @Parameter(defaultValue = "1") not what I want
@Parameter
private int param3;

I want param3 to be equals to param1 if the value of param3 is not provided by the plugin's configuration... Is this possible ?

like image 424
avianey Avatar asked Nov 02 '22 03:11

avianey


1 Answers

I don't think that this is possible with the current annotations. I suggest to write a getter for param3 which contains the necessary magic and then always use the getter in your code.

like image 60
Aaron Digulla Avatar answered Nov 10 '22 07:11

Aaron Digulla