I want to generate java class from WSDL file using spring gradle. I have already done for 1 wsdl file. But in future it might be around 200 WSDLs. Is there a beter way to generate WSDLs separately and place the java classes in different packages. say each package named with WSDL file name? Please find below my build.gradle. Is is possible to make the Ant Task common and call individually for each WSDL file separately just by passing WSDL name, package name?
// tag::wsdl[]
task genJaxb {
ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
ext.classesDir = "${buildDir}/classes/jaxb"
//ext.schema = "http://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl"
ext.schema = "${projectDir}/src/main/resources/wsdl.test1"
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: "wsdl.test1") {
arg(value: "-wsdl")
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")
}
}
}
}
}
// end::wsdl[]
I use wsdl2java gradle plugin to generate Java classes from multiple wsdl/xsd files. Works like a charm.