I got a Quarkus microservice, and I'm using an XJC Gradle task for generating java classes out of XSD schemas like this: (It's based on the second answer of this post: How to generate jaxb classes from xsd using gradle, jaxb and xjc, classes should have XmlRootElement
// The folter to put the generated XJC Java classes in
def generatedXjcClassesDir = "src/generated/java"
sourceSets {
generated {
java.srcDir generatedXjcClassesDir
}
}
dependencies {
// Also compile the generated XJC Java classes
compile sourceSets.generated.output
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.3'
generatedCompile 'org.glassfish.jaxb:jaxb-runtime:2.3.3'
}
/**
* XJC stuff
*
**/
configurations {
// Having a separate configuration for XJC plugin only
xjc
}
dependencies {
xjc 'org.glassfish.jaxb:jaxb-xjc:2.3.3'
}
def xjcTask(taskName, schema, pkg, dest) {
// Create (if not existing yet) the destination directory
file(dest).mkdirs()
// Calling XJCFacade which is the entry point of the XJC JAR
tasks.create(name: taskName, type: JavaExec) {
classpath configurations.xjc
main 'com.sun.tools.xjc.XJCFacade'
// To explore available args, download the XJC JAR manually and run java -jar jaxb-xjc.jar --help
args schema, "-p", pkg, "-d", dest
}
//
compileGeneratedJava.dependsOn tasks.getByName(taskName)
}
xjcTask('xjcSchema1', 'src/main/xsd/SCL.xsd', 'org.lfenergy.compas', generatedXjcClassesDir)
It does work pretty well, all java classes are being generated and putted into the src/generated/java folder.
But the quarkus application doesn't compile correctly, because it gives the following error:
> Task :quarkusGenerateCode FAILED
Caching disabled for task ':quarkusGenerateCode' because:
Build cache is disabled
Task ':quarkusGenerateCode' is not up-to-date because:
Task has not declared any outputs despite executing actions.
preparing quarkus application
:quarkusGenerateCode (Thread[Execution worker for ':',5,main]) completed. Took 1.487 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':quarkusGenerateCode'.
> Error while reading file as JAR: /Users/rob/Code/CoMPAS/compas-cim-mapping/build/resources/generated
I tried search for the error, but my Quarkus knowledge lacks here. Can somebody help me out? :)