【发布时间】:2016-11-29 23:33:41
【问题描述】:
我正在开发一个带有多个 Mojo 的 maven 插件。在其中之一中,我的目标是在我的项目中附加额外的工件。类似于attach-artifact of maven-build-helper-plugin。但我不想使用任何给定的构建插件,我想通过我的 Mojo 来完成。
我知道我必须使用MavenProjectHelper.attachArtifact。因为 MavenProject.attachArtifact 已被弃用。
我现在拥有的是这个(在 mojo.java 中):
@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject project;
@Parameter(defaultValue = "${helper}", required = true, readonly = true)
protected MavenProjectHelper projectHelper;
在execute方法中:
projectHelper.attachArtifact(project, "plugin", file);
但问题是,MavenProjectHelper 的默认值不是${helper}。这就是为什么,我收到以下错误:
Failed to execute goal com.company.product.repo:my-plugin:1.0.1:attach-artifact (default) on project consumer-plugin: The parameters 'projectHelper' for goal com.company.product.repo:my-plugin:1.0.1:attach-artifact are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
如何给它正确的值?就像MavenSession 的${session} 一样,我假设MavenProjectHelper 有一个默认值。如果是这样,它是什么?如果不是,那我怎样才能给MavenProjectHelper参数正确的值?
【问题讨论】:
标签: java maven maven-plugin mojo