bjornvester / xjc-gradle-plugin

A Gradle plugin for running the XJC binding compiler to generate JAXB Java source code from XSD schemas
MIT License
59 stars 10 forks source link

java.lang.NullPointerException when xsd with <jaxb:globalBindings optionalProperty="primitive"> element #26

Open Andrey-Metelyov opened 2 years ago

Andrey-Metelyov commented 2 years ago

Excution failed:

Execution failed for task ':xjc'.
> A failure occurred while executing com.github.bjornvester.xjc.XjcWorker
   > java.lang.NullPointerException (no error message)

When compiling xsd:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://unbroken-dome.org/gradle-xjc-plugin/samples/books"
            xmlns:jaxb="https://jakarta.ee/xml/ns/jaxb"
            jaxb:version="3.0"
            targetNamespace="http://unbroken-dome.org/gradle-xjc-plugin/samples/books">

  <xsd:annotation>
    <xsd:appinfo>
<!--      <jaxb:globalBindings>-->
      <jaxb:globalBindings optionalProperty="primitive">
        <jaxb:serializable/>
      </jaxb:globalBindings>
    </xsd:appinfo>
  </xsd:annotation>
  <xsd:complexType name="bookType">
    <xsd:attribute name="title" type="xsd:string"/>
    <xsd:attribute name="author" type="xsd:string"/>
    <xsd:attribute name="bestseller" type="xsd:boolean"/>
    <xsd:attribute name="publicationYear" type="xsd:gYear"/>
  </xsd:complexType>

  <xsd:element name="book" type="tns:bookType"/>

  <xsd:complexType name="booksType">
    <xsd:sequence>
      <xsd:element ref="tns:book"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:element name="books" type="tns:booksType"/>
</xsd:schema>

build.gradle:

plugins {
  id('java-library')
  id('com.github.bjornvester.xjc') version '1.6.0'
}
repositories {
  mavenCentral()
}

dependencies {
  xjc "org.glassfish.jaxb:jaxb-runtime:3.0.2"
  xjc 'org.glassfish.jaxb:jaxb-xjc:3.0.1'
  xjc 'jakarta.xml.bind:jakarta.xml.bind-api:3.0.1'
  xjc 'jakarta.annotation:jakarta.annotation-api:2.0.0'
  xjc 'jakarta.activation:jakarta.activation-api:2.0.1'
}

xjc {
  xjcVersion.set("3.0.0")
  xsdDir.set(layout.projectDirectory.dir("src/main/schema"))
}