【问题标题】:Maven build-helper plugin not including sources in multi module projectMaven build-helper 插件不包括多模块项目中的源
【发布时间】:2017-01-26 15:14:05
【问题描述】:

我正在使用 cxf-xjc 生成 Web 服务工件,并尝试使用 build-helper 插件将它们添加到源代码中。这在单个 Maven 项目中使用时可以正常工作,但是现在我已经进入了一个多模块项目,生成的类没有作为源包含在内。

类生成正确,生成类后 build-helper 插件正在执行。 build-helper 的输出显示了类所在的正确源目录路径并显示“已添加”。

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>

控制台截图

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

此配置在我将其移至模块之前运行良好。我已更改为生成源和流程源阶段之间的构建助手阶段,但没有运气。我正在使用基于 Eclipse Neon 4.6.1 的 Spring Tool Suite 3.8。

谢谢

【问题讨论】:

    标签: eclipse maven maven-plugin cxf-xjc-plugin


    【解决方案1】:

    我通过将项目文件夹移动到我的 Eclipse 工作区中解决了这个问题。它们位于工作区之外,出于某种原因将项目移动到工作区并重新导入它有固定的东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      • 2021-05-28
      • 1970-01-01
      • 2021-08-08
      • 1970-01-01
      • 2012-11-21
      • 2019-01-30
      相关资源
      最近更新 更多