Using jaxb2-annotate-plugin with Gradle XJC plugin

We are using this plugin to generate code from XSD and WSDL’s:

In addition to the normal code generation we need annotations added to the generated sources. I am trying to use the XJC plugin jaxb2-annotate-plugin to accomplish this.

The gradle XJC plugin has some vague documentation for loading XJC plugins here: GitHub - unbroken-dome/gradle-xjc-plugin: A Gradle plugin to run the XJC binding compiler during a build

Through that doc, some SO posts and other general searching I pieced together this build.gradle:

configurations {
xjcClasspath
}

dependencies {
xjcClasspath “org.jvnet.jaxb2_commons:jaxb2-basics-annotate:jar:1.0.3”
xjcClasspath “org.jvnet.jaxb2_commons:jaxb2-basics-tools:jar:0.8.1”
xjcClasspath “org.jvnet.jaxb2_commons:jaxb2-basics:1.11.1”
xjcClasspath “org.jvnet.annox:annox:1.0.1”
xjcClasspath “com.github.javaparser:javaparser-core:1.0.11”
xjcClasspath “commons-io:commons-io:jar:1.2”
xjcClasspath “commons-beanutils:commons-beanutils:1.7.0”
xjcClasspath “commons-logging:commons-logging:1.1.1”
xjcClasspath “org.apache.commons:commons-lang3:3.9”
}

On my xjcGenerate task config I am adding extraArgs = ["-Xannotate"] (this is supposed to activate the jaxb2-annotate-plugin for XJC).

However, no matter what I do I get the error:

Execution failed for task ‘:xjcGenerate’.
com.sun.tools.xjc.BadCommandLineException: unrecognized parameter -Xannotate

I assume the jaxb2-annotate-plugin for XJC isn’t getting loaded. I am wondering if someone has this working in their gradle build and can provide an example?