mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
107 stars 77 forks source link

JavaDoc Processor disregards xml type renaming #25

Closed dxxr closed 8 years ago

dxxr commented 9 years ago

The JavaDoc post-processor seems to disregard xml type renamings... Version:

<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.1</version>

Example 1: No xml type name given, documentation is copied

/** Class level documentation */
@XmlType
public class TestType {

    /** Field level documentation */
    private Integer id;
}
 <xs:complexType name="testType">
    <xs:annotation>
      <xs:documentation><![CDATA[Class level documentation]]></xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element minOccurs="0" name="id" type="xs:int">
        <xs:annotation>
          <xs:documentation><![CDATA[Field level documentation]]></xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

Example 2: xml type is renamed, no documentation...

/** Class level documentation */
@XmlType(name = "SomeOtherType")
public class TestType {

    /** Field level documentation */
    private Integer id;
}
  <xs:complexType name="SomeOtherType">
    <xs:sequence>
      <xs:element minOccurs="0" name="id" type="xs:int"/>
    </xs:sequence>
  </xs:complexType>
lennartj commented 9 years ago

True. This situation is not handled in the current or upcoming (2.2) release of the plugin. We need an IT to tracks this issue in downstream deliveries.

lennartj commented 9 years ago

Are there other such "re-name" attributes than as shown in the @XmlType (name="SomeOtherType") annotation?

dxxr commented 9 years ago

Well, I guess the main ones are Types

@XmlType(name="some-type")
<xs:complexType name="some-type"> ...

Elements

@XmlElement(name = "some-element")
@XmlRootElement(name = "some-root")
@XmlElementWrapper(name = "some-wrapper")
<xs:element name="some-element" .... />
<xs:element name="some-root" .... />
<xs:element name="some-wrapper" .... />

Attributes

@XmlAttribute(name = "some-attribute")
<xs:attribute name="some-attribute" .... />

Btw. I've noticed that enums don't get annotated at all, regardless whether re-named or not:

/** Enum Class level documentation */
@XmlEnum
@XmlType(name="SomeEnumType")
public enum EnumType {

    /** Enum constant level documentation */
    VALUE1,

    /** Enum constant level documentation */
    VALUE2

}
  <xs:simpleType name="SomeEnumType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="VALUE1"/>
      <xs:enumeration value="VALUE2"/>
    </xs:restriction>
  </xs:simpleType>
lennartj commented 9 years ago

Good input, this. Solution to this problem is rather pinpointed in the codebase, so we should be able to deal with it in a rather simple manner. However, we need to create ITs to track this issue from future regressions.

lennartj commented 8 years ago

Fixed this in recent commits. Slated for 2.3 release.