Hello, I’m using an ant task to generate JAXB classes from an xsd. It works
The problem comes if if want to run the same task twice with a different configuration. What I tryed is to define twice the same task but with a different config like:
task genJaxb {
ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
ext.classesDir = "${buildDir}/classes/jaxb"
ext.schema = "${projectDir}/src/main/webapp/WEB-INF/wsdl/RegistrySchema.xsd"
inputs.files schema
outputs.dir classesDir
doLast() {
project.ant {
taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
classpath: configurations.jaxb.asPath
mkdir(dir: sourcesDir)
mkdir(dir: classesDir)
xjc(destdir: sourcesDir, schema: schema,
package: "com.proveance.ws.registry.domain") {
produces(dir: sourcesDir, includes: "**/*.java")
}
javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true,
debugLevel: "lines,vars,source",
classpath: configurations.jaxb.asPath) {
src(path: sourcesDir)
include(name: "**/*.java")
include(name: "*.java")
}
copy(todir: classesDir) {
fileset(dir: sourcesDir, erroronmissingdir: false) { exclude(name: "**/*.java") }
}
}
}
}
task genJaxbCIM {
ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
ext.classesDir = "${buildDir}/classes/jaxb"
ext.schema = "${projectDir}/src/main/resources/com/proveance/ws/ServiceIndividu.xsd"
inputs.files schema
outputs.dir classesDir
doLast() {
project.ant {
taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
classpath: configurations.jaxb.asPath
mkdir(dir: sourcesDir)
mkdir(dir: classesDir)
xjc(destdir: sourcesDir, schema: schema,
package: "com.proveance.ws.mutcim.domain") {
produces(dir: sourcesDir, includes: "**/*.java")
}
javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true,
debugLevel: "lines,vars,source",
classpath: configurations.jaxb.asPath) {
src(path: sourcesDir)
include(name: "**/*.java")
include(name: "*.java")
}
copy(todir: classesDir) {
fileset(dir: sourcesDir, erroronmissingdir: false) { exclude(name: "**/*.java") }
}
}
}
}
but only one task produces something, the other one gets executed but produces no output. If I run gradle genJaxb genJaxbCIM only the first one gets executed. If then I try to run only gradle genJaxbCIM it still produces no output until I issue a gradle build. It seems that the execution of the 2 ant tasks is exclusive… Any hint? Thanks.