简体   繁体   English

使用Maven Plugin参数值作为另一个参数的默认值

[英]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 ? 有人知道是否可以将maven插件参数默认值设置为同一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 ? 如果插件的配置不提供param3的值,我希望param3等于param1 ......这可能吗?

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. 我建议为param3编写一个getter,它包含必要的魔法,然后总是在你的代码中使用getter。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM