Difference of Maven JAXB plugins

cuh picture cuh · Mar 12, 2010 · Viewed 91.8k times · Source

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.

Answer

Pascal Thivent picture Pascal Thivent · Mar 12, 2010

Let's summarize. We have:

  1. the maven-jaxb2-plugin (https://github.com/highsource/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, the plugin #2 isn't very active (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 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>