users@jaxb.java.net

Re: JAXB XJC Maven 2 Plugin Questions

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Wed, 28 Nov 2007 11:17:15 +0100

Hi.

> 1. It looks like the latest version of the maven2 plugin is 1.1. This
> version is dependent on xjc 2.0.2. Can this support the latest xjc
> release (2.1.5?)?

Much more further developed and better supported is
maven-jaxb2-plugin. The project is very active and has more features.

See https://maven-jaxb2-plugin.dev.java.net/

Current version is 0.4.M3, comes with JAXB RI 2.1.5.

> 2. Also can the later xjc versions be released to the maven server? The
> latest released version is 2.0.3. (The 2.1-EA1 is no good because there
> is no pom).

JAXB 2.1.5 is in there. It is distributed via Maven1 dev.java.net repo:

http://download.java.net/maven/1/com.sun.xml.bind/jars/

See https://maven-jaxb2-plugin.dev.java.net/ for details on how to
bind this repo to your project.

> 3. How can I use jaxb2-commons plugins with the maven2 plugin?
> Specifically the value constructor, default value, equals & fluent api
> plugins?

1. The plugin you want to use must be available as a maven artifact.
2. Include the JAXB plugin artifact in configuration using the plugins/plugin
3. Add appropriate arguments to args/arg.
4. If generated code has some additional dependencies, add them to the
dependencies of your project so that the project would compile
allright.

Here's an example:

                        <plugin>
                                <groupId>org.jvnet.jaxb2.maven2</groupId>
                                <artifactId>maven-jaxb2-plugin</artifactId>
                                <configuration>
                                        <args>
                                                <arg>-XtoString</arg>
                                                <arg>-Xequals</arg>
                                                <arg>-XhashCode</arg>
                                                <arg>-Xcopyable</arg>
                                        </args>
                                        <plugins>
                                                <plugin>
                                                        <groupId>org.jvnet.jaxb2_commons</groupId>
                                                        <artifactId>basic</artifactId>
                                                        <version>0.2.GA</version>
                                                </plugin>
                                        </plugins>
                                </configuration>
                        </plugin>

I'll add this to plugin documentation as well.

ps. value-constructor is not a Maven project. fluent-api is a maven
project, but I don't see if it's available from any maven repo.
default value is not a maven project. commons-lang-plugin is a Maven
project but I don't see it in any of the repos. So if you really want
to use these, you'll have to install the manually.

For toString/equals/hashCode/copyable plugins see the example above.
org.jvnet.jaxb2_commons:basic implements these JAXB plugins.

Bye.
/lexi