David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 1 | <?xml version="1.0"?> |
David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 2 | <!-- |
| 3 | Licensed to the Apache Software Foundation (ASF) under one |
| 4 | or more contributor license agreements. See the NOTICE file |
| 5 | distributed with this work for additional information |
| 6 | regarding copyright ownership. The ASF licenses this file |
| 7 | to you under the Apache License, Version 2.0 (the |
| 8 | "License"); you may not use this file except in compliance |
| 9 | with the License. You may obtain a copy of the License at |
| 10 | |
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | |
| 13 | Unless required by applicable law or agreed to in writing, |
| 14 | software distributed under the License is distributed on an |
| 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | KIND, either express or implied. See the License for the |
| 17 | specific language governing permissions and limitations |
| 18 | under the License. |
| 19 | --> |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 20 | <project name="libthrift" default="dist" basedir="." |
| 21 | xmlns:ivy="antlib:org.apache.ivy.ant"> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 22 | |
| 23 | <description>Thrift Build File</description> |
| 24 | |
David Reiss | 089164a | 2009-05-22 19:50:32 +0000 | [diff] [blame] | 25 | <property environment="env" /> |
| 26 | |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 27 | <property name="gen" location="gen-java" /> |
| 28 | <property name="genbean" location="gen-javabean" /> |
| 29 | |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 30 | <property name="src" location="src" /> |
| 31 | <property name="build" location="build" /> |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 32 | <property name="javadoc" location="${build}/javadoc" /> |
David Reiss | f0c21a7 | 2008-07-11 01:26:16 +0000 | [diff] [blame] | 33 | <property name="install.path" value="/usr/local/lib" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 34 | <property name="src.test" location="test" /> |
| 35 | <property name="build.test" location="${build}/test" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 36 | <property name="test.thrift.home" location="../../test"/> |
Bryan Duxbury | 2f45e78 | 2009-08-20 00:55:12 +0000 | [diff] [blame] | 37 | <property name="thrift.root" location="../../"/> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 38 | |
| 39 | <property file="${user.home}/.thrift-build.properties" /> |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 40 | |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 41 | <!-- ivy properties --> |
| 42 | <property name="ivy.version" value="2.0.0-rc2" /> |
| 43 | <property name="ivy.dir" location="${build}/ivy" /> |
| 44 | <property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/> |
| 45 | <property name="ivy.lib.dir" location="${ivy.dir}/lib" /> |
| 46 | <property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/> |
| 47 | <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" /> |
| 48 | |
| 49 | <path id="compile.classpath"> |
| 50 | <fileset dir="${ivy.lib.dir}"> |
| 51 | <include name="**/*.jar" /> |
| 52 | </fileset> |
| 53 | </path> |
| 54 | |
| 55 | <path id="test.classpath"> |
| 56 | <path refid="compile.classpath" /> |
David Reiss | 089164a | 2009-05-22 19:50:32 +0000 | [diff] [blame] | 57 | <pathelement path="${env.CLASSPATH}" /> |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 58 | <pathelement location="build/test" /> |
| 59 | <pathelement location="libthrift.jar" /> |
| 60 | </path> |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 61 | |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 62 | <target name="init"> |
| 63 | <tstamp /> |
| 64 | <mkdir dir="${build}"/> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 65 | <mkdir dir="${build.test}" /> |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 66 | <!-- |
| 67 | Allow Ivy to be disabled with "-Dnoivy=". |
| 68 | It is kind of a hack to pretend that we already found it, |
| 69 | but Ant doesn't provide an easy way of blocking dependencies |
| 70 | from executing or checking multiple conditions. |
| 71 | --> |
| 72 | <condition property="ivy.found"><isset property="noivy" /></condition> |
| 73 | <condition property="offline"><isset property="noivy" /></condition> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 74 | </target> |
| 75 | |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 76 | <target name="ivy-init-dirs"> |
| 77 | <mkdir dir="${ivy.dir}" /> |
| 78 | <mkdir dir="${ivy.lib.dir}" /> |
| 79 | </target> |
| 80 | |
| 81 | <target name="ivy-download" depends="ivy-init-dirs" description="To download ivy" unless="offline"> |
| 82 | <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/> |
| 83 | </target> |
| 84 | |
| 85 | <target name="ivy-probe-antlib"> |
| 86 | <condition property="ivy.found"> |
| 87 | <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/> |
| 88 | </condition> |
| 89 | </target> |
| 90 | |
| 91 | <target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib" unless="ivy.found"> |
| 92 | <typedef uri="antlib:org.apache.ivy.ant" onerror="fail" |
| 93 | loaderRef="ivyLoader"> |
| 94 | <classpath> |
| 95 | <pathelement location="${ivy.jar}"/> |
| 96 | </classpath> |
| 97 | </typedef> |
| 98 | <fail> |
| 99 | <condition > |
| 100 | <not> |
| 101 | <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/> |
| 102 | </not> |
| 103 | </condition> |
| 104 | You need Apache Ivy 2.0 or later from http://ant.apache.org/ |
| 105 | It could not be loaded from ${ivy_repo_url} |
| 106 | </fail> |
| 107 | </target> |
| 108 | |
| 109 | <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy"> |
| 110 | <ivy:retrieve /> |
| 111 | </target> |
| 112 | |
| 113 | <target name="compile" depends="init,resolve"> |
Bryan Duxbury | 7875389 | 2009-05-06 17:22:11 +0000 | [diff] [blame] | 114 | <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" /> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 115 | </target> |
| 116 | |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 117 | <target name="javadoc" depends="init"> |
| 118 | <javadoc sourcepath="${src}" |
| 119 | destdir="${javadoc}" |
| 120 | version="true" |
| 121 | windowtitle="Thrift Java API" |
| 122 | doctitle="Thrift Java API"> |
| 123 | </javadoc> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 124 | </target> |
| 125 | |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 126 | <target name="dist" depends="compile"> |
Bryan Duxbury | 2f45e78 | 2009-08-20 00:55:12 +0000 | [diff] [blame] | 127 | <mkdir dir="${build}/META-INF"/> |
| 128 | <copy file="${thrift.root}/LICENSE" tofile="${build}/META-INF/LICENSE.txt"/> |
| 129 | <copy file="${thrift.root}/NOTICE" tofile="${build}/META-INF/NOTICE.txt"/> |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 130 | <jar jarfile="libthrift.jar"> |
| 131 | <fileset dir="${build}"> |
Bryan Duxbury | 5261121 | 2010-02-10 23:23:35 +0000 | [diff] [blame] | 132 | <include name="org/apache/thrift/**/*.class" /> |
Bryan Duxbury | 2f45e78 | 2009-08-20 00:55:12 +0000 | [diff] [blame] | 133 | <include name="META-INF/*.txt" /> |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 134 | </fileset> |
| 135 | <fileset dir="src"> |
| 136 | <include name="**/*.java" /> |
| 137 | </fileset> |
| 138 | </jar> |
| 139 | </target> |
| 140 | |
| 141 | <target name="install" depends="dist,javadoc"> |
David Reiss | 56c2c21 | 2009-06-04 02:05:25 +0000 | [diff] [blame] | 142 | <copy todir="${install.path}"> |
| 143 | <fileset dir="."><include name="*.jar" /></fileset> |
| 144 | </copy> |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 145 | <copy todir="${install.javadoc.path}"> |
| 146 | <fileset dir="${javadoc}"> |
| 147 | <include name="**/*" /> |
| 148 | </fileset> |
| 149 | </copy> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 150 | </target> |
| 151 | |
| 152 | <target name="clean"> |
| 153 | <delete dir="${build}" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 154 | <delete dir="${gen}"/> |
| 155 | <delete dir="${genbean}"/> |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 156 | <delete dir="${javadoc}"/> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 157 | <delete file="libthrift.jar" /> |
| 158 | </target> |
| 159 | |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 160 | <target name="compile-test" description="Build the test suite classes" depends="generate,dist"> |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 161 | <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" /> |
| 162 | <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" /> |
| 163 | <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 164 | </target> |
| 165 | |
| 166 | <target name="test" description="Run the full test suite" depends="compile-test"> |
| 167 | <java classname="org.apache.thrift.test.JSONProtoTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 168 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 169 | <java classname="org.apache.thrift.test.TCompactProtocolTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 170 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 171 | <java classname="org.apache.thrift.test.IdentityTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 172 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 173 | <java classname="org.apache.thrift.test.EqualityTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 174 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 175 | <java classname="org.apache.thrift.test.ToStringTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 176 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 177 | <java classname="org.apache.thrift.test.DeepCopyTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 178 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | dee6d42 | 2010-02-23 19:06:25 +0000 | [diff] [blame] | 179 | <java classname="org.apache.thrift.test.CompareTest" |
| 180 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 986d705 | 2009-01-29 01:51:08 +0000 | [diff] [blame] | 181 | <java classname="org.apache.thrift.test.MetaDataTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 182 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 183 | <java classname="org.apache.thrift.test.JavaBeansTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 184 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | ab3666e | 2009-09-01 23:03:47 +0000 | [diff] [blame] | 185 | <java classname="org.apache.thrift.test.UnionTest" |
| 186 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 51f2880 | 2009-10-01 20:53:45 +0000 | [diff] [blame] | 187 | <java classname="org.apache.thrift.test.PartialDeserializeTest" |
| 188 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 189 | </target> |
| 190 | |
David Reiss | 2727fab | 2009-12-09 19:30:01 +0000 | [diff] [blame] | 191 | <target name="testclient" description="Run a test client"> |
| 192 | <java classname="org.apache.thrift.test.TestClient" |
| 193 | classpathref="test.classpath" failonerror="true"> |
| 194 | <arg line="${testargs}" /> |
| 195 | </java> |
| 196 | </target> |
| 197 | |
| 198 | <target name="testserver" description="Run a test server"> |
| 199 | <java classname="org.apache.thrift.test.TestServer" |
| 200 | classpathref="test.classpath" failonerror="true"> |
| 201 | <arg line="${testargs}" /> |
| 202 | </java> |
| 203 | </target> |
| 204 | |
| 205 | <target name="testnonblockingserver" description="Run a test nonblocking server"> |
| 206 | <java classname="org.apache.thrift.test.TestNonblockingServer" |
| 207 | classpathref="test.classpath" failonerror="true"> |
| 208 | <arg line="${testargs}" /> |
| 209 | </java> |
| 210 | </target> |
| 211 | |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 212 | <target name="generate"> |
Bryan Duxbury | 2845b16 | 2009-11-09 15:55:22 +0000 | [diff] [blame] | 213 | <exec executable="../../compiler/cpp/thrift" failonerror="true"> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 214 | <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" /> |
| 215 | </exec> |
Bryan Duxbury | 2845b16 | 2009-11-09 15:55:22 +0000 | [diff] [blame] | 216 | <exec executable="../../compiler/cpp/thrift" failonerror="true"> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 217 | <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" /> |
| 218 | </exec> |
Bryan Duxbury | 2845b16 | 2009-11-09 15:55:22 +0000 | [diff] [blame] | 219 | <exec executable="../../compiler/cpp/thrift" failonerror="true"> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 220 | <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" /> |
| 221 | </exec> |
Bryan Duxbury | 2845b16 | 2009-11-09 15:55:22 +0000 | [diff] [blame] | 222 | <exec executable="../../compiler/cpp/thrift" failonerror="true"> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 223 | <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" /> |
| 224 | </exec> |
| 225 | </target> |
| 226 | |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 227 | </project> |