Browse Source
- Generate castor test classes with genCastor task - Generate xmlbeans test classes with genXmlbeans task - Generate JAXB2 test classes with genJaxb task - Generate JiBX bindings by extending existing compileTestJava task Test classes are written into their own dedicated output folders and tied into the spring-oxm classpath using the files(...).builtBy(...) directive. Incremental build works as expected across all of these customizations. `gradle eclipse` and `gradle idea` generate correct .project / .iml metadata respectively, i.e., these special cases do not cause a problem in the IDE (as they used to prior to the move to Gradle).pull/22/head
5 changed files with 143 additions and 111 deletions
@ -1,105 +0,0 @@
@@ -1,105 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project name="org.springframework.oxm" xmlns:ivy="antlib:org.apache.ivy.ant"> |
||||
<property file="${basedir}/../build.properties"/> |
||||
<property file="${basedir}/../build.versions"/> |
||||
<import file="${basedir}/../build-spring-framework/package-bundle.xml"/> |
||||
<import file="${basedir}/../spring-build/standard/default.xml"/> |
||||
|
||||
<property name="flightSchema" value="${basedir}/src/test/resources/org/springframework/oxm/flight.xsd"/> |
||||
<property name="orderSchema" value="${basedir}/src/test/resources/org/springframework/oxm/order.xsd"/> |
||||
<property name="castorBuilderProperties" value="${basedir}/src/test/castor/castorbuilder.properties"/> |
||||
<property name="test.castor.dir" value="${target.dir}/castor/test"/> |
||||
<property name="test.jaxb.dir" value="${target.dir}/jaxb/test"/> |
||||
|
||||
<macrodef name="test-compile"> |
||||
<attribute name="classpath.id"/> |
||||
<attribute name="input.dir"/> |
||||
<attribute name="output.dir"/> |
||||
<attribute name="resources.dir"/> |
||||
<sequential> |
||||
<delete quiet="true" dir="@{output.dir}"/> |
||||
<mkdir dir="@{output.dir}"/> |
||||
|
||||
<!-- Castor --> |
||||
<ivy:cachepath resolveId="castor.classpath" pathid="castor.classpath" organisation="org.codehaus.castor" |
||||
module="com.springsource.org.castor.anttask" revision="1.2.0" conf="runtime" type="jar" |
||||
inline="true" log="download-only"/> |
||||
<taskdef name="castor" classname="org.castor.anttask.CastorCodeGenTask" classpathref="castor.classpath"/> |
||||
|
||||
<delete quiet="true" dir="${test.castor.dir}" /> |
||||
<mkdir dir="${test.castor.dir}" /> |
||||
|
||||
<castor types="j2" warnings="false" file="${flightSchema}" todir="${test.castor.dir}" |
||||
package="org.springframework.oxm.castor" properties="${castorBuilderProperties}"/> |
||||
<castor types="j2" warnings="false" file="${orderSchema}" todir="${test.castor.dir}" |
||||
package="org.springframework.oxm.castor" properties="${castorBuilderProperties}"/> |
||||
<do-compile classpath.id="@{classpath.id}" input.dir="${test.castor.dir}" output.dir="@{output.dir}" |
||||
resources.dir="${test.castor.dir}"/> |
||||
<copy todir="@{output.dir}"> |
||||
<fileset dir="${test.castor.dir}"> |
||||
<exclude name="**/*.java"/> |
||||
</fileset> |
||||
</copy> |
||||
|
||||
<!-- JAXB2 --> |
||||
<ivy:cachepath resolveId="jaxb.classpath" pathid="jaxb.classpath" organisation="com.sun.xml" |
||||
module="com.springsource.com.sun.tools.xjc" revision="2.1.7" conf="runtime" type="jar" inline="true" |
||||
log="download-only"/> |
||||
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask" classpathref="jaxb.classpath"/> |
||||
|
||||
<delete quiet="true" dir="${test.jaxb.dir}" /> |
||||
<mkdir dir="${test.jaxb.dir}" /> |
||||
|
||||
<xjc destdir="${test.jaxb.dir}" package="org.springframework.oxm.jaxb.test" schema="${flightSchema}"> |
||||
<produces dir="${test.jaxb.dir}" includes="**/*.java"/> |
||||
</xjc> |
||||
<do-compile classpath.id="@{classpath.id}" input.dir="${test.jaxb.dir}" output.dir="@{output.dir}" |
||||
resources.dir="${test.jaxb.dir}"/> |
||||
|
||||
<!-- Standard Compile --> |
||||
<test-pre-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}" |
||||
resources.dir="@{resources.dir}"/> |
||||
<do-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}" |
||||
resources.dir="@{resources.dir}"/> |
||||
<test-post-compile classpath.id="@{classpath.id}" input.dir="@{input.dir}" output.dir="@{output.dir}" |
||||
resources.dir="@{resources.dir}"/> |
||||
</sequential> |
||||
</macrodef> |
||||
|
||||
<macrodef name="test-pre-compile"> |
||||
<attribute name="classpath.id"/> |
||||
<attribute name="input.dir"/> |
||||
<attribute name="output.dir"/> |
||||
<attribute name="resources.dir"/> |
||||
<sequential> |
||||
<!-- XMLBeans --> |
||||
<ivy:cachepath resolveId="xmlbeans.classpath" pathid="xmlbeans.classpath" organisation="org.apache.xmlbeans" |
||||
module="com.springsource.org.apache.xmlbeans" revision="2.4.0" |
||||
conf="runtime" type="jar" inline="true" log="download-only"/> |
||||
<taskdef name="xmlbeans" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpathref="xmlbeans.classpath"/> |
||||
<xmlbeans schema="${flightSchema}" classgendir="@{output.dir}" classpathref="xmlbeans.classpath" compiler="modern" |
||||
verbose="false"/> |
||||
</sequential> |
||||
|
||||
</macrodef> |
||||
|
||||
<macrodef name="test-post-compile"> |
||||
<attribute name="classpath.id"/> |
||||
<attribute name="input.dir"/> |
||||
<attribute name="output.dir"/> |
||||
<attribute name="resources.dir"/> |
||||
<sequential> |
||||
<!-- JiBX --> |
||||
<ivy:cachepath resolveId="jibx.classpath" pathid="jibx.classpath" organisation="net.sourceforge.jibx" |
||||
module="com.springsource.org.jibx.binding" revision="1.1.5" |
||||
conf="runtime" type="jar" inline="true" log="download-only"/> |
||||
<taskdef name="jibx-bind" classname="org.jibx.binding.ant.CompileTask" classpathref="jibx.classpath"/> |
||||
<jibx-bind load="true" binding="${basedir}/src/test/resources/org/springframework/oxm/jibx/binding.xml"> |
||||
<classpathset dir="@{output.dir}"> |
||||
<include name="**/jibx/**/*"/> |
||||
</classpathset> |
||||
</jibx-bind> |
||||
</sequential> |
||||
</macrodef> |
||||
|
||||
</project> |
@ -0,0 +1,130 @@
@@ -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/**/*") |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue