users@jaxb.java.net

RE: JAXB compilation plugin

From: Jonathan Johnson <jonjohnson_at_mail.com>
Date: Sat, 4 Feb 2006 23:58:15 -0500

Kohsuke,

In my progress for creating a JAXB compilation plugin for Maven 2 (should be
available in a few more evenings) I started to use the class
com.sun.tools.xjc.XJC2Task.

When calling:

        XJC2Task xjc = new XJC2Task();
        xjc.setSchema("/development/JAXB-SOURCES/JAXBSample/src/main/resourc
es/schemas/catalog.xsd");

it produces this NPE inside XJC2Task.setSchema

java.lang.NullPointerException
        at com.sun.tools.xjc.XJC2Task.setSchema(XJC2Task.java:118)
        at
com.sun.tools.xjc.maven.JAXBGenerateMojo.execute(JAXBGenerateMojo.jav
a:143)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:415)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:531)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLi
fecycle(DefaultLifecycleExecutor.java:472)...

When I got the cvs source for JAXB-SOURCES the class XJC2Task was not in
there only XJCTask.

The javadoc for XJC2Task.setSchema is a ambiguous because its not clear if
the String parameter should be a file path name for the schema for, a URL or
the actual schema xsd text. The javadoc for setSchema(String schema) reads
"Parses the schema attribute."

Should I be using using XJCTask instead? Perhaps I use
com.sun.tools.xjc.api.Driver to eliminate the ant dependency (no pun
intendend)?


-----Original Message-----
From: Kohsuke Kawaguchi [mailto:kohsuke.kawaguchi_at_sun.com]
Sent: Saturday, January 28, 2006 10:31 AM
To: users_at_jaxb.dev.java.net
Subject: Re: JAXB compilation plugin


Jonathan Johnson wrote:
> Kohsuke,
>
> Yes, start simple and grow the features as needed. The Ant JAXB features
> are a good guideline
> (http://java.sun.com/webservices/docs/1.6/jaxb/ant.html) for Mavenizing.
As
> you suggested using com.sun.tools.xjc.XJC2Task would be best since it
builds
> on the ant experience, eases the transition from ant and adapts to future
> needs.

I then realized that you'd probably want to take some of the values from
Maven project setting --- such as where to place generated source files.

So perhaps instead of just copying XML, your plugin would probably want
to do additional configuration.


> Thanks for the CVS access. I'm new to contributing to open source. Can
you
> point me to the guidelines and standards for create and submitting code.

There's not so much of "guideline and standards". You can just take it
easy and start writing code, and we can adjust as we go along :-)

If you are going to help an existing code, that usually calls for more
"guidelines and standards", but since this plugin is from scratch, it's
more like what you do will decide guidelines.

> What java version is the target?

Since JAXB2 itself requires Tiger, there's no point in not using Tiger
features, I think.

> Do I create a build.xml as well (no pom.xml) ;-(? Etc..

Since you are writing a plugin for Maven2, there's no reason not to use
Maven2 as the build system. That would probably be the easiest, as Maven
defines all sorts of goals for developing plugins.

--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com