无法从自定义maven MOJO获取系统参数
我尝试在自定义 Maven MOJO 中获取系统属性的值,如下所述: https://maven.apache.org/developers/mojo-api-specification.html。 我尝试从以下命令行获取值的属性是“releaseVersion”:
mvn -DdevelopmentVersion=0.0.0.7-SNAPSHOT -DreleaseVersion=0.0.0.6 -Dresume=false release:clean release:prepare release:perform
在我的自定义 MOJO 中,我尝试使用以下代码将系统属性注入属性中:
@Mojo(name = "release-change", defaultPhase = LifecyclePhase.COMPILE)
public class ReleaseChangesMojo extends AbstractMojo
{
@Parameter(property = "releaseVersion", defaultValue = "${releaseVersion}", required = true)
private String releaseVersion;
我的 pom.xml 包含此代码来启动我的 MOJO :
<plugin>
<groupId>fr.my.plugin</groupId>
<artifactId>my-release-maven-plugin</artifactId>
<version>0.0.5</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
...
<configuration combine.self="override">
<preparationGoals>clean verify</preparationGoals>
<goals>deploy</goals>
<completionGoals>my-release:release-change</completionGoals>
...
</configuration>
</plugin>
</plugins>
</pluginManagement>
但在执行时,我收到以下错误:
[ERROR] 无法在项目示例上执行目标插件:my-release-maven-plugin:0.0.5:release-change(default-cli):参数'目标 fr.my.plugin:my-release-maven-plugin:0.0.5:release-change 的releaseVersion'缺失或无效 -> [帮助 1]
您知道为什么系统属性没有注入到我的 MOJO 中吗?
I try to get the value of a system property in a custom maven MOJO, like described here : https://maven.apache.org/developers/mojo-api-specification.html.
The property which I try to get the value is "releaseVersion" from the following command line :
mvn -DdevelopmentVersion=0.0.0.7-SNAPSHOT -DreleaseVersion=0.0.0.6 -Dresume=false release:clean release:prepare release:perform
In my custom MOJO, I try to inject the system property in an attribute with the following code :
@Mojo(name = "release-change", defaultPhase = LifecyclePhase.COMPILE)
public class ReleaseChangesMojo extends AbstractMojo
{
@Parameter(property = "releaseVersion", defaultValue = "${releaseVersion}", required = true)
private String releaseVersion;
My pom.xml contains this to launch my MOJO :
<plugin>
<groupId>fr.my.plugin</groupId>
<artifactId>my-release-maven-plugin</artifactId>
<version>0.0.5</version>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
...
<configuration combine.self="override">
<preparationGoals>clean verify</preparationGoals>
<goals>deploy</goals>
<completionGoals>my-release:release-change</completionGoals>
...
</configuration>
</plugin>
</plugins>
</pluginManagement>
But on execution, I get the following error :
[ERROR] Failed to execute goal plugin:my-release-maven-plugin:0.0.5:release-change (default-cli) on project exemple: The parameters 'releaseVersion' for goal fr.my.plugin:my-release-maven-plugin:0.0.5:release-change are missing or invalid -> [Help 1]
Do you have any idea why the system property is not injected in my MOJO ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论