How to use JAXB extensions on xjc command line

I am working on a related issue here , but I have a separate question. This may be part of the same problem, but it seems different.

Due to the problems that I launch XJC through the Ant task and through the facade, I am now trying to start it using the "xjc" command-line tool from the JDK.

As in the original problem, I am trying to use the extensions "Wrapper Element" and "Fluent API", so my command line is as follows:

xjc -extension -classpath "lib/jaxb-fluent-api-2.1.8.jar;lib/jaxb-xew-plugin-1.4.jar" -Xxew -summary target/xew-summary.txt -instantiate lazy -Xfluent-api schema/serviceCallResults.xsd 

These are basically the same parameters that I sent to the Maven plugin "cxf-jaxb-plugin", which has been running for a long time. Unfortunately, this "xjc" command line fails:

unrecognized option -Xxew

What could be wrong here?

+6
source share
1 answer

It just doesn't work, sorry.

XJC plugins must extend the com.sun.tools.xjc.Plugin class. But XJC, which is included in the JDK and is available as xjc binary (for example, xjc.exe for Windows), is repackaged: com.sun.tools.xjccom.sun.tools.internal.xjc .

So, on the vanilla xjc command line, you do not have the class com.sun.tools.xjc.Plugin (extensions for XJC plugins), but com.sun.tools.internal.xjc.Plugin .

So the xjc CLI just doesn't work with XJC plugins. The only plugins that still work are those that are also repackaged. (Example com.sun.tools.internal.xjc.addon.code_injector.PluginImpl .)

If you need a command line, try to figure out the parameters java -cp ... , this is the only way to make it work with third-party XJC plugins, such as XEW or JAXB2-Basics.

+6
source

Source: https://habr.com/ru/post/981529/


All Articles