Question

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?

Was it helpful?

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

OTHER TIPS

I wasn't be able to use version 1.6 of the plugin to solve this problem (DataSource class not found, impossible to solve this even by using javax-annotation dependency as suggested in some posts)

but I found a way to make jaxb plugin 1.5 working on more than one execution : Inside each <configuration> section defined in each <execution> section, define the following parameter :

<execution>
    ....
    <configuration>
        ....
        <staleFile>${project.build.directory}/some directories/staleFile>
    </configuration>
</execution>

Of course, the absolute file path must be unique for each execution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top