Skip to content

Instantly share code, notes, and snippets.

@nilsmagnus
Last active July 14, 2016 02:21
Show Gist options
  • Save nilsmagnus/4965921 to your computer and use it in GitHub Desktop.
Save nilsmagnus/4965921 to your computer and use it in GitHub Desktop.
WsdlToJava for simple projects. Time consuming if you have many wsdls, but good enough.
project.ext{
cxfVersion = '2.5.1'
generatedWsdlDir = file("build/generated-sources")
wsdlDir = file("wsdl")
wsdlsToGenerate =[
['-xjc', '-b', "$wsdlDir/serializable_binding.xml", "$wsdlDir/mywsdl1.wsdl.xml"],
['-xjc', '-b', "$wsdlDir/some_binding.xml", "$wsdlDir/mywsdl2.xml"],
['-xjc', '-b', "$wsdlDir/joda_binding.xml", "$wsdlDir/mywsdl3.wsdl.xml"],
// 55 more wsdls
]
}
dependencies {
compile "joda-time:joda-time:$jodatimeVersion"
compile "org.apache.cxf:cxf-tools:$cxfVersion",
"org.apache.cxf:cxf-tools-wsdlto-databinding-jaxb:$cxfVersion",
"org.apache.cxf:cxf-tools-wsdlto-frontend-jaxws:$cxfVersion",
"log4j:log4j:$log4jVersion"
}
task wsdl2Java() {
inputs.files wsdlDir.listFiles()
outputs.files generatedWsdlDir
doLast {
wsdlsToGenerate.each { wsdlFile ->
createJavaFromWsdl(wsdlFile, generatedWsdlDir)
}
}
}
def createJavaFromWsdl(arguments, destinationDir) {
arguments.add(arguments.size - 1, '-d')
arguments.add(arguments.size - 1, generatedWsdlDir)
println "Processing " + arguments[arguments.size - 1]
javaexec {
main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
classpath = configurations.runtime
args arguments
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment