Search code examples
javamaven-2jaxbmavenmaven-plugin

Difference of Maven JAXB plugins


I have determined that two JAXB plugins for Maven 2 exist, with some different configurations.

The one is from Sun: http://jaxb.dev.java.net/jaxb-maven2-plugin/, the other from Mojohaus: http://mojohaus.org/jaxb2-maven-plugin/

Which of these two plugins can be recommended?


Thanks Matt. On my little research project, I found that there's quite another plugin comming from the sunners:

<groupId>com.sun.tools.xjc.maven2</groupId>  
<artifactId>maven-jaxb-plugin</artifactId>  

and that one:

<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>

and still the one from Codehouse.


Solution

  • Let's summarize. We have/had:

    1. the jaxb-maven-plugin (https://github.com/highsource/jaxb-tools), formerly called 'maven-jaxb2-plugin'.
    2. the maven-jaxb-plugin (https://jaxb.dev.java.net/jaxb-maven2-plugin/)
    3. the jaxb2-maven-plugin (https://github.com/mojohaus/jaxb2-maven-plugin)

    Based on the comments of this thread, I've always used the maven-jaxb2-plugin (i.e. plugin #1):

    Concerning the org.jvnet.jaxb2.maven2:maven-jaxb2-plugin versus com.sun.tools.xjc.maven2:maven-jaxb-plugin, from my point of view it's definitely the first one (http://maven-jaxb2-plugin.java.net/).

    This plugin has much more features than com.sun.tools.xjc.maven2:maven-jaxb-plugin, the development is active. Finally, I'm one of the authors :) and I'd say we keep in touch with JAXB developers and users and react to the latests features/requests.

    And indeed, plugin #2 is dead. And because I've always been happy with #1, I've never used plugin #3 so can't really say anything about it. Just in case, here is a working configuration for the old plugin #1:

    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <source>1.5</source>
              <target>1.5</target>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
              <execution>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </project>