简体   繁体   English

build-helper-maven-plugin 添加额外的源

[英]build-helper-maven-plugin adding additional source

I am trying to add an additional source folder to my current maven project by using build-helper-maven plugin .我正在尝试使用build-helper-maven plugin向我当前的 maven 项目添加一个额外的源文件夹。

This source folder contains some common classes, like utility classes.此源文件夹包含一些常用类,如实用程序类。

For that, here is my relevant pom.xml为此,这是我的相关 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 is showing the following error : Eclipse 显示以下错误:

Build path entry is missing.缺少构建路径条目。 Project->Right Click->Java build path->Source->项目->右键单击->Java构建路径->源代码->

Project/Users/CommonIncludes/src(missing)项目/用户/CommonIncludes/src(缺失)

Here the additional source location : "C:/Users/CommonIncludes/src" is outside of the workspace of the current project.这里的附加源位置:“C:/Users/CommonIncludes/src”位于当前项目的工作区之外。 But eclipse always treating this as a location from current project.但是 Eclipse 总是将其视为当前项目中的一个位置。

I am using Eclipse 4.3 and m2e.我正在使用 Eclipse 4.3 和 m2e。 How can I overcome this error through MAVEN, so that Eclipse can identify the linked source from correct location.?如何通过 MAVEN 克服此错误,以便 Eclipse 可以从正确的位置识别链接的源。? Or is there any alternate way to do this using MAVEN?或者有没有其他方法可以使用 MAVEN 来做到这一点?

Any help will be greatly appreciated.任何帮助将不胜感激。 Thanks in advance.提前致谢。

Found it in an alternate way..works great.!以另一种方式找到它……效果很好。!

Steps include步骤包括

1. Removed build-helper-maven-plugin from pom . 1. 从 pom 中删除了build-helper-maven-plugin

2. Created another maven project and added the common classes in it. 2.创建另一个maven项目并在其中添加常用类。 Added maven-source-plugin in this pom to generate sources.在此 pom 中添加了maven-source-plugin以生成源。

3. To the same pom, added maven-dependency-plugin to copy this generated sources to the desired location (My project's src/main/java). 3.在同一个pom中,添加maven-dependency-plugin将这个生成的源复制到想要的位置(我的项目的src/main/java)。

4. Run a maven build for common classes project. 4. 为通用类项目运行 Maven 构建。

Now the common code in my project.现在是我项目中的通用代码。 Thanks.谢谢。

I had a lot of inconsistent trouble with this plugin.我在这个插件上遇到了很多不一致的问题。 by far the simplest workaround in my case was simply to apply the addition via the standard 'resources' options.到目前为止,在我的情况下,最简单的解决方法就是通过标准的“资源”选项应用添加。 hope this helps someone.希望这有助于某人。

    <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.

相关问题 使用 build-helper-maven-plugin 添加生成的 Apache Avro 源 - Add generated Apache Avro source with build-helper-maven-plugin build-helper-maven-plugin导致AnnotationTypeMismatchException - build-helper-maven-plugin causing AnnotationTypeMismatchException 停止m2e以创建在build-helper-maven-plugin中指定的不存在的源文件夹 - Stopping m2e to create non-existing source folders specified in build-helper-maven-plugin build-helper-maven-plugin add-test-resource错误 - build-helper-maven-plugin add-test-resource error 使用 build-helper-maven-plugin 从 Jar 中排除文件 - Excluding Files From Jar With build-helper-maven-plugin 错误:生命周期配置未涵盖插件执行:org.codhaus.mojo:build-helper-maven-plugin:1.3:add-source - Error: plugin execution not covered by life cycle configuration:org.codhaus.mojo:build-helper-maven-plugin:1.3:add-source Maven build-helper-maven-plugin 正则表达式无法使用属性作为dependency.version - Maven build-helper-maven-plugin regex unable to use property as dependency.version maven不会识别来自build-helper-maven-plugin的execution'a标签 - maven doesnt recognize execution'a tag from build-helper-maven-plugin Maven | 如何在Gradle中使用build-helper-maven-plugin? - Maven | How can I use build-helper-maven-plugin in Gradle? build-helper-maven-plugin目标:正则表达式属性如何访问生成的属性 - build-helper-maven-plugin goal:regex-property how to access generated property
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM