I'm attempting to add a source folder for maven java project to Eclipse using a maven plugin.
我正在尝试使用maven插件将maven java项目的源文件夹添加到Eclipse。
When trying to use the org.codehaus.mojo plugin I receive the following error
当尝试使用org.codehaus.mojo插件时,我收到以下错误
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]
无法在项目应用程序框架上执行目标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]
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.
通过阅读http://mojo.codehaus.org/build-helper-maven-plugin/usage.html上的文档,这应该是正确的吗?文件夹target / sources / mygeneratedfiles on存在。
<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>
1 个解决方案
#1
13
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.
问题是构建帮助器插件通常太旧而无法与最新的maven版本一起使用(与m2e eclipse插件结合使用),因为“相对较新的”生命周期映射规则。
I solved this issue by adding a lifecyclemapping configuration for the build-helper-maven-plugin for the orgeclipse.m2e plugib. see below:
我通过为orgeclipse.m2e plugib的build-helper-maven-plugin添加lifecyclemapping配置解决了这个问题。见下文:
<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>
#1
13
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.
问题是构建帮助器插件通常太旧而无法与最新的maven版本一起使用(与m2e eclipse插件结合使用),因为“相对较新的”生命周期映射规则。
I solved this issue by adding a lifecyclemapping configuration for the build-helper-maven-plugin for the orgeclipse.m2e plugib. see below:
我通过为orgeclipse.m2e plugib的build-helper-maven-plugin添加lifecyclemapping配置解决了这个问题。见下文:
<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>