Mirror of Apache CXF

Clone this repo:
  1. 02f4fc9 Merge pull request #421 from apache/coheigea/introspection by Colm O hEigeartaigh · 17 hours ago main
  2. 9f56ba2 Fix DefaultValuePlugin with -enableIntrospection and report code write errors by Colm O hEigeartaigh · 20 hours ago
  3. 91dc707 Bump org.apache.maven.plugins:maven-surefire-report-plugin (#420) by dependabot[bot] · 27 hours ago
  4. c17eb20 Bump org.apache.maven.plugins:maven-surefire-plugin from 3.6.0 to 3.6.1 (#419) by dependabot[bot] · 27 hours ago
  5. ca45ae4 Merge pull request #418 from apache/coheigea/ToStringPlugin by Colm O hEigeartaigh · 2 days ago

Apache CXF XJC Utils

A collection of XJC (JAXB XML-to-Java compiler) plugins and utilities for use with Apache CXF. These extensions augment CXF's code generation pipeline when compiling XML Schemas and WSDL files into Java.

Modules

ModuleArtifactDescription
cxf-xjc-pluginorg.apache.cxf:cxf-xjc-pluginMaven plugin (goals xsdtojava and xsdtojava-tests) that runs XJC on standalone XML Schemas, optionally with the extensions below
dvorg.apache.cxf.xjcplugins:cxf-xjc-dv-Xdv — initializes fields mapped from elements with the schema default values
tsorg.apache.cxf.xjcplugins:cxf-xjc-ts-Xts — adds a toString() to generated classes that prints the value of every field (using cxf-xjc-runtime at runtime). This includes any sensitive data, such as passwords or tokens, so take care when logging generated objects
booleanorg.apache.cxf.xjcplugins:cxf-xjc-boolean-Xbg — generates getXXX() instead of isXXX() for Boolean properties; -Xbgi generates both
javadocorg.apache.cxf.xjcplugins:cxf-xjc-javadoc-Xjavadoc — generates Javadoc from xsd:documentation
property-listenerorg.apache.cxf.xjcplugins:cxf-xjc-pl-Xproperty-listener — adds a PropertyChangeListener to all set methods
wsdlextensionorg.apache.cxf.xjcplugins:cxf-xjc-wsdlextension-Xwsdlextension — adds WSDL extension methods to generated root classes
bug671org.apache.cxf.xjcplugins:cxf-xjc-bug671-Xbug671 — maps package names that contain Java keywords
bug986org.apache.cxf.xjcplugins:cxf-xjc-bug986-Xbug986 — removes @XmlSchemaType(anySimpleType) from fields that should not have it
runtimeorg.apache.cxf.xjc-utils:cxf-xjc-runtimeRuntime support classes used by code generated with some of the plugins (e.g. -Xts)

Note that the artifacts use different groupIds: the Maven plugin is org.apache.cxf:cxf-xjc-plugin, while the XJC extensions are under org.apache.cxf.xjcplugins. When searching Maven Central, search by artifactId (e.g. cxf-xjc-plugin, cxf-xjc-dv) rather than by a single groupId.

Versioning

CXF XJC Utils is released independently of Apache CXF, and its version numbers do not track CXF releases. For example, there is no XJC Utils release for every CXF patch release. Use the latest XJC Utils release from the same major line as your CXF version (4.x for CXF 4.x, which uses Jakarta XML Binding; 3.x for CXF 3.x, which uses javax.xml.bind). The available versions are listed on Maven Central.

Usage

With cxf-codegen-plugin (WSDL to Java)

Add the desired extension as a dependency of the cxf-codegen-plugin Maven plugin:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <dependencies>
    <dependency>
      <groupId>org.apache.cxf.xjcplugins</groupId>
      <artifactId>cxf-xjc-dv</artifactId>
      <version>${cxf-xjc-utils.version}</version>
    </dependency>
  </dependencies>
</plugin>

Then activate the plugin in your wsdl2java configuration:

<configuration>
  <defaultOptions>
    <extraargs>
      <extraarg>-xjc-Xdv</extraarg>
    </extraargs>
  </defaultOptions>
</configuration>

With cxf-xjc-plugin (XML Schema to Java)

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-xjc-plugin</artifactId>
  <version>${cxf-xjc-utils.version}</version>
  <executions>
    <execution>
      <id>xsdtojava</id>
      <goals>
        <goal>xsdtojava</goal>
      </goals>
      <configuration>
        <xsdOptions>
          <xsdOption>
            <extension>true</extension>
            <xsd>${basedir}/src/main/resources/schemas/foo.xsd</xsd>
            <extensionArgs>
              <arg>-Xdv</arg>
            </extensionArgs>
          </xsdOption>
        </xsdOptions>
        <extensions>
          <extension>org.apache.cxf.xjcplugins:cxf-xjc-dv:${cxf-xjc-utils.version}</extension>
        </extensions>
      </configuration>
    </execution>
  </executions>
</plugin>

XJC extensions are loaded only from the artifacts listed under <extensions> and from the <dependencies> of the cxf-xjc-plugin itself, not from the dependencies of your project. If you previously relied on an XJC extension being found as a project dependency, add it to <extensions> instead.

Requirements

  • Java 17+
  • Maven 3.6.3+
  • Apache CXF 4.x (see Versioning)

Building from Source

git clone https://github.com/apache/cxf-xjc-utils.git
cd cxf-xjc-utils
mvn install

License

Apache License, Version 2.0. See LICENSE for details.