简体   繁体   English

Maven构建帮助器插件不包括多模块项目中的源

[英]Maven build-helper plugin not including sources in multi module project

I am generating webservice artifacts with cxf-xjc and attempting to add them to source with the build-helper plugin. 我正在使用cxf-xjc生成Web服务工件,并尝试使用build-helper插件将其添加到源中。 This was working properly when it was used in a single Maven project, but now that I've moved into a multi-module project, the generated classes are not being included as source. 当在单个Maven项目中使用它时,它可以正常工作,但是由于我已经进入了一个多模块项目,因此所生成的类不再包含在源代码中。

The classes are generated properly and the build-helper plugin is executing after the classes are generated. 生成类后,将正确生成类,并且正在执行build-helper插件。 The output for build-helper shows the correct source directory path where the classes are located and shows 'added'. build-helper的输出显示了类所在的正确源目录路径,并显示“ added”。

pom.xml pom.xml

<!-- CXF -->
<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-xjc-plugin</artifactId>
    <version>2.3.0</version>
    <executions>
        <execution>
            <id>generate-xsd-sources</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>xsdtojava</goal>
            </goals>
            <configuration>
                <sourceRoot>${basedir}/target/generated-sources/java</sourceRoot>
                <xsdOptions>
                    <xsdOption>
                        <!-- <bindingFile>src/main/resources/request.xjb</bindingFile> -->
                        <xsd>src/main/resources/request.xsd</xsd>
                        <packagename>${services.package}.package.request</packagename>
                    </xsdOption>
                    <xsdOption>
                        <!-- <bindingFile>src/main/resources/response.xjb</bindingFile> -->
                        <xsd>src/main/resources/response.xsd</xsd>
                        <packagename>${services.package}.package.response</packagename>
                    </xsdOption>
                </xsdOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

<!-- Move generated to source -->
<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>${project.build.directory}/generated-sources/java</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Console snip 控制台剪

[INFO] --- **cxf-xjc-plugin:2.3.0:xsdtojava (generate-xsd-sources) @ aggregation-jaxrs-api** ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ aggregation-jaxrs-api ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ aggregation-jaxrs-api ---
[INFO] Compiling 55 source files to C:\workspace\aggregation-parent\aggregation-jaxrs-api\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ aggregation-jaxrs-api ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) @ aggregation-jaxrs-api ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ aggregation-jaxrs-api ---
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ aggregation-jaxrs-api ---
[INFO] Building jar: C:\workspace\aggregation-parent\aggregation-jaxrs-api\target\aggregation-jaxrs-api-1.0-SNAPSHOT.jar
[INFO] 
**[INFO] --- build-helper-maven-plugin:1.12:add-source (add-source) @ aggregation-jaxrs-api ---
[INFO] Source directory: C:\workspace\aggregation-parent\aggregation-jaxrs-api\target\generated-sources\java added.**

This configuration worked fine prior to me moving it to a module. 在将其移至模块之前,此配置工作良好。 I've changed to build-helper phase between generate-sources and process-sources phase with no luck. 我已经转为在generate-sources和process-sources阶段之间建立帮助阶段,但是没有运气。 I am using Spring Tool Suite 3.8 which is based on Eclipse Neon 4.6.1. 我正在使用基于Eclipse Neon 4.6.1的Spring Tool Suite 3.8。

Thanks 谢谢

I solved the issue by moving the project folders into my Eclipse workspace. 我通过将项目文件夹移到Eclipse工作区中解决了该问题。 They were situated outside the workspace and for some reason moving the project into the workspace and reimporting it has fixed things. 它们位于工作空间外部,由于某种原因,将项目移至工作空间并重新导入具有固定的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM