67

为了让 m2e 1.0 正常工作,我必须指定生命周期映射:

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.bsc.maven</groupId>
                                    <artifactId>maven-processor-plugin</artifactId>
                                    <versionRange>[2.0.2,)</versionRange>
                                    <goals>
                                        <goal>process</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>                         
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

但后来我收到了这个警告:

 [WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available
 [WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0

例如,如果我运行一些特定的 Maven 任务mvn clean install findbugs:findbugs(如果我只运行mvn clean install,则没有这样的消息)

我知道问题是这个 POM 不存在,因为它只定义为保存映射信息。(未找到 m2e 生命周期映射

无论如何,我想保持我的构建干净,没有任何警告,那么我怎样才能摆脱这个特定的呢?(我的 CI 服务器检查没有警告。

我使用 Maven 3.0.2 并尝试了 Maven 3.0.3,但结果相同。

4

5 回答 5

72

我的团队通过将相关配置包装在配置文件中来解决此问题:

<profile>
  <id>only-eclipse</id>
  <activation>
    <property>
      <name>m2e.version</name>
    </property>
  </activation>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            ...
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</profile>
于 2014-05-17T02:38:38.707 回答
20

这是WONTFIX分辨率已知错误。我认为建议的解决方案是最简单的:

mvn archetype:generate -DgroupId=org.eclipse.m2e -DartifactId=lifecycle-mapping \
 -Dversion=1.0.0 -DarchetypeArtifactId=maven-archetype-mojo

install这个项目。

于 2013-09-02T08:38:50.473 回答
16

m2eclipse 1.7.0 引入了另一种选择,即 XML 处理指令。

<execution>在最初的例子中,你可以简单maven-processor-pluginprocess

<?m2e execute?>

有关语法和更多选项的更多详细信息,请参阅发行说明

于 2017-10-27T10:20:59.033 回答
8

现在不推荐使用此解决方案,我建议使用@ctrueden 的“配置文件”解决方案,这是公认的答案!

虽然不是最干净的解决方案,但当您在公司或自己使用存储库管理器时,同时您可以这样做:-结帐https://github.com/mfriedenhagen/dummy-lifecycle-mapping-plugin . -mvn install独自运行 -mvn deploy -DaltDeploymentRepository=REPO_ID::default::YOUR_THIRDPARTY_REPO_URL当您拥有 Nexus 或 Artifactory 等存储库管理器时运行。- 参见https://github.com/mfriedenhagen/dummy-lifecycle-mapping-plugin/blob/master/README.creole

问候米尔科

于 2012-01-05T11:03:07.063 回答
0

现在有了更好的解决方案(仅适用于 Eclipse 中的错误消息)。

按下生命周期配置未涵盖CTR+1的错误插件执行:org.codehaus.mojo:buildnumber-maven-plugin:1.1:create-timestamp (execution: default-create-timestamp, phase: validate)然后选择此选项:

在此处输入图像描述

这适用于org.eclipse.m2e.editor.xml_1.2.0.20120903-1050.jar插件(也许更早)

于 2012-11-09T10:17:50.847 回答