blob: b02b1379b3a131a9b76f495e3c6cfc0958781364 [file] [log] [blame]
David Reiss36a5a252009-04-29 23:20:56 +00001<?xml version="1.0"?>
David Reissea2cba82009-03-30 21:35:00 +00002<!--
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 Reiss36a5a252009-04-29 23:20:56 +000020<project name="libthrift" default="dist" basedir="."
21 xmlns:ivy="antlib:org.apache.ivy.ant">
Mark Slee83c52a82006-06-07 06:51:18 +000022
23 <description>Thrift Build File</description>
24
David Reiss089164a2009-05-22 19:50:32 +000025 <property environment="env" />
26
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000027 <property name="gen" location="gen-java" />
28 <property name="genbean" location="gen-javabean" />
29
Mark Slee83c52a82006-06-07 06:51:18 +000030 <property name="src" location="src" />
31 <property name="build" location="build" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +000032 <property name="javadoc" location="${build}/javadoc" />
David Reissf0c21a72008-07-11 01:26:16 +000033 <property name="install.path" value="/usr/local/lib" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000034 <property name="src.test" location="test" />
35 <property name="build.test" location="${build}/test" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000036 <property name="test.thrift.home" location="../../test"/>
Bryan Duxbury2f45e782009-08-20 00:55:12 +000037 <property name="thrift.root" location="../../"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000038
39 <property file="${user.home}/.thrift-build.properties" />
Bryan Duxbury538e3442009-02-10 04:49:39 +000040
David Reiss36a5a252009-04-29 23:20:56 +000041 <!-- 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 Reiss089164a2009-05-22 19:50:32 +000057 <pathelement path="${env.CLASSPATH}" />
David Reiss36a5a252009-04-29 23:20:56 +000058 <pathelement location="build/test" />
59 <pathelement location="libthrift.jar" />
60 </path>
Bryan Duxbury538e3442009-02-10 04:49:39 +000061
Mark Slee83c52a82006-06-07 06:51:18 +000062 <target name="init">
63 <tstamp />
64 <mkdir dir="${build}"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000065 <mkdir dir="${build.test}" />
David Reiss36a5a252009-04-29 23:20:56 +000066 <!--
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 Slee83c52a82006-06-07 06:51:18 +000074 </target>
75
David Reiss36a5a252009-04-29 23:20:56 +000076 <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 Duxbury78753892009-05-06 17:22:11 +0000114 <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" />
Mark Slee83c52a82006-06-07 06:51:18 +0000115 </target>
116
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000117 <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 Slee83c52a82006-06-07 06:51:18 +0000124 </target>
125
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000126 <target name="dist" depends="compile">
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000127 <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 Duxbury32e04b42009-03-20 16:43:06 +0000130 <jar jarfile="libthrift.jar">
131 <fileset dir="${build}">
Bryan Duxbury52611212010-02-10 23:23:35 +0000132 <include name="org/apache/thrift/**/*.class" />
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000133 <include name="META-INF/*.txt" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000134 </fileset>
135 <fileset dir="src">
136 <include name="**/*.java" />
137 </fileset>
138 </jar>
139 </target>
140
141 <target name="install" depends="dist,javadoc">
David Reiss56c2c212009-06-04 02:05:25 +0000142 <copy todir="${install.path}">
143 <fileset dir="."><include name="*.jar" /></fileset>
144 </copy>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000145 <copy todir="${install.javadoc.path}">
146 <fileset dir="${javadoc}">
147 <include name="**/*" />
148 </fileset>
149 </copy>
Mark Slee83c52a82006-06-07 06:51:18 +0000150 </target>
151
152 <target name="clean">
153 <delete dir="${build}" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000154 <delete dir="${gen}"/>
155 <delete dir="${genbean}"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000156 <delete dir="${javadoc}"/>
Mark Slee83c52a82006-06-07 06:51:18 +0000157 <delete file="libthrift.jar" />
158 </target>
159
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000160 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
David Reiss36a5a252009-04-29 23:20:56 +0000161 <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 Duxbury249d7cb2009-01-29 01:21:20 +0000164 </target>
165
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000166 <property name="build.test" location="${build.dir}/test"/>
167 <property name="test.junit.output.format" value="plain"/>
168 <property name="test.timeout" value="2000000"/>
169 <property name="test.src.dir" location="${basedir}/test"/>
170 <property name="test.log.dir" value="${build.test}/log"/>
171
172 <target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
173 <mkdir dir="${test.log.dir}"/>
174 <junit
175 printsummary="yes" showoutput="${test.output}"
176 haltonfailure="no" fork="yes" forkmode="once" maxmemory="512m"
177 errorProperty="tests.failed" failureProperty="tests.failed"
178 timeout="${test.timeout}"
179 >
180 <sysproperty key="build.test" value="${build.test}"/>
181 <classpath refid="test.classpath"/>
182 <formatter type="${test.junit.output.format}" />
183 <batchtest todir="${test.log.dir}" unless="testcase">
184 <fileset dir="${test.src.dir}" includes="**/Test*.java" />
185 </batchtest>
186 <batchtest todir="${test.log.dir}" if="testcase">
187 <fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
188 </batchtest>
189 </junit>
190 <fail if="tests.failed">Tests failed!</fail>
191 </target>
192
193 <target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000194 <java classname="org.apache.thrift.test.EqualityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000195 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000196 <java classname="org.apache.thrift.test.ToStringTest"
David Reiss36a5a252009-04-29 23:20:56 +0000197 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury986d7052009-01-29 01:51:08 +0000198 <java classname="org.apache.thrift.test.MetaDataTest"
David Reiss36a5a252009-04-29 23:20:56 +0000199 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000200 <java classname="org.apache.thrift.test.JavaBeansTest"
David Reiss36a5a252009-04-29 23:20:56 +0000201 classpathref="test.classpath" failonerror="true" />
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000202 <java classname="org.apache.thrift.test.UnionTest"
203 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000204 </target>
205
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000206 <target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
207
David Reiss2727fab2009-12-09 19:30:01 +0000208 <target name="testclient" description="Run a test client">
209 <java classname="org.apache.thrift.test.TestClient"
210 classpathref="test.classpath" failonerror="true">
211 <arg line="${testargs}" />
212 </java>
213 </target>
214
215 <target name="testserver" description="Run a test server">
216 <java classname="org.apache.thrift.test.TestServer"
217 classpathref="test.classpath" failonerror="true">
218 <arg line="${testargs}" />
219 </java>
220 </target>
221
222 <target name="testnonblockingserver" description="Run a test nonblocking server">
223 <java classname="org.apache.thrift.test.TestNonblockingServer"
224 classpathref="test.classpath" failonerror="true">
225 <arg line="${testargs}" />
226 </java>
227 </target>
228
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000229 <target name="generate">
Bryan Duxbury2845b162009-11-09 15:55:22 +0000230 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000231 <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
232 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000233 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000234 <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" />
235 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000236 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000237 <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" />
238 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000239 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000240 <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
241 </exec>
242 </target>
243
Mark Slee83c52a82006-06-07 06:51:18 +0000244</project>