users@jaxb.java.net

Re: JAXB compilation plugin

From: Malachi de Ælfweald <malachid_at_gmail.com>
Date: Tue, 28 Feb 2006 13:02:19 -0800

Comments inline

On 2/28/06, Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_sun.com> wrote:
>
> Malachi de Ælfweald wrote:
> > I'm glad to hear that this was done. I had recently just wrote one of my
> own
> > because of the others I found not working. I had emailed Kohsuke about
> it,
> > but didn't think about getting it up on java.net.
>
> My sincere apologies for not being able to respond to it quickly. I'm
> really sorry to cause the duplication of work.


No problem. There were a few different ones out there that I tried using,
but they just weren't cooperating. I wrote it so that I could continue
developing and debugging. That being said, I think one supported plugin
would be better than maintaining my own :)

> A quick question... Why did you have it interact with the XJC2Task instead
> > of with Driver.run?
>
> I suggested that eventually it should be possible to read in the plugin
> configuration directly into Ant task definition, so you can write:
>
> <plugin>
> <groupId>com.sun.tools.xjc.maven2</groupId>
> <artifactId>maven-jaxb-plugin</artifactId>
> <executions>...</executions>
> <configuration>
> <xjc ant task definition here />
> </configuration>
>
> ... instead of defining its own syntax for the maven plugin. I plan to
> look at the code to see how hard it is to do this, and hopefully I
> should be able to submit a patch for a consideration of Jonathan.
>
> I think reusing the same syntax would reduce the amount of work, as well
> as being easier to understand.


I think that idea works well for those of us who have used Ant in the
past... but for users that are new to Maven2, they are likely not to learn
Ant syntax at all. I know my current build doesn't use any Ant syntax at
all. We should try to keep those users in mind.


> Also, one of the things that I implemented that might be useful for yours
> > was adding codemodel extensions so that we could add custom
> 'implements',
> > etc. The specific one that I did added a .toJAXBElement() method to
> > whichever class ObjectFactory created an JAXBElement for....
>
> Reusing Ant syntax should let one specify plugins, which I assume is
> what you are talking about, right?


Yes. Whether we use ant syntax or not doesn't really make that
determination. With Maven syntax, we could simply allow
<plugin>org.mycompany.mypackage.XjcMojo1</plugin>
<plugin>org.mycompany.myotherpackage.XjcMojo2</plugin>

As a side note, I think this is an area that might do well to have some
work. When we modify the codemodel, we have to have those plugins already
compiled first... however, in most build systems, jaxb is during the
generate-sources phase. If the plugin sources are part of their build, they
would be available at compile time, but not necessarily at
generate-sources... Perhaps we could add some logic to the codemodel to
allow referencing interfaces/classes by name that are not validated until
compile time -- ie: ability to let the user say "I want the class to
implement ThisInterface, which will be available later". Just a thought.

> Is there actually a dev.java.net project for this specific piece? I would
> be
> > more than willing to be a contributor on it.
>
> Yes. The code lives in a part of the JAXB project CVS repository. It's
> up to Jonathan to decide if he wants to have other developers, and if
> he's OK, I can grant necessary roles to Malachi.
>
> (Jonathan, in case you don't know, Malachi has been around the JAXB
> mailing list for a long time, and he knows a good deal about JAXB.)


:) Yeah, unfortunately, some hacker wiped out my eoti.org server so I lost
access for awhile. I changed my preferences to gmail so that I could get
back on the list.