spring-oxm.gradle 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. description = "Spring Object/XML Marshalling"
  2. configurations {
  3. jibx
  4. xjc
  5. }
  6. dependencies {
  7. jibx "org.jibx:jibx-bind:1.3.3"
  8. jibx "org.apache.bcel:bcel:6.0"
  9. xjc "javax.xml.bind:jaxb-api:2.3.1"
  10. xjc "com.sun.xml.bind:jaxb-core:2.3.0.1"
  11. xjc "com.sun.xml.bind:jaxb-impl:2.3.0.1"
  12. xjc "com.sun.xml.bind:jaxb-xjc:2.3.1"
  13. xjc "com.sun.activation:javax.activation:1.2.0"
  14. }
  15. ext.genSourcesDir = "${buildDir}/generated-sources"
  16. ext.flightSchema = "${projectDir}/src/test/resources/org/springframework/oxm/flight.xsd"
  17. task genJaxb {
  18. ext.sourcesDir = "${genSourcesDir}/jaxb"
  19. ext.classesDir = "${buildDir}/classes/jaxb"
  20. inputs.files(flightSchema).withPathSensitivity(PathSensitivity.RELATIVE)
  21. outputs.dir classesDir
  22. doLast() {
  23. project.ant {
  24. taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask",
  25. classpath: configurations.xjc.asPath
  26. mkdir(dir: sourcesDir)
  27. mkdir(dir: classesDir)
  28. xjc(destdir: sourcesDir, schema: flightSchema,
  29. package: "org.springframework.oxm.jaxb.test") {
  30. produces(dir: sourcesDir, includes: "**/*.java")
  31. }
  32. javac(destdir: classesDir, source: 1.8, target: 1.8, debug: true,
  33. debugLevel: "lines,vars,source",
  34. classpath: configurations.xjc.asPath) {
  35. src(path: sourcesDir)
  36. include(name: "**/*.java")
  37. include(name: "*.java")
  38. }
  39. copy(todir: classesDir) {
  40. fileset(dir: sourcesDir, erroronmissingdir: false) {
  41. exclude(name: "**/*.java")
  42. }
  43. }
  44. }
  45. }
  46. }
  47. dependencies {
  48. compile(project(":spring-beans"))
  49. compile(project(":spring-core"))
  50. optional("javax.xml.bind:jaxb-api")
  51. optional("javax.activation:javax.activation-api")
  52. optional("com.thoughtworks.xstream:xstream")
  53. optional("org.jibx:jibx-run")
  54. testCompile(project(":spring-context"))
  55. testCompile(testFixtures(project(":spring-core")))
  56. testCompile("org.ogce:xpp3")
  57. testCompile("org.codehaus.jettison:jettison") {
  58. exclude group: "stax", module: "stax-api"
  59. }
  60. testCompile(files(genJaxb.classesDir).builtBy(genJaxb))
  61. testCompile("org.xmlunit:xmlunit-assertj")
  62. testCompile("org.xmlunit:xmlunit-matchers")
  63. testRuntime("com.sun.xml.bind:jaxb-core")
  64. testRuntime("com.sun.xml.bind:jaxb-impl")
  65. }
  66. // JiBX compiler is currently not compatible with JDK 9+.
  67. // If customJavaHome has been set, we assume the custom JDK version is 9+.
  68. if ((JavaVersion.current() == JavaVersion.VERSION_1_8) && !System.getProperty("customJavaSourceVersion")) {
  69. compileTestJava {
  70. def bindingXml = "${projectDir}/src/test/resources/org/springframework/oxm/jibx/binding.xml"
  71. doLast() {
  72. project.ant {
  73. taskdef(name: "jibx",
  74. classname: "org.jibx.binding.ant.CompileTask",
  75. classpath: configurations.jibx.asPath)
  76. jibx(verbose: false, load: true, binding: bindingXml) {
  77. classpathset(dir: sourceSets.test.java.outputDir) {
  78. include(name: "**/jibx/**/*")
  79. }
  80. }
  81. }
  82. }
  83. }
  84. }