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

841 Views Asked by At

I am generating webservice artifacts with cxf-xjc and attempting to add them to source with the build-helper plugin. 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.

The classes are generated properly and the build-helper plugin is executing after the classes are generated. The output for build-helper shows the correct source directory path where the classes are located and shows 'added'.

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. I am using Spring Tool Suite 3.8 which is based on Eclipse Neon 4.6.1.

Thanks

1

There are 1 best solutions below

0
On

I solved the issue by moving the project folders into my Eclipse workspace. They were situated outside the workspace and for some reason moving the project into the workspace and reimporting it has fixed things.