it-swarm.cn

m2e生命周期映射未找到

我正在尝试使用解决方案 这里描述 来解决烦人的“生命周期配置未涵盖的插件执行:org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source(执行:默认,阶段:generate-sources)“当我将以下插件放在我的pom.xml上时:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
    <execution>
        <phase>generate-sources</phase>
        <goals><goal>add-source</goal></goals>
        <configuration>
            <sources>
                <source>src/bootstrap/Java</source>
            </sources>
        </configuration>
    </execution>
</executions>
</plugin>

但是当我运行mvn clean install时,我得到了这个:

原因:在存储库中找不到POM'org.Eclipse.m2e:lifecycle-mapping':无法从任何存储库下载工件

有没有人知道如何让m2e和maven开心?

56
TraderJoeChicago

实际上不存在org.Eclipse.m2e:lifecycle-mapping插件。它应该在<build><pluginManagement>pom.xml部分使用。这样,它不会被Maven解决,但可以被m2e读取。

但是对于您的问题更实际的解决方案是在Eclipse中安装m2e build-helper连接器。您可以从Window> Preferences> Maven> Discovery> Open Catalog安装它。这样build-helper-maven-plugin:add-sources将在Eclipse中调用,而无需更改pom.xml

108
Fred Bricon

尝试使用build/pluginManagement部分,例如:

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

这是在Eclipse中进行增量编译期间生成包清单的示例:

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.Eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.Apache.felix</groupId>
                                    <artifactId>maven-bundle-plugin</artifactId>
                                    <versionRange>[1.0.0,)</versionRange>
                                    <goals>
                                        <goal>manifest</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.Apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.7</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                </instructions>
            </configuration>
            <executions>
                <execution>
                    <id>manifest</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>manifest</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

versionRange是必需的,如果省略m2e(从1.1.0开始)将抛出NullPointerException。

10
Hendy Irawan

你可以使用这个虚拟插件:

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

生成项目后安装/部署它。

8
Manfred Hantschel

我是这样做的:我将m2e的生命周期映射插件放在一个单独的配置文件中,而不是默认的<build>部分。在Eclipse构建期间,通过m2e属性(而不是settings.xml中的手动激活或其他方式)自动激活配置文件。这将处理m2e案例,而命令行maven将简单地跳过配置文件和m2e生命周期映射插件而没有任何警告,并且每个人都很高兴。

<project>
  ...
  <profiles>
    ...
    <profile>
      <id>m2e</id>
      <!-- This profile is only active when the property "m2e.version"
        is set, which is the case when building in Eclipse with m2e. -->
      <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>
                <lifecycleMappingMetadata>
                  <pluginExecutions>
                    <pluginExecution>
                      <pluginExecutionFilter>
                        <groupId>...</groupId>
                        <artifactId>...</artifactId>
                        <versionRange>[0,)</versionRange>
                        <goals>
                          <goal>...</goal>
                        </goals>
                      </pluginExecutionFilter>
                      <action>

                        <!-- either <ignore> XOR <execute>,
                          you must remove the other one. -->

                        <!-- execute: tells m2e to run the execution just like command-line maven.
                          from m2e's point of view, this is not recommended, because it is not
                          deterministic and may make your Eclipse unresponsive or behave strangely. -->
                        <execute>
                          <!-- runOnIncremental: tells m2e to run the plugin-execution
                            on each auto-build (true) or only on full-build (false). -->
                          <runOnIncremental>false</runOnIncremental>
                        </execute>

                        <!-- ignore: tells m2Eclipse to skip the execution. -->
                        <ignore />

                      </action>
                    </pluginExecution>
                  </pluginExecutions>
                </lifecycleMappingMetadata>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    ...
  </profiles>
  ...
</project>
4
Robin479

我在m2e打开了一个(琐碎的)bug。如果您希望警告信息消失,请投票给它...

https://bugs.Eclipse.org/bugs/show_bug.cgi?id=367870

3
Ben

我遇到了同样的问题,其中:

没有找到处理build-helper-maven-plugin的市场条目:1.8:Eclipse中的add-source。有关更多信息,请参阅帮助。

然后单击窗口>首选项> Maven>发现>打开目录按钮将报告无连接。

在Centos 6.4和OSX上从7u40更新到7u45可以解决这个问题。

3
user145880

Maven正在尝试下载m2e的生命周期映射工件,M2E使用它来确定如何在Eclipse中处理插件(添加源文件夹等)。由于某种原因,无法下载此工件。你有互联网连接吗?是否可以从存储库下载其他工件?代理设置?

有关Maven的更多详细信息,请尝试打开M2E调试输出(Settings/Maven/Debug Output复选框),它可能会为您提供有关无法从存储库下载的详细信息。

1
prunge

m2e 1.7为生命周期映射元数据引入了一个 新语法 不再导致此警告:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
    <execution>

        <!-- This executes the goal in Eclipse on project import.
             Other options like are available, eg ignore.  -->
        <?m2e execute?>

        <phase>generate-sources</phase>
        <goals><goal>add-source</goal></goals>
        <configuration>
            <sources>
                <source>src/bootstrap/Java</source>
            </sources>
        </configuration>
    </execution>
</executions>
</plugin>
1
Arend v. Reinersdorff

它是由于缺少插件配置而发生的(根据 vaadin的demo pom.xml comment):

此插件的配置仅用于存储Eclipse m2e设置。它对Maven构建本身没有影响。

<pluginManagement>
    <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e ettings only. It has no influence on the Maven build itself.-->
        <plugin>
            <groupId>org.Eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>com.vaadin</groupId>
                                <artifactId>
                                    vaadin-maven-plugin
                                </artifactId>
                                <versionRange>
                                    [7.1.5,)
                                </versionRange>
                                <goals>
                                    <goal>resources</goal>
                                    <goal>update-widgetset</goal>
                                    <goal>compile</goal>
                                    <goal>update-theme</goal>
                                    <goal>compile-theme</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <ignore></ignore>
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
    </plugins>
</pluginManagement>
0
falsarella