I have a CXF JAX-RS app being built with Maven. I\'m working on converting it to Gradle, but using the Ant XJC task.
The current build uses a couple of extensions,
Kudos to dma_k, but a working gradle solution was never provided. After some experimentation, this is what worked for me:
def xjcGeneratedSourcesDir = "$buildDir/generated-sources/xjc"
configurations {
jaxb
xjc
}
sourceSets {
main {
java.srcDir xjcGeneratedSourcesDir
}
}
dependencies {
jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.11'
jaxb 'com.sun.xml.bind:jaxb-core:2.2.11'
jaxb 'com.sun.xml.bind:jaxb-impl:2.2.11'
jaxb 'javax.xml.bind:jaxb-api:2.2.11'
xjc "com.github.jaxb-xew-plugin:jaxb-xew-plugin:1.4"
xjc "net.java.dev.jaxb2-commons:jaxb-fluent-api:2.1.8"
// etc.
}
task wsdl2java << {
file( xjcGeneratedSourcesDir ).mkdirs()
ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask',
classpath: configurations.jaxb.asPath)
ant.xjc(destdir: xjcGeneratedSourcesDir,
package: "com.localhost.jaxb", extension: true) {
schema(dir: "src/main/resources/schema", includes: "*.xsd")
classpath(path: configurations.xjc.asPath)
arg(line: "-Xxew")
arg(line: "-Xxew:summary $buildDir/xew-summary.txt")
arg(line: "-Xxew:instantiate lazy")
arg(line: "-Xfluent-api")
}
}
compileJava.dependsOn wsdl2java