Maven Build Helper Maven插件的用法 [英] Usage of maven Build Helper Maven Plugin
问题描述
我正尝试使用maven插件将maven java项目的源文件夹添加到Eclipse.
I'm attempting to add a source folder for maven java project to Eclipse using a maven plugin.
当尝试使用org.codehaus.mojo插件时,出现以下错误
When trying to use the org.codehaus.mojo plugin I receive the following error
无法在项目应用程序框架上执行目标org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source(default-cli):目标org.codehaus.mojo的参数"sources": build-helper-maven-plugin:1.7:add-source丢失或无效-> [帮助1]
Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source (default-cli) on project application-framework: The parameters 'sources' for goal org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source are missing or invalid -> [Help 1]
通过阅读 http://mojo.codehaus.org/build-helper-上的文档maven-plugin/usage.html 这应该是正确的吗? target/sources/mygenicfiles所在的文件夹存在.
From reading the docs on http://mojo.codehaus.org/build-helper-maven-plugin/usage.html this should be correct ? The folder target/sources/mygeneratedfiles on exists.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/sources/mygeneratedfiles</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
推荐答案
问题是,由于以下原因,构建帮助器插件通常太旧而无法与最新的maven版本(与m2e eclipse插件结合使用)一起使用相对新的"生命周期映射规则.
The problem is that the build helper plugin is in general too old to be used with the newest maven versions (in combination with the m2e eclipse plugin), because of the "relative new" Lifecycle-mapping rules.
我通过为orgeclipse.m2e插件的build-helper-maven-plugin添加生命周期映射配置来解决此问题.见下文:
I solved this issue by adding a lifecyclemapping configuration for the build-helper-maven-plugin for the orgeclipse.m2e plugib. see below:
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>add-source</goal>
<goal>add-test-source</goal>
<goal>add-resource</goal>
<goal>add-test-resource</goal>
<goal>maven-version</goal>
<goal>parse-version</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnConfiguration>true</runOnConfiguration>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
这篇关于Maven Build Helper Maven插件的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!