Tra*_*ago 58 maven-2 m2eclipse maven-plugin maven m2e
我正在尝试使用此处描述的解决方案来解决恼人的"生命周期配置未涵盖的插件执行:org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source(执行:默认,阶段:生成 -来源)"当我将以下插件放在我的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>
Run Code Online (Sandbox Code Playgroud)
但是当我运行mvn clean install时,我得到了这个:
原因:在存储库中找不到POM'org.eclipse.m2e:lifecycle-mapping':无法从任何存储库下载工件
有没有人知道如何让m2e和maven开心?
Fre*_*con 111
该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.
Hen*_*wan 11
尝试使用该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>
Run Code Online (Sandbox Code Playgroud)
这是在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>
Run Code Online (Sandbox Code Playgroud)
versionRange是必需的,如果省略m2e(从1.1.0开始)将抛出NullPointerException.
小智 9
你可以使用这个虚拟插件:
mvn archetype:generate -DgroupId=org.eclipse.m2e -DartifactId=lifecycle-mapping -Dversion=1.0.0 -DarchetypeArtifactId=maven-archetype-mojo
Run Code Online (Sandbox Code Playgroud)
生成项目后安装/部署它.
我是这样做的:我将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>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
95479 次 |
| 最近记录: |