users@jaxb.java.net

Re: JAXB XJC Maven 2 Plugin Questions

From: nidhi084 <nidhi084_at_gmail.com>
Date: Thu, 4 Jun 2009 00:47:02 -0700 (PDT)

Hi, I want to use jaxb with maven1 to be able to generate java classes with
annotations from an xsd.I was able to use jaxb-xjc-1.0.2 version but it
generated interfaces and impl classes from the xsd.So iguess i need to use a
latest version of jaxb-xjc jar. But i am not use it for maven1. I have the
following in my maven.xml:
</preGoal>
    <preGoal name="java:compile">
        <attainGoal name="jaxb:generate"/>
    </preGoal>
    <goal name="jaxb:generate"
        description="Generates the java classes using JAXB">

             <path id="xjc.class.path">
                  <!--path refid="maven.compile.classpath"/-->
                  <classpath refid="maven.dependency.classpath"/>
                  <fileset
dir="/home/nidhm/p4ws/nidhm_att_mobility_dcm_mm/repository/qpass-cingular-third-party/jars/">
                    <include name="**/*xjc*.jar"/>
                    <include name="**/*jaxb*.jar"/>
                  </fileset>
             </path>
                <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
                  <classpath refid="xjc.class.path"/>
                </taskdef>
                <!-- //Ant is not so intelligent, you have to create the
output directory manually -->
                <mkdir
dir="/home/nidhm/p4ws/nidhm_att_mobility_dcm_mm/jars/jobschedulerjobs/src/java/generated"/>
                <xjc
destdir="/home/nidhm/p4ws/nidhm_att_mobility_dcm_mm/jars/jobschedulerjobs/src/java/generated"
package="net.qpass.att.catalogFeed.data" removeOldOutput="yes">
                   <schema
dir="/home/nidhm/p4ws/nidhm_att_mobility_dcm_mm/jars/jobschedulerjobs/src/java/net/qpass/att/catalogFeed/xsd"
includes="*.xsd"/>
                   <produces
dir="/home/nidhm/p4ws/nidhm_att_mobility_dcm_mm/jars/jobschedulerjobs/src/java/generated"
includes="**/*"/>
                </xjc>

   </goal>

But while compiling i am getting an error:
java.lang.NullPointerException
        at com.sun.tools.xjc.Messages.format(Messages.java:49)
        at com.sun.tools.xjc.Driver.getBuildID(Driver.java:410)

I think i am doing something wrong here. Can anyone please tell me a working
example, maven.xml snippet for this? and please specify the jar version i
need to use.

Please reply asap.
Thanks


Aleksei Valikov wrote:
>
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
>

-- 
View this message in context: http://www.nabble.com/JAXB-XJC-Maven-2-Plugin-Questions-tp13985771p23865320.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.