mojohaus / jaxb2-maven-plugin

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

Empty lines in generated XSD via schemagen goal with JDK 11 #160

Open ondrejlerch opened 4 years ago

ondrejlerch commented 4 years ago

After upgrading from JDK 8 to JDK 11 there are many empty lines in generated XSD, e.g.:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:EchoService="http://example/EchoService" elementFormDefault="qualified" targetNamespace="http://example/EchoService" version="1.0">

  <xs:element name="echoServiceRequest" type="EchoService:echoServiceRequest"/>

  <xs:complexType name="echoServiceRequest">

    <xs:sequence>

      <xs:element name="message" type="xs:string"/>

    </xs:sequence>

  </xs:complexType>

</xs:schema>

With JDK 8 and the same jaxb2-maven-plugin configuration generated XSD looked reasonable:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:EchoService="http://example/EchoService" elementFormDefault="qualified" targetNamespace="http://example/EchoService" version="1.0">

  <xs:element name="echoServiceRequest" type="EchoService:echoServiceRequest"/>

  <xs:complexType name="echoServiceRequest">
    <xs:sequence>
      <xs:element name="message" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

My jaxb2-maven-plugin configuration looks like:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>schemagen</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
                <clearOutputDir>true</clearOutputDir>
                <outputDirectory>${outputDirectory}</outputDirectory>
                <transformSchemas>
                    <transformSchema>
                        <uri>http://example/EchoService</uri>
                        <toPrefix>EchoService</toPrefix>
                        <toFile>EchoService.xsd</toFile>
                    </transformSchema>
                </transformSchemas>
            </configuration>
        </execution>
    </executions>
</plugin>

I am using jaxb2-maven-plugin in latest version 2.5.0.

Is my configuration wrong or is there a problem with jaxb2-maven-plugin / xjc / JDK 11?

See also: https://stackoverflow.com/questions/57309893/empty-lines-in-generated-xsd/61653789#61653789

Many thanks!