configurations { castor xjc xmlbeans jibx } dependencies { castor "org.codehaus.castor:castor-anttasks:1.4.0" castor "org.apache.velocity:velocity:1.7" xjc "com.sun.xml.bind:jaxb-xjc:2.1.17" xmlbeans "org.apache.xmlbeans:xmlbeans:2.6.0" jibx "org.jibx:jibx-bind:1.2.6" jibx "bcel:bcel:5.1" } ext.genSourcesDir = "${buildDir}/generated-sources" ext.flightSchema = "${projectDir}/src/test/resources/org/springframework/oxm/flight.xsd" task genCastor { def orderSchema = "${projectDir}/src/test/resources/org/springframework/oxm/order.xsd" def castorBuilderProperties = "${projectDir}/src/test/castor/castorbuilder.properties" ext.sourcesDir = "${genSourcesDir}/castor" ext.classesDir = "${buildDir}/classes/castor" inputs.files flightSchema, orderSchema, castorBuilderProperties outputs.dir classesDir doLast() { project.ant { taskdef name: "castor", classname: "org.castor.anttask.CastorCodeGenTask", classpath: configurations.castor.asPath mkdir(dir: sourcesDir) mkdir(dir: classesDir) castor(types: "j2", warnings: false, file: flightSchema, todir: sourcesDir, package: "org.springframework.oxm.castor", properties: castorBuilderProperties) castor(types: "j2", warnings: false, file: orderSchema, todir: sourcesDir, package: "org.springframework.oxm.castor", properties: castorBuilderProperties) javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true, debugLevel: "lines,vars,source", classpath: configurations.castor.asPath) { src(path: sourcesDir) include(name: "**/*.java") include(name: "*.java") } copy(todir: classesDir) { fileset(dir: sourcesDir, erroronmissingdir: false) { exclude(name: "**/*.java") } } } } } task genJaxb { ext.sourcesDir = "${genSourcesDir}/jaxb" ext.classesDir = "${buildDir}/classes/jaxb" inputs.files flightSchema outputs.dir classesDir doLast() { project.ant { taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask", classpath: configurations.xjc.asPath mkdir(dir: sourcesDir) mkdir(dir: classesDir) xjc(destdir: sourcesDir, schema: flightSchema, package: "org.springframework.oxm.jaxb.test") { produces(dir: sourcesDir, includes: "**/*.java") } javac(destdir: classesDir, source: 1.6, target: 1.6, debug: true, debugLevel: "lines,vars,source", classpath: configurations.castor.asPath) { src(path: sourcesDir) include(name: "**/*.java") include(name: "*.java") } copy(todir: classesDir) { fileset(dir: sourcesDir, erroronmissingdir: false) { exclude(name: "**/*.java") } } } } } task genXmlbeans { ext.classesDir = "${buildDir}/classes/xmlbeans" inputs.files flightSchema outputs.dir classesDir doLast() { project.ant { taskdef name: "xmlbeans", classname: "org.apache.xmlbeans.impl.tool.XMLBean", classpath: configurations.xmlbeans.asPath xmlbeans(classgendir: classesDir, schema: flightSchema, compiler: "modern", verbose: "false", classpath: configurations.xmlbeans.asPath) } } } // add jibx binding to the normal test compilation process // INCOMPATIBLE WITH OPENJDK 8 b89+ def jibxEnabled = project.properties.get("testGroups")?.toLowerCase()?.split(",")?.contains("custom_compilation") if (jibxEnabled) { compileTestJava { def bindingXml = "${projectDir}/src/test/resources/org/springframework/oxm/jibx/binding.xml" doLast() { project.ant { taskdef(name: "jibx", classname: "org.jibx.binding.ant.CompileTask", classpath: configurations.jibx.asPath) jibx(verbose: true, load: true, binding: bindingXml) { classpathset(dir: sourceSets.test.output.classesDir) { include(name: "**/jibx/**/*") } } } } } }