The CXF XJC Maven Plugin
The CXF XJC Maven Plugin is a wrapper around the JAXB XJC tool to handle the XSD -> Java tasks.
There are two targets:
xsdtojava |
Defaults into generate-sources phase and outputs to ${project.build.directory}/generated/src/main/java |
xsdtojava-tests |
Defaults into generate-test-sources phase and outputs to ${project.build.directory}/generated/src/test/java |
Parameters
extensions |
List of maven artifacts to add to the extension classpath. Each item in the list is a string of groupId:artifactId:version. |
xsdOptions |
List of XsdOption objects. See below. |
sourceRoot/testSourceRoot |
For the two targets above, override the default output directory. |
The XsdOption object is used to pass specific options and configuration for each XSD file that is to be processed.
xsd |
The location of the schema to process. |
bindingFile |
The location of the JAXB binding file to customize the output. |
packagename |
Specifies the package name to use for the outputted code. |
extension |
(boolean) Turns on the custom JAXB implementation extensions. |
catalog |
The location of a catalog file for mapping schema locations. |
extensionArgs |
List of additional arguements passed to XJC. (ex: -Xlocator) |
dependencies |
List of files that are examined to determine if subsequent runs of the plugin must re-generate code. |
deleteDirs |
List of directories that are removed after generation. If you have schemas that generate code that has already been generated, (possibly in a different maven module) you can specify this to have them removed. The preferred method to do this, however, is a binding file with the "skip" flag set on those namespaces. |
Example:
<plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-xjc-plugin</artifactId> <version>2.3.0</version> <configuration> <extensions> <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:2.3.0</extension> </extensions> </configuration> <executions> <execution> <id>generate-sources</id> <phase>generate-sources</phase> <goals> <goal>xsdtojava</goal> </goals> <configuration> <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot> <xsdOptions> <xsdOption> <xsd>classpath:/schemas/wsdl/http.xsd</xsd> <bindingFile>classpath:/schemas/wsdl/http.xjb</bindingFile> <catalog>${basedir}/src/main/build-resources/catalog.cat</catalog> </xsdOption> <xsdOption> <xsd>classpath:/schemas/wsdl/ws-addr.xsd</xsd> <packagename>org.apache.cxf.ws.addressing</packagename> </xsdOption> <xsdOption> <xsd>classpath:/schemas/wsdl/addressing.xsd</xsd> <bindingFile>classpath:/schemas/wsdl/addressing.xjb</bindingFile> </xsdOption> <xsdOption> <xsd>classpath:/schemas/configuration/security.xsd</xsd> <bindingFile>classpath:/schemas/configuration/security.xjb</bindingFile> <catalog>${basedir}/src/main/build-resources/catalog.cat</catalog> <extensionArgs> <extensionArg>-Xdv</extensionArg> </extensionArgs> </xsdOption> <xsdOption> <xsd>classpath:/schemas/wsdl/ws-addr-wsdl.xsd</xsd> <bindingFile>classpath:/schemas/wsdl/ws-addr-wsdl.xjb</bindingFile> <extension>true</extension> </xsdOption> <xsdOption> <xsd>classpath:/schemas/wsdl/addressing200403.xsd</xsd> <bindingFile>classpath:/schemas/wsdl/addressing200403.xjb</bindingFile> </xsdOption> </xsdOptions> </configuration> </execution> </executions> </plugin>