diff --git a/build.gradle b/build.gradle index fd4f66bce77d99e541440f4dab7db85bc7c69806..cae83ec5f8ea923b8a2474f9c4cf39f63954a69d 100644 --- a/build.gradle +++ b/build.gradle @@ -227,6 +227,7 @@ project('spring-tx') { project('spring-oxm') { description = 'Spring Object/XML Marshalling' + apply from: 'oxm.gradle' dependencies { compile project(":spring-context") compile "commons-lang:commons-lang:2.5" @@ -238,10 +239,9 @@ project('spring-oxm') { testCompile "org.codehaus.jettison:jettison:1.0.1" testCompile "xmlunit:xmlunit:1.2" testCompile "xmlpull:xmlpull:1.1.3.4a" - // this is a workaround until we have xjc/etc generation plugged in - // in order for this to work, you must FIRST run `ant test` within the - // .oxm module. that will create/populate the target/test-classes dir - testCompile(files("target/test-classes")) + testCompile(files(genCastor.classesDir).builtBy(genCastor)) + testCompile(files(genJaxb.classesDir).builtBy(genJaxb)) + testCompile(files(genXmlbeans.classesDir).builtBy(genXmlbeans)) } } diff --git a/org.springframework.oxm/build.xml b/org.springframework.oxm/build.xml deleted file mode 100644 index f1acbfae3b6b39a3a090e6f263c5aad172708808..0000000000000000000000000000000000000000 --- a/org.springframework.oxm/build.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.springframework.oxm/oxm.gradle b/org.springframework.oxm/oxm.gradle new file mode 100644 index 0000000000000000000000000000000000000000..c8dceea4a342499b953fbbd86ed9199294836d84 --- /dev/null +++ b/org.springframework.oxm/oxm.gradle @@ -0,0 +1,130 @@ +configurations { + castor + xjc + xmlbeans + jibx +} +dependencies { + castor "org.codehaus.castor:castor-anttasks:1.2" + castor "velocity:velocity:1.5" + xjc "com.sun.xml:com.springsource.com.sun.tools.xjc:2.1.7" + xmlbeans "org.apache.xmlbeans:com.springsource.org.apache.xmlbeans:2.4.0" + jibx "org.jibx:jibx-bind:1.1.5" + jibx "bcel:bcel:5.1" +} + +genSourcesDir = "${buildDir}/generated-sources" +flightSchema = "${projectDir}/src/test/resources/org/springframework/oxm/flight.xsd" + +task genCastor { + orderSchema = "${projectDir}/src/test/resources/org/springframework/oxm/order.xsd" + castorBuilderProperties = "${projectDir}/src/test/castor/castorbuilder.properties" + + sourcesDir = "${genSourcesDir}/castor" + classesDir = "${buildDir}/classes/castor" + + inputs.files flightSchema, orderSchema, castorBuilderProperties + outputs.dir classesDir + + doLast() { + project.ant { + taskdef name: "castor", classname: "org.castor.anttask.CastorCodeGenTask", + classpath: configurations.castor.asPath + mkdir(dir: sourcesDir) + mkdir(dir: classesDir) + + castor(types: "j2", warnings: false, file: flightSchema, todir: sourcesDir, + package: "org.springframework.oxm.castor", properties: castorBuilderProperties) + + castor(types: "j2", warnings: false, file: orderSchema, todir: sourcesDir, + package: "org.springframework.oxm.castor", properties: castorBuilderProperties) + + javac(destdir: classesDir, source: 1.5, target: 1.5, debug: true, + debugLevel: "lines,vars,source", classpath: configurations.castor.asPath) { + src(path: sourcesDir) + include(name: "**/*.java") + include(name: "*.java") + } + + copy(todir: classesDir) { + fileset(dir: sourcesDir, erroronmissingdir: false) { + exclude(name: "**/*.java") + } + } + } + } +} + +task genJaxb { + sourcesDir = "${genSourcesDir}/jaxb" + classesDir = "${buildDir}/classes/jaxb" + + inputs.files flightSchema + outputs.dir classesDir + + doLast() { + project.ant { + taskdef name: "xjc", classname: "com.sun.tools.xjc.XJCTask", + classpath: configurations.xjc.asPath + mkdir(dir: sourcesDir) + mkdir(dir: classesDir) + + xjc(destdir: sourcesDir, schema: flightSchema, + package: "org.springframework.oxm.jaxb.test") { + produces(dir: sourcesDir, includes: "**/*.java") + } + + javac(destdir: classesDir, source: 1.5, target: 1.5, debug: true, + debugLevel: "lines,vars,source", + classpath: configurations.castor.asPath) { + src(path: sourcesDir) + include(name: "**/*.java") + include(name: "*.java") + } + + copy(todir: classesDir) { + fileset(dir: sourcesDir, erroronmissingdir: false) { + exclude(name: "**/*.java") + } + } + } + } +} + +task genXmlbeans { + classesDir = "${buildDir}/classes/xmlbeans" + + inputs.files flightSchema + outputs.dir classesDir + + doLast() { + project.ant { + taskdef name: "xmlbeans", + classname: "org.apache.xmlbeans.impl.tool.XMLBean", + classpath: configurations.xmlbeans.asPath + + xmlbeans(classgendir: classesDir, schema: flightSchema, + compiler: "modern", verbose: "false", + classpath: configurations.xmlbeans.asPath) + } + } +} + +// add jibx binding to the normal test compilation process +compileTestJava { + bindingXml = "${projectDir}/src/test/resources/org/springframework/oxm/jibx/binding.xml" + + doLast() { + project.ant { + taskdef(name: "jibx", + classname: "org.jibx.binding.ant.CompileTask", + classpath: configurations.jibx.asPath) + + jibx(verbose: true, load: true, binding: bindingXml) { + classpathset(dir: sourceSets.test.output.classesDir) { + include(name: "**/jibx/**/*") + } + } + } + } +} diff --git a/org.springframework.oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java b/org.springframework.oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java index 70bd3375dfeeaecab16134b1ca08663c7190ab01..42c25f9b316ee7e2130a984230717f1b16d19d5e 100644 --- a/org.springframework.oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java +++ b/org.springframework.oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java @@ -29,7 +29,12 @@ import static org.custommonkey.xmlunit.XMLAssert.*; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -@org.junit.Ignore // TODO fix this issue https://gist.github.com/1174579 +/** + * @author Arjen Poutsma + * + * NOTE: These tests fail under Eclipse/IDEA because JiBX binding does + * not occur by default. The Gradle build should succeed, however. + */ public class JibxMarshallerTests extends AbstractMarshallerTests { @Override diff --git a/org.springframework.oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java b/org.springframework.oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java index a6a8315cdfd6e54492079d85b7947a0c725bdfad..3b19ec620c9ba17a3aac1ff9b89d094456bfc76a 100644 --- a/org.springframework.oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java +++ b/org.springframework.oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java @@ -25,8 +25,10 @@ import org.springframework.oxm.Unmarshaller; /** * @author Arjen Poutsma + * + * NOTE: These tests fail under Eclipse/IDEA because JiBX binding does + * not occur by default. The Gradle build should succeed, however. */ -@org.junit.Ignore // TODO fix this issue https://gist.github.com/1174575 public class JibxUnmarshallerTests extends AbstractUnmarshallerTests { @Override