I need to migrate a maven project to gradle. The maven project uses the maven-jaxb2-plugin
like this (version for the plugin is set in a root pom.xml
):
<plugin>
<groupId>...</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>package for generated classes</generatePackage>
<schemaDirectory>directory containing XSD files</schemaDirectory>
<includeSchemas>
<includeSchema>XSD file name</includeSchema>
<includeSchema>XSD file name</includeSchema>
...
</includeSchemas>
<strict>true</strict>
<verbose>true</verbose>
<extension>true</extension>
</configuration>
<plugin>
So, I wanted to achieve the same functionality in gradle, and this is what I have:
plugins {
id "com.github.jacobono.jaxb" version "1.3.5"
}
dependencies {
jaxb "org.glassfish.jaxb:jaxb-runtime:2.2.11"
jaxb "org.glassfish.jaxb:jaxb-xjc:2.2.11"
}
jaxb {
xsdDir = "directory containing XSD files"
xjc {
taskClassname = "com.sun.tools.xjc.XJC2Task"
generatedPackage = "package for generated classes"
}
}
compileJava.dependsOn xjc
This project is part of a multi-project build with dependencies on other projects etc., but I don't think those are relevant.
Am I on the right track?? I'm asking because the behavior doesn't seem to be the same when I do mvn clean install
and gradle clean build
Question:
- Is there a way to specify the XSD file names we want to use in gradle (as we do using
includeSchema
in maven)?
My problem: