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 ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With