如何映射Eclipse m2e插件未涵盖的Maven生命周期阶段? [英] How can I map Maven lifecycle phases not covered by the Eclipse m2e plugin?

查看:169
本文介绍了如何映射Eclipse m2e插件未涵盖的Maven生命周期阶段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac 10.9.5中使用Eclipse Kepler。我已经使用m2e Eclipse插件导入了一些Maven项目。所有这些项目都是父母的孩子。当我看到单个小孩pom.xml文件中的概述时,我看到如下所示的东西:

 插件执行不覆盖生命周期配置:org.codehaus.mojo:properties-maven-plugin:1.0-alpha-2:write-project-properties(执行:默认,阶段:进程资源)

我希望Eclipse在适当的时候执行这些生命周期阶段,但我不知道该怎么做。当我选择Eclipse的建议...

 将pom.xml中的目标写入项目属性永久标记为忽略

当提示选择位置忽略时,我选择了父pom.xml文件,但是,错误不会消失我在Eclipse编辑器中查看小孩pom.xml文件。如何映射m2e不涵盖的生命周期阶段?



编辑:



根据答案,我去了Eclipse - >首选项 - > Maven - >生命周期映射,点击打开工作空间生命周期映射元数据,并按照建议编辑文件。

 <?xml version =1.0encoding =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>

即使重新启动Eclipse,当我打开一个小孩pom.xml文件时,插件执行未覆盖通过生命周期配置错误仍然如前所述。

解决方案

M2Eclipse(Eclipse的Maven集成插件)是映射和执行默认阶段 s和目标的Maven进入内部Eclipse构建工作流程。



请参阅: https://www.eclipse.org/ m2e / documentation / m2e-execution-not-covered.html


[...]需要明确的说明做什么所有Maven插件都绑定到项目构建生命周期的有趣阶段[...]。我们将这些指令称为项目构建生命周期映射或简称为生命周期映射,因为它们定义了在Eclipse工作空间构建过程中,m2e如何将项目pom.xml文件中的信息映射到Eclipse工作区项目配置和行为。


可以在每个项目或全局Eclipse安装中解决此错误。


项目构建生命周期映射可以在项目的pom.xml中配置,由Eclipse插件提供,或默认为m2e附带的常用Maven插件。我们称这些生命周期映射元数据源。


全局Eclipse设置文件称为 lifecycle-mapping- metadata.xml ,并可以通过Maven设置对话框[1]上的生命周期映射进行配置。


M2Eclipse使用插件groupId,artifactId,版本范围和目标的组合将插件执行与动作匹配。有两个基本的操作可以指示M2Eclipse执行插件 - 忽略执行并委托给项目配置程序。



[...]



顾名思义,忽略选项告诉M2Eclipse默认忽略插件执行



[...]



执行选项告诉m2e执行作为Eclipse工作区完整或增量构建的一部分的操作。


委托给项目配置器意味着有Eclipse市场中适配器Eclipse插件。适配器插件以更具Maven插件的特定方式执行阶段目标



真正的设置(XML结构)不是真实的直观,而是在上面的链接中描述。



在你的情况下, code> lifecycle-mapping-metadata.xml 将如下所示:

  ?xml version =1.0encoding =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:您是否有更多的项目,一直使用一组Maven插件, code> lifecycle-mapping-metadata.xml 在SCM(git,svn,cvs ...)。



编辑



添加插件的所有目标,也可以添加其他插件,以避免出现这些错误。仔细阅读错误消息,以获取额外的目标或插件。



保存的 lifecycle-mapping-metadata.xml 您必须重新加载Maven设置对话框[1]中的内容,并更新工作区中所有基于Maven的项目。



单击工作区中Maven项目上的鼠标右键,然后选择Maven>更新项目... 。选择/ all Maven项目并激活以下复选框:




  • 从pom.xml更新项目配置

  • 从本地文件系统刷新工作区资源

  • 清理项目



strong>



[1] Maven设置对话框位于文件>窗口>首选项> Maven>生命周期映射,直到Exclipse Oxygen。 p>

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:

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 …

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?

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 ...

<?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.

解决方案

M2Eclipse (the Maven integration plugin for Eclipse) is mapping and execution the default phases and goals of Maven into the internal Eclipse build workflow.

See: 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.

It is possible to solve this errors in every project or in your global Eclipse installation.

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".

The global Eclipse setting file is called lifecycle-mapping-metadata.xml and configurable via the 'Lifecycle Mappings' at the Maven Settings dialog[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, execute and delegate to a project configurator.

[...]

The ignore option, as the name suggests, tells M2Eclipse to silently ignore the plugin execution.

[...]

The execute option tells m2e to execute the action as part of Eclipse workspace full or incremental build.

delegate to a project configurator means there are adapter Eclipse plugins in the Eclipse Marketplace. A adapter plugin executes the phases and goals in a more Maven plugin specific way.

The real settings (the XML structure) isn't real intuitive but a bit described in the link above.

In your case the lifecycle-mapping-metadata.xml will be looks like:

<?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 ...).

EDIT

Add all goals of a plugin and maybe additional plugins to avoid these errors. Read the error message carefully for additional goals or plugins.

After any saved change of lifecycle-mapping-metadata.xml you have to reload the content in the Maven Settings dialog[1] and update all Maven based projects in the workspace.

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:

  • Update project configuration from pom.xml
  • Refresh workspace resources from local filesystem
  • Clean projects

EDIT

[1] The Maven Settings dialog was located at File > Window > Preferences > Maven > Lifecycle Mappings until Exclipse Oxygen.

这篇关于如何映射Eclipse m2e插件未涵盖的Maven生命周期阶段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆