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

episode files ignored if binding file used #33

Closed Clockwork-Muse closed 5 years ago

Clockwork-Muse commented 6 years ago

I'm using a build task to drop .episodes from dependencies into build/generated-resources/episodes (and the source XSDs into src/main/resources/schema/), and this works fine (classes from the dependency are reused)... until I add an .xjb. Doing so causes the classes to be regenerated.

The build file I'm working with looks like this:

buildscript {
    ext {
        jaxbVersion = "2.2.11"
        dependencyVersion = "2.27.0"
    }
}

plugins {
    id "java"
    id "eclipse"
    id "maven"
    id "org.openrepose.gradle.plugins.jaxb" version "2.4.1"
}

repositories {
    mavenCentral()
    mavenLocal()
}

jar {
    baseName = "some.artifact"
    appendix = "soap"
}

group = "some.group"
version = "5.0.0"
sourceCompatibility = 9
targetCompatibility = 9

configurations {
    api
}

dependencies {
    api "some.group:some.dependency:${dependencyVersion}"
    compile "some.group:some.dependency:${dependencyVersion}"
    compile "javax.xml.bind:jaxb-api:${jaxbVersion}"
    jaxb "org.glassfish.jaxb:jaxb-runtime:${jaxbVersion}"
    jaxb "org.glassfish.jaxb:jaxb-xjc:${jaxbVersion}"
    jaxb "javax.xml.bind:jaxb-api:${jaxbVersion}"
    jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-ant:1.11.1"
    jaxb "org.jvnet.jaxb2_commons:jaxb2-basics:1.11.1"
    jaxb "org.jvnet.jaxb2_commons:jaxb2-basics-annotate:1.0.4"
    jaxb "javax.activation:activation:1.1.1"
}

task extractApi(type: Copy) {
    dependsOn configurations.api

    configurations.api.asFileTree.each {
        from(zipTree(it))
        include "/schema/*.xsd"
    }
    into "src/main/resources/"
}

task extractBinding(type: Copy) {
    dependsOn configurations.api

    configurations.api.asFileTree.each {
        from(zipTree(it))
        include "*.episode"
    }
    into "build/generated-resources/episodes"
}

jaxb {
    System.setProperty("javax.xml.accessExternalSchema", "all")
    xsdIncludes = ["local.xsd"]
    xjc {
        generatePackage = "some.package.name"
        header = false
        removeOldOutput = "yes"
        taskClassname = "org.jvnet.jaxb2_commons.xjc.XJC2Task"
        args = [
            "-verbose", "-Xinheritance", "-Xannotate",
        ]
    }
}

tasks.xjc.dependsOn("extractApi")
tasks.xjc.dependsOn("extractBinding")

sourceSets {
    main {
        java.srcDirs += "$project.buildDir/generated-sources/xjc"
        resources.srcDirs += "$project.buildDir/generated-resources/episodes"
    }
}

...and it works as expected until I try to add an xjb (because I have numeric enums).


I have figured out a workaround - import into a different build folder, then manually add the episodes as an arg to the XJC task (different build folder, because otherwise it complains about it "being attached to the wrong spot").

wdschei commented 5 years ago

Issue closed due to lack of activity.