javamavenpluginsjaxbwsdl

JAXB-maven-plugin Skipping Executions Past Beyond First


Stumbled onto some odd behavior with the org.jvnet.jaxb:jaxb-maven-plugin:4.0.8 plugin, related to multiple executions to generate classes for multiple WSDLs. Each individual WSDL generates classes as expected when it is the first execution block defined in my pom.xml. Every other WSDL in subsequent executions is skipped with the following message:

[INFO] Latest timestamp of the source resources is [2025-05-16 18:23:58.989], earliest timestamp of the target resources is [2025-05-16 18:24:03.210].
[INFO] Sources are up-to-date, XJC (version 4.0.5) will be skipped.

The given timestamps are only a few seconds apart, XJC seems to be tripping on the classes generated by the first WSDL processed. If WSDL1 is listed first in the pom.xml, it generates and WSDL2 is skipped. If WSDL2 is listed first, it generates and WSDL1 is skipped. This behavior persists after running mvn:clean on the project. I can get around this behavior with the forceRegenerate flag, but that generates warnings and and doesn't seem like a proper solution. Anyone know a trick to get keep source-up-to-date checks relative to a given WSDL or JAXB execution?

I use binding files force the generated classes into distinct packages, so even classes with similar names are separated:

com.foo.ws.wsdl1
com.foo.ws.wsdl2

pom.xml:

...
<plugin>
    <groupId>org.jvnet.jaxb</groupId>
    <artifactId>jaxb-maven-plugin</artifactId>
    <version>4.0.8</version>
    <executions>
        <execution>
            <id>wsdl1</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <bindingDirectory>${project.bindings}</bindingDirectory>
                <bindingIncludes>wsdl1_bindings.xjb</bindingIncludes>
                <schemaIncludes>
                    <include>wsdl1.wsdl</include>
                </schemaIncludes>
            </configuration>
        </execution>
        <execution>
            <id>wsdl2</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <bindingDirectory>${project.bindings}</bindingDirectory>
                <bindingIncludes>wsdl2_bindings.xjb</bindingIncludes>
                <!-- <forceRegenerate>true</forceRegenerate> -->
                <schemaIncludes>
                    <include>wsdl2.wsdl</include>
                </schemaIncludes>
            </configuration>
        </execution>
    </executions>
</plugin>
...

Solution

  • You should consider adding the generateDirectory property for each execution in order to split generated classes. Default is :

    <generateDirectory>${project.build.directory}/generated-sources/xjc</generateDirectory>
    

    By splitting directories for each execution, the plugin will handle properly class / configuration and WSDL changes and will only generate classes when needed.

    Here, since plugin finds files in directory on 2nd execution which seems more recent than files used to generate classes, plugin skips 2nd execution generation

    Also feel free to post issue on jaxb-tools repository if needed, you'll get help more easily