BCG | de0b4b5 | 2015-12-28 01:15:00 -0500 | [diff] [blame] | 1 | <!-- |
| 2 | Licensed to the Apache Software Foundation (ASF) under one |
| 3 | or more contributor license agreements. See the NOTICE file |
| 4 | distributed with this work for additional information |
| 5 | regarding copyright ownership. The ASF licenses this file |
| 6 | to you under the Apache License, Version 2.0 (the |
| 7 | "License"); you may not use this file except in compliance |
| 8 | with the License. You may obtain a copy of the License at |
| 9 | |
| 10 | http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | |
| 12 | Unless required by applicable law or agreed to in writing, |
| 13 | software distributed under the License is distributed on an |
| 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | KIND, either express or implied. See the License for the |
| 16 | specific language governing permissions and limitations |
| 17 | under the License. |
| 18 | --> |
| 19 | <project name="XML Schema Test" default="test" basedir="."> |
| 20 | |
| 21 | <description>XML Schema Validation Test</description> |
| 22 | |
| 23 | <property name="xml.dir" location="${basedir}/.." /> |
| 24 | <property name="gen.xml.dir" location="${basedir}/../gen-xml" /> |
| 25 | <property name="idl.xml.schema" location="${xml.dir}/thrift-idl.xsd" /> |
| 26 | |
| 27 | <property name="thrift.dir" location="../../../" /> |
| 28 | <property name="thrift.test.dir" location="${thrift.dir}/test" /> |
| 29 | <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" /> |
| 30 | |
| 31 | <property file="${basedir}/build.properties" /> |
| 32 | |
| 33 | <target name="compiler.check"> |
| 34 | <fail> |
| 35 | <condition> |
| 36 | <not> |
| 37 | <resourcecount count="1"> |
| 38 | <fileset id="fs" file="${thrift.compiler}"/> |
| 39 | </resourcecount> |
| 40 | </not> |
| 41 | </condition> |
| 42 | Thrift compiler is missing ! |
| 43 | </fail> |
| 44 | </target> |
| 45 | |
| 46 | <target name="init" depends="compiler.check, mkdirs"> |
| 47 | <tstamp /> |
| 48 | </target> |
| 49 | |
| 50 | <target name="mkdirs"> |
| 51 | <mkdir dir="${gen.xml.dir}"/> |
| 52 | </target> |
| 53 | |
| 54 | <target name="generate" depends="init"> |
| 55 | <generate-xml file="${thrift.test.dir}/ThriftTest.thrift"/> |
| 56 | <generate-xml file="${thrift.test.dir}/Include.thrift"/> |
| 57 | <generate-xml file="${thrift.test.dir}/Recursive.thrift"/> |
| 58 | <generate-xml file="${thrift.test.dir}/ManyOptionals.thrift"/> |
| 59 | <generate-xml file="${thrift.test.dir}/OptionalRequiredTest.thrift"/> |
| 60 | <generate-xml file="${thrift.test.dir}/ConstantsDemo.thrift"/> |
| 61 | <generate-xml file="${thrift.test.dir}/TypedefTest.thrift" /> |
| 62 | <generate-xml file="${thrift.test.dir}/AnnotationTest.thrift" /> |
| 63 | <generate-xml file="${thrift.test.dir}/DocTest.thrift" /> |
| 64 | <generate-xml file="${thrift.test.dir}/EnumTest.thrift" /> |
| 65 | <generate-xml file="${thrift.test.dir}/ManyTypedefs.thrift" /> |
| 66 | </target> |
| 67 | |
| 68 | <target name="test" description="run schema validation" |
| 69 | depends="validate-generated-xml"/> |
| 70 | |
| 71 | <target name="validate-generated-xml" depends="init, generate"> |
| 72 | <validate-xml file="${gen.xml.dir}/ThriftTest.xml"/> |
| 73 | <validate-xml file="${gen.xml.dir}/Include.xml"/> |
| 74 | <validate-xml file="${gen.xml.dir}/Recursive.xml"/> |
| 75 | <validate-xml file="${gen.xml.dir}/ManyOptionals.xml"/> |
| 76 | <validate-xml file="${gen.xml.dir}/OptionalRequiredTest.xml"/> |
| 77 | <validate-xml file="${gen.xml.dir}/ConstantsDemo.xml"/> |
| 78 | <validate-xml file="${gen.xml.dir}/TypedefTest.xml"/> |
| 79 | <validate-xml file="${gen.xml.dir}/AnnotationTest.xml"/> |
| 80 | <validate-xml file="${gen.xml.dir}/DocTest.xml"/> |
| 81 | <validate-xml file="${gen.xml.dir}/EnumTest.xml"/> |
| 82 | <validate-xml file="${gen.xml.dir}/ManyTypedefs.xml"/> |
| 83 | </target> |
| 84 | |
| 85 | <target name="clean"> |
| 86 | <delete dir="${build.dir}" /> |
| 87 | <delete dir="${gen.xml.dir}" /> |
| 88 | </target> |
| 89 | |
| 90 | <macrodef name="generate-xml"> |
| 91 | <attribute name="file" /> |
| 92 | <sequential> |
| 93 | <exec executable="${thrift.compiler}" failonerror="true"> |
| 94 | <arg line="-gen xml:merge"/> |
| 95 | <arg line="-out ${gen.xml.dir}"/> |
| 96 | <arg line="@{file}"/> |
| 97 | </exec> |
| 98 | </sequential> |
| 99 | </macrodef> |
| 100 | |
| 101 | <macrodef name="validate-xml"> |
| 102 | <attribute name="file" /> |
| 103 | <sequential> |
| 104 | <echo message="validating generated XML: @{file}" /> |
| 105 | <schemavalidate file="@{file}"> |
| 106 | <schema namespace="http://thrift.apache.org/xml/idl" |
| 107 | file="${idl.xml.schema}" /> |
| 108 | </schemavalidate> |
| 109 | </sequential> |
| 110 | </macrodef> |
| 111 | |
| 112 | </project> |