Difference of Maven Jaxb Plugins

Difference of Maven JAXB plugins

Let's summarize. We have/had:

  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 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 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>


maven-jaxb2-plugin VS jaxb2-maven-plugin for multiple schemas

General advice: specify your packages in bindings.xjb rather than in different executions with individual generatePackages.

<jxb:bindings schemaLocation="common1.xsd" node="/xsd:schema">
<jxb:schemaBindings>
<jxb:package name="mypackage.commonclasses"/>
</jxb:schemaBindings>
</jxb:bindings>

generatePackage does not really work well with multiple schemas.

And please file a bug in

https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN

citing the problem with the multiple schemas and Eclipse. I'll take a look into it.

ps. SO disclaimer: I'm the author of maven-jaxb2-plugin.

maven: which jaxb plugin to use?

There was a question that you could find helpful: Difference of Maven JAXB plugins.

Truly, the com.sun.tools.xjc.maven2:maven-jaxb-plugin seems to be dead, it also offers few configuration options. I used it for a while, then switched to org.codehaus.mojo:jaxb2-maven-plugin when I found a need to customize the generation to the extent the Sun's plugin could not cope with.

I haven't used the org.codehaus.mojo:xjc-maven-plugin, but it seems to be a subset of the more versatile org.codehaus.mojo:jaxb2-maven-plugin. As for the last one, the org.jvnet.jaxb2.maven2:maven-jaxb2-plugin, no personal experience, either, but the dead links on the terse documentation page are not encouraging.

which jaxb plugin to use?

maven-jaxb-plugin supports jaxb1.0 and this has not been updated since June 2005.

The maven-jaxb2-plugin supports JAXB 2.1.

See more on this thread

What Maven2 plugins are available for JAXB2?

I found the following to be working well enough for my system.

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


Related Topics



Leave a reply



Submit