如何映射 Eclipse m2e 插件未涵盖的 Maven 生命周期阶段?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30063357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I map Maven lifecycle phases not covered by the Eclipse m2e plugin?
提问by Dave
I'm using Eclipse Kepler on Mac 10.9.5. I have imported a number of Maven projects using the m2e Eclipse plugin. All these projects are children of a parent pom. When I look at the “Overview” in the individual child pom.xml files, I see stuff like this:
我在 Mac 10.9.5 上使用 Eclipse Kepler。我已经使用 m2e Eclipse 插件导入了许多 Maven 项目。所有这些项目都是父 pom 的子项。当我查看单个子 pom.xml 文件中的“概述”时,我看到如下内容:
Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties (execution: default, phase: process-resources)
I would like Eclipse to execute these lifecycle phases at the appropriate times, but I'm not sure how to do that. When I select Eclipse's suggestion …
我希望 Eclipse 在适当的时间执行这些生命周期阶段,但我不确定如何做到这一点。当我选择 Eclipse 的建议时……
Permanently mark goal write-project-properties in pom.xml as ignore
I selected the parent pom.xml file when prompted “Select location to place ignore,” however, the error does not go away when I view the child pom.xml file in the Eclipse editor. How can I map lifecycle phases not covered by m2e?
当提示“Select location to place ignore”时,我选择了父 pom.xml 文件,但是,当我在 Eclipse 编辑器中查看子 pom.xml 文件时,错误并没有消失。如何映射 m2e 未涵盖的生命周期阶段?
Edit:
编辑:
Per the answer, I went to Eclipse -> Preferences -> Maven -> Lifecycle Mappings, clicked on "Open Workspace Lifecycle Mappings Metadata", and edited the file as suggested ...
根据答案,我转到 Eclipse -> Preferences -> Maven -> Lifecycle Mappings,单击“Open Workspace Lifecycle Mappings Metadata”,并按照建议编辑文件...
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<versionRange>2.3.3</versionRange>
<goals>
<goal>xmlbeans</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<versionRange>[1.0-alpha-2,)</versionRange>
<goals>
<goal>write-project-properties</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
Even after restarting Eclipse, when I open a child pom.xml file, the "Plugin execution not covered by lifecycle configuration" errors remain as before.
即使在重新启动 Eclipse 之后,当我打开一个子 pom.xml 文件时,“生命周期配置未涵盖插件执行”错误仍然像以前一样。
回答by barthel
M2Eclipse (the Maven integration plugin for Eclipse) is mapping and execution the default phase
s and goals
of Maven into the internal Eclipse build workflow.
m2eclipse的(Eclipse的Maven的集成插件)是映射和执行的默认phase
S和goals
的Maven到内部Eclipse构建工作流程。
See: https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
请参阅:https: //www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
[...] requires explicit instructions what to do with all Maven plugins bound to “interesting” phases [...] of a project build lifecycle. We call these instructions “project build lifecycle mapping” or simply “lifecycle mapping” because they define how m2e maps information from project pom.xml file to Eclipse workspace project configuration and behaviour during Eclipse workspace build.
[...] 需要明确说明如何处理绑定到项目构建生命周期的“有趣”阶段 [...] 的所有 Maven 插件。我们将这些说明称为“项目构建生命周期映射”或简称为“生命周期映射”,因为它们定义了 m2e 如何将信息从项目 pom.xml 文件映射到 Eclipse 工作空间项目配置和 Eclipse 工作空间构建期间的行为。
It is possible to solve this errors in every project or in your global Eclipse installation.
可以在每个项目或全局 Eclipse 安装中解决此错误。
Project build lifecycle mapping can be configured in a project's pom.xml, contributed by Eclipse plugins, or defaulted to the commonly used Maven plugins shipped with m2e. We call these “lifecycle mapping metadata sources”.
项目构建生命周期映射可以在项目的 pom.xml 中配置,由 Eclipse 插件提供,或者默认为 m2e 附带的常用 Maven 插件。我们称这些为“生命周期映射元数据源”。
The global Eclipse setting file is called lifecycle-mapping-metadata.xml
and configurable via the 'Lifecycle Mappings' at the Maven Settings dialog[1].
全局 Eclipse 设置文件lifecycle-mapping-metadata.xml
通过 Maven 设置对话框中的“生命周期映射”进行调用和配置 [1]。
M2Eclipse matches plugin executions to actions using combination of plugin groupId, artifactId, version range and goal. There are three basic actions that M2Eclipse can be instructed to do with a plugin execution – ignore, executeand delegate to a project configurator.
[...]
The ignoreoption, as the name suggests, tells M2Eclipse to silently ignore the plugin execution.
[...]
The executeoption tells m2e to execute the action as part of Eclipse workspace full or incremental build.
M2Eclipse 使用插件 groupId、artifactId、版本范围和目标的组合将插件执行与操作相匹配。可以指示 M2Eclipse 执行插件执行的三个基本操作 -忽略、执行和委托给项目配置器。
[...]
该忽略选项,顾名思义,讲述的m2eclipse悄悄忽略插件运行。
[...]
该执行选项告诉M2E作为Eclipse中的一部分工作区完全或增量生成来执行操作。
delegate to a project configuratormeans there are adapter Eclipse plugins in the Eclipse Marketplace. A adapter plugin executes the phase
s and goals
in a more Maven plugin specific way.
委托给项目配置器意味着 Eclipse Marketplace 中有适配器 Eclipse 插件。适配器插件以更 Maven 插件特定的方式执行phase
s 和goals
。
The real settings (the XML structure) isn't real intuitive but a bit described in the link above.
真正的设置(XML 结构)并不是很直观,但在上面的链接中有一些描述。
In your case the lifecycle-mapping-metadata.xml
will be looks like:
在您的情况下,lifecycle-mapping-metadata.xml
将如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
<pluginExecutions>
[...]
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<versionRange>[1.0-alpha-2,)</versionRange>
<goals>
<goal>write-project-properties</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
[...]
</pluginExecutions>
</lifecycleMappingMetadata>
ProTip: Did you have more projects and use a set of Maven plugins all the time, move the lifecycle-mapping-metadata.xml
in SCM (git, svn, cvs ...).
ProTip:你有没有更多的项目并且一直使用一组Maven插件,移动lifecycle-mapping-metadata.xml
SCM(git,svn,cvs ...)。
EDIT
编辑
Add allgoals of a plugin and maybe additional plugins to avoid these errors. Read the error message carefully for additional goal
s or plugins.
添加插件的所有目标,可能还添加其他插件以避免这些错误。请仔细阅读错误消息以获取其他goal
s 或插件。
After any saved change of lifecycle-mapping-metadata.xml
you have to reloadthe content in the Maven Settings dialog[1] and update all Maven based projects in the workspace.
在任何保存的更改之后,lifecycle-mapping-metadata.xml
您必须重新加载Maven 设置对话框 [1] 中的内容并更新工作区中所有基于 Maven 的项目。
Click the right mouse button on a Maven project in your Workspace and choose Maven > Update Projects .... Select the/all Maven Projects and activate the following checkboxes:
在工作区中的 Maven 项目上单击鼠标右键,然后选择Maven > Update Projects ...。选择/所有 Maven 项目并激活以下复选框:
- Update project configuration from pom.xml
- Refresh workspace resources from local filesystem
- Clean projects
- 从 pom.xml 更新项目配置
- 从本地文件系统刷新工作区资源
- 清洁项目
EDIT
编辑
[1] The Maven Settings dialog was located at File > Window > Preferences > Maven > Lifecycle Mappingsuntil Exclipse Oxygen.
[1] Maven 设置对话框位于File > Window > Preferences > Maven > Lifecycle Mappingsuntil Exclipse Oxygen。