javamavenjaxb2

jaxb2-maven-plugin only executing first execution


I'm trying to convert multiple XSDs to POJOs in different packages using JAXB using the jaxb-maven plugin. I've set it up to use multiple execution blocks, the first execution block executes, then I get a message saying: No changes detected in schema or binding files

This is an extract from my pom.xml:

...
<build>
    <pluginManagement>
        <plugin> 
            <groupId>org.codehaus.mojo</groupId> 
            <artifactId>jaxb2-maven-plugin</artifactId> 
            <version>1.5</version> 
        </plugin>
    </pluginManagement>
    <plugins>
    <!-- JAXB GENERATOR PLUGIN -->
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.5</version>
        <executions>                    
        <execution>
            <id>Application0</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version1</schemaDirectory>
            <packageName>za.co.mycee.application.model</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>                
        <execution>
            <id>Application1</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version1</schemaDirectory>
            <packageName>za.co.mycee.application.model.version1</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>
        <execution>
            <id>Application2</id>
            <phase>generate-sources</phase>
            <goals>
            <goal>xjc</goal>
            </goals>
            <configuration>
            <schemaDirectory>src/main/webapp/WEB-INF/xsd/version2</schemaDirectory>
            <packageName>za.co.mycee.application.model.version2</packageName>
            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
            <clearOutputDir>false</clearOutputDir>
            <source>1.5</source>
            <target>2.1</target>
            <arguments>-no-header</arguments>
            </configuration>
        </execution>        
        </executions>
    </plugin>
    ...
</build>
....

This is the error message I'm getting:

[INFO] --- jaxb2-maven-plugin:1.5:xjc (Application) @ mycee-application ---                                                                                                        
[INFO] Generating source...                                                                                                                                                  
[INFO] parsing a schema...                                                                                                                                                   
[INFO] compiling a schema...                                                                                                                                                 
[INFO] za/co/mycee/application/model/AddressType.java                                                                                                                          
[INFO] ...
[INFO] za/co/mycee/application/model/package-info.java                                                                                                                         
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (Application1) @ mycee-application ---
[INFO] No changes detected in schema or binding files - skipping source generation.
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (Application2) @ mycee-application ---
[INFO] No changes detected in schema or binding files - skipping source generation.

If I swap the execution blocks around, the first one always executes and I get the same message for the remaining two blocks.

Any ideas on how to work around this?


Solution

  • Fixed it by upgrading to version 1.6

    <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>jaxb2-maven-plugin</artifactId> 
        <version>1.6</version> 
    </plugin>
    

    and

    <!-- JAXB GENERATOR PLUGIN -->
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.6</version>
        ....
    

    Fixed in version 1.6, in version 1.5 all execution blocks were using the same staleFile: http://jira.codehaus.org/browse/MJAXB-8