未findm2e生命周期映射

我试图使用这里描述的解决scheme来解决烦人的“生命周期configuration不包括的插件执行:org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source(execution:default,phase:generate-来源)“当我把我的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干净安装我得到这个:

原因:在存储库中未findPOM'org.eclipse.m2e:lifecycle-mapping':无法从任何存储库下载工件

有没有人有关于如何使m2e和maven快乐的线索?

org.eclipse.m2e:lifecycle-mapping插件实际上不存在。 它应该从你的pom.xml<build><pluginManagement>部分使用。 这样,它不是由Maven解决,但可以通过m2e读取。

但是更实际的解决scheme就是在eclipse中安装m2e build-helper连接器。 您可以从“ Window > Preferences >“ Maven >“ Discovery >“ Open Catalog 。 这样build-helper-maven-plugin:add-sources会在eclipse中被调用,而不需要你改变你的pom.xml

尝试使用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。

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

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

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

下面是我如何做到这一点:我将m2e的生命周期映射插件放在单独的configuration文件中,而不是默认的<build>部分。 该configuration文件在eclipse构build期间通过存在m2e属性(而不是在settings.xml或其他方式中手动激活)自动激活。 这将处理m2e的情况,而命令行maven只是简单地跳过profile和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> 

我在m2e打开了一个(微不足道的)错误。 投票给它,如果你想警告信息消失了… … –

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

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

发现没有市场条目处理build-helper-maven-plugin:1.8:Eclipse中的add-source。 请参阅帮助了解更多信息。

并单击窗口>首选项> Maven>发现>打开目录button将报告没有连接。

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

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

有关Maven的更多详细信息,请尝试在(Settings / Maven / Debug Outputcheckbox)上打开M2Edebugging输出,它可能会提供更多详细信息,说明为什么无法从存储库下载。

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> 

这是由于缺less插件configuration(按照vaadin的demo pom.xml注释):

该插件的configuration仅用于存储Eclipse m2e设置。 它对Maven构build本身没有影响。

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