Hi. Sorry for reviving an old thread but I think I do have a nice concrete case where managing two class output folders causes trouble. Picture this:
- A project generates CXF web service clients and the generation process also relies on generating Model classes based on XMLBeans like so:
// Custom task to generate CXF Java classes from WSDL.
task wsdl2java(type: JavaExec) {
ext {
wsdlFile = 'src/main/resources/ath/btrans/xath.wsdl'
outputDir = project.ext.generatedSrcDir
}
inputs.file file(wsdlFile)
outputs.dir outputDir
main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
classpath = configurations.provided
args '-p', 'https.my.web.service.package'
args '-d', outputDir
args '-client'
args '-verbose'
args '-validate'
args '-wsdlLocation', 'classpath:my/wsdl/file.wsdl'
args wsdlFile
}
task xmlbean << {
ant.taskdef(name: 'xmlbean', classname: 'org.apache.xmlbeans.impl.tool.XMLBean', classpath: configurations.compile.asPath)
ant.xmlbean(srconly: true, srcgendir: project.ext.generatedSrcDir.absolutePath, classgendir: "$buildDir/classes/main") {
fileset(dir: 'src/main/resources/my/xml/schemas/dir', includes: '**/*.xsd **/*.xsdconfig')
}
}
The ‘xmlbean’ task avobe will place this peculiar class structure folder inside ‘$buildDir/classes/main’ containing an assortment of ‘.xsb’ files and a class named ‘TypeSystemHolder’, all of them generated by the latter task.
During unit test time, Eclipse will know that it can find any necessary class files inside the ‘bin’ folder. That even includes the model classes generated at , say, ‘my.xml.models’ defined inside an XMLBeans ‘.xsdconfig’ file because the source code was correctly placed inside ‘build/generated-src’ with this instruction:
project.ext.generatedSrcDir = file("$buildDir/generated-src")
What Eclipse doesn’t know is that XMLBeans also generated metadata classes which are necessary to construct instances of my model classes, which are only located at ‘$buildDir/classes/main’ and not in ‘bin’, which results in a runtime exception.
How could I deal with this issue in a sensible manner? Thanks!