Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven JAXB plugin executing only one excecution

I am trying to generated sources from two XSD schemas. My JAXB maven plugin looks like this:

<plugin>
    <groupId>com.sun.tools.xjc.maven2</groupId>
    <artifactId>maven-jaxb-plugin</artifactId>
    <version>1.1.1</version>
    <executions>
        <execution>
            <id>GenerateKenexa</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <includeBindings>
                    <includeBinding>**/jaxb-bindings-kenexa.xml</includeBinding>
                </includeBindings>
                <includeSchemas>
                    <includeSchema>**/KenexaXMLConfiguration.xsd</includeSchema>
                </includeSchemas>
            </configuration>
        </execution>
        <execution>
            <id>GenerateTalentQ</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <includeBindings>
                    <includeBinding>**/jaxb-bindings-talentq.xml</includeBinding>
                </includeBindings>
                <includeSchemas>
                    <includeSchema>**/TalentQXMLConfiguration.xsd</includeSchema>
                </includeSchemas>
            </configuration>
        </execution>
    </executions>
</plugin>

The first one gets generated fine. But the second one does not. I see in the maven output:

[INFO] --- maven-jaxb-plugin:1.1.1:generate (GenerateKenexa) @ online.tests.management ---
[INFO] Compiling file:/D:/Projects/GTIWebApplications/gti_online_tests_management/src/main/resources/xsd/KenexaXMLConfiguration.xsd
[INFO] Writing output to D:\Projects\GTIWebApplications\gti_online_tests_management\target\generated-sources\xjc
[INFO] 
[INFO] --- maven-jaxb-plugin:1.1.1:generate (GenerateTalentQ) @ online.tests.management ---
[INFO] files are up to date

It says that files are up to date, but they aren't even generated. What might be wrong?

like image 694
Paulius Matulionis Avatar asked Aug 31 '12 10:08

Paulius Matulionis


4 Answers

For people coming in to this question as I did, a year later :/

The problem persists in maven-jaxb2-plugin aswell, it's probably some sort of bug in 0.8.3. When you generate the files into the same directory, the plugin "thinks" that the files have allready been generated and skips that second execution.

I found that in order to generate the second execution you will have to set the argument

<forceRegenerate>true</forceRegenerate>

In the configuration section.

like image 70
Jan Nielsen Avatar answered Sep 29 '22 16:09

Jan Nielsen


I solved the problem. I have changed the maven jaxb plugin into maven jaxb2 plugin and now everything works. Now my maven configuration looks like this:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.8.2</version>
    <executions>
        <execution>
            <id>GenerateKenexa</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <schemaDirectory>src/main/resources/xsd</schemaDirectory>
                <schemaIncludes>
                    <include>KenexaXMLConfiguration.xsd</include>
                </schemaIncludes>
                <generatePackage>com.groupgti.onlinetest.kenexa.jaxb</generatePackage>
                <generateDirectory>${project.build.directory}/generated-sources/kenexa</generateDirectory>
            </configuration>
        </execution>
        <execution>
            <id>GenerateTalentQ</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <schemaDirectory>src/main/resources/xsd</schemaDirectory>
                <schemaIncludes>
                    <include>TalentQXMLConfiguration.xsd</include>
                </schemaIncludes>
                <generatePackage>com.groupgti.onlinetest.talentq.jaxb</generatePackage>
                <generateDirectory>${project.build.directory}/generated-sources/talentq</generateDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>
like image 27
Paulius Matulionis Avatar answered Sep 29 '22 15:09

Paulius Matulionis


I am using jaxb2 while still was facing the problem when I reached here. I added the below piece into config from other folks answers and it works now. For previous answers the part that did the trick should be:

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

Also a unique execution id is needed

<id>GenerateKenexa</id>

But different directories make the code lies into two top level packages, so at last I am using:

<forceRegenerate>true</forceRegenerate>
like image 21
Peng Zhang Avatar answered Sep 29 '22 16:09

Peng Zhang


First, I would recommend to specify separate output folders for each xsd <outputdirectory>${basedir}/target/generated-sources/xjc</outputdirectory>

And second, try to set it up as separate plugin entries, no separate executions:

<plugin>
    <groupId>com.sun.tools.xjc.maven2</groupId>
...
<includeSchema>**/KenexaXMLConfiguration.xsd...
...
</plugin>
<plugin>
    <groupId>com.sun.tools.xjc.maven2</groupId>
...
<includeSchema>**/TalentQXMLConfiguration.xsd...
...
</plugin>
like image 44
Grigory Katkov Avatar answered Sep 29 '22 17:09

Grigory Katkov