rackerlabs / gradle-jaxb-plugin

Gradle plugin to ease projects that use xsds and the ant jaxb task
GNU General Public License v2.0
34 stars 21 forks source link

Super interface reference is not present in jaxb class path #21

Closed sreekanthp closed 6 years ago

sreekanthp commented 7 years ago

I am using a super interface com.test.xsd.Element. Using xjb I am configuring the interface. This interface is in my current project src/main/java location. Jaxb classes generating successfully and Implementing the interface. but compilation fails with "com.test.xsd" package does not exist. import com.test.xsd.Element.Element; how we can add this interface to the class path.

subprojects { project ->
    apply plugin: 'org.openrepose.gradle.plugins.jaxb'
    dependencies {
        jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7'
        jaxb 'com.sun.xml.bind:jaxb-impl:2.2.7'
        jaxb 'javax.xml.bind:jaxb-api:2.2.7'
    }

    def generatedDir = "${project.buildDir}/generated-sources/xjc"

    jaxb {
        xjc {
            args['-npa']
            extension=true
            destinationDir = "${generatedDir}"
            generateEpisodeFiles=false
        }
    }

    sourceSets {
        main {
            java {
                srcDirs += "${generatedDir}"
            }
        }
    }
}
wdschei commented 6 years ago

@sreekanthp Did you get this working? Is there a project you can point me at?

sreekanthp commented 6 years ago

u can create a binding file like this

<jaxb:bindings version="1.0"
               xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
               xmlns:xs="http://www.w3.org/2001/XMLSchema"
               xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
  <jaxb:globalBindings generateValueClass="false">
    <xjc:superInterface name="com.test.common.jaxb.InputElement" />
    <xjc:serializable uid="3099325368888314454" />
    <xjc:simple />
  </jaxb:globalBindings>
</jaxb:bindings>

and refer this in in to the plugin.

ant.xjc(destdir: project.ext.generatedSrcDir,extension:true){
                schema(dir: 'src/main/resources/com/mmi', includes: "**/*.xsd")
                binding(dir: "src/main/resources", includes: '*.bnd')
                arg(value: '-npa')
}
wdschei commented 6 years ago

@sreekanthp

I created a Short, Self Contained, Correct (Compilable), Example or Minimal, Complete, and Verifiable example here:

And I think the line you may be missing in your build is here:

wdschei commented 6 years ago

Due to inactivity, this issue is being closed.