m2e 仍然给出错误“生命周期配置未涵盖插件执行”即使在自定义插件中有显式绑定
我正在构建一个插件来生成一些代码。
我已按照此处的步骤创建插件: http://maven.apache.org/guides/plugin/ Guide-java-plugin-development.html
插件来源:
/**
* @goal helloworld
* @phase generate-sources
*/
public class SampleMojo extends AbstractMojo
{
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
getLog().info("Hello, world.");
}
}
用法:
<plugins>
<plugin>
<groupId>com.sample</groupId>
<artifactId>sample-maven-plugin</artifactId>
<version>0.0.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>helloworld</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
该插件本身工作正常,但在 Eclipse 中,我不断收到“生命周期未涵盖”错误。
我通读了“如何解决” Spring Data Maven 构建的生命周期配置未涵盖插件执行”,我假设如果我创建自己的插件并设置 @phase 和 @goal 注释,它将消除该错误。我真的不想在 pom.xml 中放入“lifecycleMappingMetadata”节点。
有人对此有什么建议吗?我需要为 m2e 编写一些特殊的内容才能消除该错误吗?
I'm building a plugin to do some code generation.
I've followed the steps here for how to create a plugin:
http://maven.apache.org/guides/plugin/guide-java-plugin-development.html
Plugin Source:
/**
* @goal helloworld
* @phase generate-sources
*/
public class SampleMojo extends AbstractMojo
{
@Override
public void execute() throws MojoExecutionException, MojoFailureException
{
getLog().info("Hello, world.");
}
}
Usage:
<plugins>
<plugin>
<groupId>com.sample</groupId>
<artifactId>sample-maven-plugin</artifactId>
<version>0.0.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>helloworld</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
The plugin works fine on its own, but in Eclipse, I keep getting the "not covered by lifecycle" error.
I read through "How to solve “Plugin execution not covered by lifecycle configuration” for Spring Data Maven Builds" and I assumed that if I created my own plugin and set the @phase and @goal annotations it would get rid of that error. I really don't want to put in the "lifecycleMappingMetadata" node in the pom.
Anyone have any advice on this? Is there something special that I need to write for m2e to get that error to go away?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
K. Claszen 的答案是正确的,但我想填写一些额外的细节。
A、m2e为什么会这样?
此行为的目的是防止 m2e 通过增量(且可能永无止境)更改消耗过多资源。
B. m2e 版本 1.1 还不是“版本”
目前 m2e 1.1 仍然是一个“里程碑”。
用户需要使用此更新站点安装/升级到它:
http://download.eclipse.org/technology/m2e/milestones/1.1
(我还必须卸载“m2e SCM 连接器”才能升级它)
现在,这对于您的用户来说可能比在其 pom.xml 文件中插入“快速修复”代码段更麻烦。但从长远来看,使用它是有好处的。
C. 使您的 Maven 插件与 m2e-1.1 兼容的概述
正如 K. Claszen 所描述的,大部分信息都在这里: M2E 兼容的 Maven 插件。
一些关键点:
D. 替代方案
如果 1.1 对于您的用户来说不是一个现实的选择,您可以:
行更改为
。还有其他 SO 问题/答案涵盖了这一点。K. Claszen's answer is correct, but I'd like to fill out some extra details.
A. Why is m2e like this?
The point of this behaviour is to prevent m2e from consuming too many resources with incremental (& potentially never-ending) changes.
B. m2e version 1.1 is not a 'release' yet
Currently m2e 1.1 is still a 'milestone'.
Users would need to install/upgrade-to it with this update site:
http://download.eclipse.org/technology/m2e/milestones/1.1
(I also had to uninstall an 'm2e SCM connector' in order to upgrade it)
Right now, this is potentially more hassle for your users than inserting the 'Quick Fix' snippet in their pom.xml files. But, in the long-term it's good to use it.
C. Overview of making your maven plugin m2e-1.1-compatible
As described by K. Claszen, most of the info is here: M2E compatible maven plugins.
Some key points:
D. Alternatives
If 1.1 isn't a realistic option for your users, you could:
<ignore />
line to<execute />
. There are other SO questions/answers which cover this.我认为 M2E 兼容 Maven 插件 站点将为您提供所需的信息。请注意,这是从 m2e 版本 1.1 开始才起作用的。
I think the M2E compatible maven plugins site will give you the information you need. Notice that this works first since m2e version 1.1.