Hi everyone,
Here’s my problem: I have a big and deep gradle multiproject build that contains lots of WSDL interface definitions. I want to ensure the validity of all wsdl files in every project. To do so, I use the JAX-WS wsimport ant task for generating bindings. This task fails if the wsdl / xsd files contain errors.
configurations {
wsImport
}
dependencies {
wsImport (group: 'com.sun.xml.ws', name: 'jaxws-tools', version: '2.1.4')
}
task validateWsdl(dependsOn: otherTask) {
ext.generatedWsdlDir = file("${project.buildDir}/tmp/wsimport/")
doLast {
ant.taskdef(name: 'wsimport',
classname: 'com.sun.tools.ws.ant.WsImport',
classpath: configurations.wsImport.asPath)
otherTask.outputs.files.asFileTree.matching({include '**/*.wsdl'}).each { wsdlFile ->
delete(generatedWsdlDir)
mkdir(generatedWsdlDir)
try {
ant.wsimport(keep: false,
destdir: generatedWsdlDir,
wsdl: wsdlFile,
package: 'mypackage.wsdlvalidate',
verbose: false,
fork: false,
xendorsed: true,
xnocompile: true)
} catch (Exception e) {
throw new RuntimeException("Error validating WSDL file: ${wsdlFile} : ${e.message}", e)
}
delete(generatedWsdlDir)
}
}
}
This works wonderfully on a single project. When I run it from the root project, however, it fails with: java.lang.OutOfMemoryError: PermGen space. The obvious solution would be to specify “fork: true”. Doing this helps, indeed, but suppresses all console output from the ant task. There are, however, some warnings it outputs on the console, that I want to see in the build log.
Is it possible to achieve this by either fixing what causes the OOM or redirecting the console output from the forked process to the main build process?
Thanks in advance, Mike