m2eclipse支持这个。首先,路径添加到您的构建路径:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/java/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
其次,对于支持添加到M2E:
<pluginManagement>
<plugins>
<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>parse-version</goal>
<goal>add-source</goal>
<goal>maven-version</goal>
<goal>add-resource</goal>
<goal>add-test-resource</goal>
<goal>add-test-source</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnConfiguration>true</runOnConfiguration>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
第二步可能没有必要,如果您的Eclipse已经安装了“组织.eclipse.m2e.discovery.lifecyclemapping.buildhelper.xml“插件。这个插件可以通过窗口 - >首选项 - > Maven - >发现。目前,在Eclipse Kepler中这不起作用,因此,我提取了JAR(从Catalog URL中显示的xml链接),并手工从org.eclipse.m2e.discovery.lifecyclemapping.buildhelper.xml
中提取了片段。
我发布了这个问题和一个(可能的)答案,因为我正在尝试一些事情,部分是为了分享我学习的东西d,部分原因是,尽管我最终完成了这项工作,但我仍然不明白为什么。 – 2009-07-28 08:28:34
问题http://stackoverflow.com/q/7160006/873282似乎是相关的。答案http://stackoverflow.com/a/7160614/873282建议最终与APT M2E连接器一起使用build-helper插件。目前,它与M2E和Eclipse开普勒不兼容。 – koppor 2013-11-26 18:17:52