1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- configurations {
- jaxb
- }
- group = 'ru.sudrf'
- version = '0.1'
- buildDir = 'target'
- apply plugin: 'java'
- sourceCompatibility = '1.8'
- targetCompatibility = '1.8'
- compileJava.options.encoding = 'UTF-8'
- tasks.withType(JavaCompile) {
- options.encoding = 'UTF-8'
- }
- repositories {
- mavenCentral()
- }
- sourceSets.main.java.srcDirs "${buildDir}/generated-sources/jaxb"
- task genJaxb {
- ext.sourcesDir = "${buildDir}/generated-sources/jaxb"
- ext.classesDir = "${buildDir}/classes/jaxb"
- outputs.dir classesDir
- doLast() {
- project.ant {
- mkdir(dir: sourcesDir)
- mkdir(dir: classesDir)
- taskdef name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.jaxb.asPath
- xjc(destdir: sourcesDir, binding: "${projectDir}/src/main/resources/binding.xml") {
- schema(dir: "${projectDir}/src/main/resources/xsd", includes: '**/*.xsd')
- arg(value: "-extension")
- arg(value: "-encoding")
- arg(value: "UTF-8")
- produces(dir: sourcesDir, includes: '**/*.java')
- }
- javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true,
- debugLevel: 'lines,vars,source',
- includeantruntime: false,
- classpath: configurations.jaxb.asPath) {
- src(path: sourcesDir)
- include(name: '**/*.java')
- include(name: '*.java')
- }
- copy(todir: classesDir) {
- fileset(dir: sourcesDir, erroronmissingdir: false) {
- exclude(name: '**/*.java')
- }
- }
- }
- }
- }
- dependencies {
- compile(files(genJaxb.classesDir).builtBy(genJaxb))
- jaxb (
- 'com.sun.xml.bind:jaxb-xjc:2.3.9',
- 'com.sun.xml.bind:jaxb-impl:2.3.9',
- 'org.glassfish.jaxb:jaxb-runtime:2.3.9'
- )
- }
- compileJava.dependsOn 'genJaxb'
- jar {
- from genJaxb.classesDir
- }
- java {
- withSourcesJar()
- }
|