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 23 forks source link

Output separate schemas to separate packages (2.5.0) #44

Open konstantinosraptis91 opened 5 years ago

konstantinosraptis91 commented 5 years ago

I know there is another closed issue #5 with exacly the same title and some proposed solutions. I have managed to solve this issue by combining those proposals but, since I have updated from 2.2.3 -> 2.5.0 I deal with a new issue. The problem now is that only one's schemas generated classes remain in the output package. It is like the missing one is generated but be deleted after that.

-My project gradle build files looks like this:

... gen-schema-v1.gradle gen-schema-v2.gradle build.gradle settings.gradle

-My build.gradle related schema-gen tasks look like this:

....
task genSchemaV1(type: GradleBuild) {
    doFirst {
        println 'Generating Schema v1'
    }
    buildFile = 'gen-schema-v1.gradle'
    tasks = ['xjc']
    startParameter.projectProperties = [jaxb_impl_version: "${project.jaxb_impl_version}"]
}

task genSchemaV2(type: GradleBuild) {
    doFirst {
        println 'Generating Schema v2'
    }
    buildFile = 'gen-schema-v2.gradle'
    tasks = ['xjc']
    startParameter.projectProperties = [jaxb_impl_version: "${project.jaxb_impl_version}"]
}

compileJava.dependsOn genSchemaV1, genSchemaV2

-My gen-schema-v1.gradle looks like this:

....
jaxb {
    // schema v1
    bindingsDir = "${project.rootDir}/src/main/resources/xsd/bindings"
    xsdDir = "${project.projectDir}/src/main/resources/xsd/v1"
    bindings = ["binding_schema_v1.xjb"]

    xjc {
        destinationDir = "${project.buildDir}/generated-sources/xjc"
        args = ["-verbose"]
    }
}

compileJava.dependsOn xjc

-My gen-schema-v2.gradle looks like this:

....
jaxb {
    // schema v2
    bindingsDir = "${project.rootDir}/src/main/resources/xsd/bindings"
    xsdDir = "${project.projectDir}/src/main/resources/xsd/v2"
    bindings = ["binding_schema_v2.xjb"]

    xjc {
        destinationDir = "${project.buildDir}/generated-sources/xjc"
        args = ["-verbose"]
    }
}

compileJava.dependsOn xjc