[英]Add generated Apache Avro source with build-helper-maven-plugin
[英]build-helper-maven-plugin adding additional source
.我正在尝试使用向我当前的 maven 项目添加一个额外的源文件夹。
此源文件夹包含一些常用类,如实用程序类。
为此,这是我的相关 pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>C:/Users/CommonIncludes/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Eclipse 显示以下错误:
缺少构建路径条目。 项目->右键单击->Java构建路径->源代码->
项目/用户/CommonIncludes/src(缺失)
这里的附加源位置:“C:/Users/CommonIncludes/src”位于当前项目的工作区之外。 但是 Eclipse 总是将其视为当前项目中的一个位置。
我正在使用 Eclipse 4.3 和 m2e。 如何通过 MAVEN 克服此错误,以便 Eclipse 可以从正确的位置识别链接的源。? 或者有没有其他方法可以使用 MAVEN 来做到这一点?
任何帮助将不胜感激。 提前致谢。
以另一种方式找到它……效果很好。!
步骤包括
1. 从 pom 中删除了build-helper-maven-plugin 。
2.创建另一个maven项目并在其中添加常用类。 在此 pom 中添加了maven-source-plugin以生成源。
3.在同一个pom中,添加maven-dependency-plugin将这个生成的源复制到想要的位置(我的项目的src/main/java)。
4. 为通用类项目运行 Maven 构建。
现在是我项目中的通用代码。 谢谢。
我在这个插件上遇到了很多不一致的问题。 到目前为止,在我的情况下,最简单的解决方法就是通过标准的“资源”选项应用添加。 希望这有助于某人。
<build>
<resources>
...
<resource>
<directory>${project.build.directory}/generated-sources</directory>
<targetPath>${project.build.outputDirectory}</targetPath>
</resource>
</build>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.