Skip to content

Instantly share code, notes, and snippets.

@jurberg
Created November 28, 2012 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jurberg/4158702 to your computer and use it in GitHub Desktop.
Save jurberg/4158702 to your computer and use it in GitHub Desktop.
Groovy script to generate JAXB classes from an XSD
// Add the following to BuildConfig.groovy:
// build('com.sun.xml.bind:jaxb-xjc:2.1')
// build('com.sun.xml.bind:jaxb-impl:2.1')
target('generateSources': "Generate JAXB classes from a schema") {
def classpath = grailsSettings
.getBuildDependencies()
.join(System.getProperty("path.separator"))
Ant.taskdef(name: "xjc",
classname: "com.sun.tools.xjc.XJCTask",
classpath: classpath)
Ant.xjc(schema: "etc/schema/books.xsd",
destDir: "src/java",
'package': "com.microsoft.books")
}
@jschloer
Copy link

This was helpful. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment