jaxb2-maven-plugin only executing first execution
Asked Answered
S

2

12

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?

Saline answered 24/3, 2014 at 11:37 Comment(0)
S
11

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

Saline answered 24/3, 2014 at 12:30 Comment(0)
F
0

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

Fifteen answered 4/8, 2022 at 9:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.