users@jaxb.java.net

Re: JAXB Plugin

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Fri, 10 Nov 2006 14:01:41 +0100

Hi.

> Thanks lexi.
> I've refined my work.
> Now I'm trying to create my "dummy plugin" which the content is just the
> same as code injector, just adding a line of println inside the run
> method of the PluginImpl class.
>
> Here are my steps:
> 1. Add the line "System.out.println("A");" inside method run of
> PluginImpl.java
> 2. Change the getNameOption to returning String "inject-code"

Should be "Xinject-code".

> 3. change the package name to "package mycodeinjector", also the in file
> Const.java

I'd choose a more meaningful package name, but that's your choice.

> 4. Save the file inside folder mycodeinjector
> 5. I compiled it.
> 6. Adding line "mycodeinjector.PluginImpl" in file
> META-INF/services/com.sun.tools.xjc.Plugin
> 7. Creating the jar files using command
> jar -cf plugin.jar META-INF mycodeinjector/*.class
> 8. Change the build file to use argument of "-inject-code"

Should be -Xinject-code.

> Now it cause error message, "unrecognized parameter -inject-code"
> Even when I change the build file to use argument of "-Xinject-code",
> which did work, it showed an error message of "unrecognized parameter
> -Xinject-code"

Is your JAR file in the XJC classpath?

Maybe you'll find this helpful:
https://hyperjaxb2.dev.java.net/nonav/hyperjaxb2/reference/reference.html#d0e2237

And a general comment. I see you're trying to do a nice thing but I'd suggest
that you first take a look at build tools like Ant or Maven. You are doing
things manually. This is ok, but you can automate a lot and avoid a lot of problems.
I'd suggest maven2, this seems to be the tool of the future. Therefore the
earlier you switch to it/learn it, the better is it for you.

Bye.
/lexi