Created
November 14, 2012 09:07
-
-
Save aphexmunky/4071113 to your computer and use it in GitHub Desktop.
JAXB task in gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def generatedResources = "src/main/generated-sources" | |
task jaxb(){ | |
description 'Converts xsds to classes' | |
def jaxbTargetDir = file( generatedResources ) | |
jaxbTargetDir.deleteDir() | |
doLast { | |
jaxbTargetDir.mkdirs() | |
ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.jaxb.asPath) | |
ant.jaxbTargetDir = jaxbTargetDir | |
ant.xjc(destdir: '${jaxbTargetDir}', package: 'com.thehutgroup.xml.representation') { | |
schema(dir:'XSD/Representation', includes: '*.xsd') | |
} | |
ant.xjc(destdir: '${jaxbTargetDir}', package: 'com.thehutgroup.xml.event') { | |
schema(dir:'XSD/Event', includes: '*.xsd') | |
} | |
} | |
} | |
task generateSources(dependsOn: jaxb) { | |
description 'generates the resources defined by the external xsd\'s' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found your blog post while searching for a fix for the compile issue. I'll link it here in case anyone else runs into it:
http://squidoop.blogspot.com/2012/11/jaxb-generation-using-gradle.html