Created
October 8, 2014 08:13
-
-
Save breskeby/b829eca7c1a37e5e4e05 to your computer and use it in GitHub Desktop.
simple jaxb source generation with gradle
This file contains hidden or 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
apply plugin:'idea' | |
apply plugin:'groovy' | |
repositories{ | |
jcenter() | |
} | |
configurations{ | |
jaxb | |
} | |
dependencies{ | |
compile "org.codehaus.groovy:groovy-all:2.3.7" | |
jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.7-b41' | |
jaxb 'com.sun.xml.bind:jaxb-impl:2.2.7-b41' | |
jaxb 'javax.xml.bind:jaxb-api:2.2.7' | |
} | |
task generateJaxb { | |
ext.destDir = new File(buildDir, 'generated') | |
ext.inputDir = new File(projectDir, 'src/xsd') | |
outputs.dir(destDir) | |
inputs.dir(inputDir) | |
doLast{ | |
destDir.mkdirs() | |
ant.taskdef(name: 'xjc', classname:"com.sun.tools.xjc.XJCTask", classpath: configurations.jaxb.asPath) | |
ant.xjc(destdir: destDir.absolutePath, package: 'org.acme.demo.model.generated') { | |
schema(dir:inputDir.absolutePath, includes: '*.xsd') | |
} | |
} | |
} | |
sourceSets { | |
main { | |
groovy{ | |
srcDir generateJaxb.destDir | |
} | |
} | |
} | |
ideaModule.dependsOn generateJaxb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment