When it comes to building a SOAP web services client using Spring, the guide suggests using an Ant based gradle build task to generate the required classes. However, if you are using Jib to produce a Docker container, you may find that the generated classes are not in the container, and there are few guides as to how to get them in there.
It looks something like this:
... task genJaxb { ext.sourcesDir = "${buildDir}/generated-sources/jaxb" ext.classesDir = "${buildDir}/classes/jaxb" ext.schema = "http://localhost:8080/ws/countries.wsdl" outputs.dir classesDir doLast() { project.ant { taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask", classpath: configurations.jaxb.asPath mkdir(dir: sourcesDir) mkdir(dir: classesDir) xjc(destdir: sourcesDir, schema: schema, package: "com.example.consumingwebservice.wsdl") { arg(value: "-wsdl") produces(dir: sourcesDir, includes: "**/*.java") } javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true, debugLevel: "lines,vars,source", classpath: configurations.jaxb.asPath) { src(path: sourcesDir) include(name: "**/*.java") include(name: "*.java") } copy(todir: classesDir) { fileset(dir: sourcesDir, erroronmissingdir: false) { exclude(name: "**/*.java") } } } } } ... The crux of the issue is getting the generated classes onto the main source set so that Jib will package them up. I’m not a Gradle expert, so while there may be a way to make this happen with this setup, the neater solution appeared to be to us the XJC Gradle Plugin which takes care of a lot of this automatically.
...