Generate getter/setter JavaDoc from XSD with jaxb

63 views Asked by At

I am using jaxb-maven-plugin to generate Java code with XML bindings from XSD files. While it works generally great, the JavaDoc of the generated setters and getters are missing the documentation from the xs:annotation /xs:documentation. I even started to write my own jaxb plugin; but even within such plugin I don't seem to be able to access the element's annotation.

Is there a straight forward way to do this? The org.jibx's jibx-maven-plugin seems to be doing this out of the box, but I would like to be able to use the jaxb-maven-plugin's extensions and more up to date dependencies.

Example extract of the XSD:

<xs:complexType name="Some_Type">
    <xs:sequence>
        <xs:element name="Some_Field" type="BoolType" minOccurs="0" maxOccurs="1">
            <xs:annotation>
                <xs:documentation>Some documentation</xs:documentation>
            </xs:annotation>
        </xs:element>
</xs:complexType>

POM extract:

<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin</artifactId>
<version>4.0.0</version>
1

There are 1 answers

3
Laurent Schoelens On

We are currently working on 4.0.1 version of the org.jvnet.jaxb:jaxb-maven-plugin.

This version includes update to 4.0.4 jaxb-ri.
This 4.0.4 jaxb version includes the fix of issue #1708 : add javadoc from xsd documentation tags.

In the meantime, if you're using simple case usage of the plugin, you can try providing jaxb-xjc 4.0.4 as dependency of the plugin with the following change :

  • addIfExistsToEpisodeSchemaBindings should be set to false (due to fixed also done in jaxb-ri (issue #829)

Another possible solution is to use the following xjc plugin from CXF with the Xjavadoc flag :

<dependency>
    <groupId>org.apache.cxf.xjcplugins</groupId>
    <artifactId>cxf-xjc-javadoc</artifactId>
    <version>4.0.0</version>
</dependency>