blob: ed55c2fec0936b25a55b947dc7f192a5af6e89e2 [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="."
Bryan Duxbury547edc72010-03-28 21:02:38 +000021 xmlns:ivy="antlib:org.apache.ivy.ant"
22 xmlns:artifact="antlib:org.apache.maven.artifact.ant">
Mark Slee83c52a82006-06-07 06:51:18 +000023
24 <description>Thrift Build File</description>
25
David Reiss089164a2009-05-22 19:50:32 +000026 <property environment="env" />
27
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000028 <property name="gen" location="gen-java" />
29 <property name="genbean" location="gen-javabean" />
Bryan Duxbury547edc72010-03-28 21:02:38 +000030 <property name="mvn.ant.task.version" value="2.1.0" />
31
Mark Slee83c52a82006-06-07 06:51:18 +000032 <property name="src" location="src" />
33 <property name="build" location="build" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +000034 <property name="javadoc" location="${build}/javadoc" />
David Reissf0c21a72008-07-11 01:26:16 +000035 <property name="install.path" value="/usr/local/lib" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000036 <property name="src.test" location="test" />
37 <property name="build.test" location="${build}/test" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000038 <property name="test.thrift.home" location="../../test"/>
Bryan Duxbury2f45e782009-08-20 00:55:12 +000039 <property name="thrift.root" location="../../"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +000040 <property name="jar.file" location="${basedir}/libthrift.jar" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000041
42 <property file="${user.home}/.thrift-build.properties" />
Bryan Duxbury538e3442009-02-10 04:49:39 +000043
David Reiss36a5a252009-04-29 23:20:56 +000044 <!-- ivy properties -->
45 <property name="ivy.version" value="2.0.0-rc2" />
46 <property name="ivy.dir" location="${build}/ivy" />
47 <property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/>
48 <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
49 <property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
50 <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
Bryan Duxbury547edc72010-03-28 21:02:38 +000051 <property name="mvn_ant_task_url" value="http://www.reverse.net/pub/apache/maven/binaries/maven-ant-tasks-${mvn.ant.task.version}.jar" />
52 <property name="mvn.ant.task.jar" location="${ivy.dir}/maven-ant-tasks-${mvn.ant.task.version}.jar" />
53 <property name="sources.zip" location="${build}/libthrift-src.zip" />
54 <property name="pom.file" location="${build}/pom.xml" />
55
56 <!-- TODO: Get the appropriate tokens / URL for upload -->
57 <property name="apache.snapshot.repository" value="https://repository.apache.org/content/repositories/snapshots" />
58
David Reiss36a5a252009-04-29 23:20:56 +000059 <path id="compile.classpath">
60 <fileset dir="${ivy.lib.dir}">
61 <include name="**/*.jar" />
62 </fileset>
63 </path>
64
65 <path id="test.classpath">
66 <path refid="compile.classpath" />
David Reiss089164a2009-05-22 19:50:32 +000067 <pathelement path="${env.CLASSPATH}" />
David Reiss36a5a252009-04-29 23:20:56 +000068 <pathelement location="build/test" />
Bryan Duxbury547edc72010-03-28 21:02:38 +000069 <pathelement location="${jar.file}" />
David Reiss36a5a252009-04-29 23:20:56 +000070 </path>
Bryan Duxbury538e3442009-02-10 04:49:39 +000071
Mark Slee83c52a82006-06-07 06:51:18 +000072 <target name="init">
73 <tstamp />
74 <mkdir dir="${build}"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000075 <mkdir dir="${build.test}" />
David Reiss36a5a252009-04-29 23:20:56 +000076 <!--
77 Allow Ivy to be disabled with "-Dnoivy=".
78 It is kind of a hack to pretend that we already found it,
79 but Ant doesn't provide an easy way of blocking dependencies
80 from executing or checking multiple conditions.
81 -->
82 <condition property="ivy.found"><isset property="noivy" /></condition>
83 <condition property="offline"><isset property="noivy" /></condition>
Mark Slee83c52a82006-06-07 06:51:18 +000084 </target>
85
David Reiss36a5a252009-04-29 23:20:56 +000086 <target name="ivy-init-dirs">
87 <mkdir dir="${ivy.dir}" />
88 <mkdir dir="${ivy.lib.dir}" />
89 </target>
90
91 <target name="ivy-download" depends="ivy-init-dirs" description="To download ivy" unless="offline">
92 <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
93 </target>
94
95 <target name="ivy-probe-antlib">
96 <condition property="ivy.found">
97 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
98 </condition>
99 </target>
100
101 <target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib" unless="ivy.found">
102 <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
103 loaderRef="ivyLoader">
104 <classpath>
105 <pathelement location="${ivy.jar}"/>
106 </classpath>
107 </typedef>
108 <fail>
109 <condition >
110 <not>
111 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
112 </not>
113 </condition>
114 You need Apache Ivy 2.0 or later from http://ant.apache.org/
115 It could not be loaded from ${ivy_repo_url}
116 </fail>
117 </target>
118
119 <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
120 <ivy:retrieve />
121 </target>
122
123 <target name="compile" depends="init,resolve">
Bryan Duxbury78753892009-05-06 17:22:11 +0000124 <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" />
Mark Slee83c52a82006-06-07 06:51:18 +0000125 </target>
126
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000127 <target name="javadoc" depends="init">
128 <javadoc sourcepath="${src}"
129 destdir="${javadoc}"
130 version="true"
131 windowtitle="Thrift Java API"
132 doctitle="Thrift Java API">
133 </javadoc>
Mark Slee83c52a82006-06-07 06:51:18 +0000134 </target>
135
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000136 <target name="dist" depends="compile">
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000137 <mkdir dir="${build}/META-INF"/>
138 <copy file="${thrift.root}/LICENSE" tofile="${build}/META-INF/LICENSE.txt"/>
139 <copy file="${thrift.root}/NOTICE" tofile="${build}/META-INF/NOTICE.txt"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +0000140 <jar jarfile="${jar.file}">
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000141 <fileset dir="${build}">
Bryan Duxbury52611212010-02-10 23:23:35 +0000142 <include name="org/apache/thrift/**/*.class" />
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000143 <include name="META-INF/*.txt" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000144 </fileset>
145 <fileset dir="src">
146 <include name="**/*.java" />
147 </fileset>
148 </jar>
149 </target>
150
151 <target name="install" depends="dist,javadoc">
David Reiss56c2c212009-06-04 02:05:25 +0000152 <copy todir="${install.path}">
153 <fileset dir="."><include name="*.jar" /></fileset>
154 </copy>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000155 <copy todir="${install.javadoc.path}">
156 <fileset dir="${javadoc}">
157 <include name="**/*" />
158 </fileset>
159 </copy>
Mark Slee83c52a82006-06-07 06:51:18 +0000160 </target>
161
162 <target name="clean">
163 <delete dir="${build}" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000164 <delete dir="${gen}"/>
165 <delete dir="${genbean}"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000166 <delete dir="${javadoc}"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +0000167 <delete file="${jar.file}" />
Mark Slee83c52a82006-06-07 06:51:18 +0000168 </target>
169
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000170 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
David Reiss36a5a252009-04-29 23:20:56 +0000171 <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" />
172 <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" />
173 <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000174 </target>
175
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000176 <property name="build.test" location="${build.dir}/test"/>
177 <property name="test.junit.output.format" value="plain"/>
178 <property name="test.timeout" value="2000000"/>
179 <property name="test.src.dir" location="${basedir}/test"/>
180 <property name="test.log.dir" value="${build.test}/log"/>
181
182 <target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
183 <mkdir dir="${test.log.dir}"/>
184 <junit
185 printsummary="yes" showoutput="${test.output}"
186 haltonfailure="no" fork="yes" forkmode="once" maxmemory="512m"
187 errorProperty="tests.failed" failureProperty="tests.failed"
188 timeout="${test.timeout}"
189 >
190 <sysproperty key="build.test" value="${build.test}"/>
191 <classpath refid="test.classpath"/>
192 <formatter type="${test.junit.output.format}" />
193 <batchtest todir="${test.log.dir}" unless="testcase">
194 <fileset dir="${test.src.dir}" includes="**/Test*.java" />
195 </batchtest>
196 <batchtest todir="${test.log.dir}" if="testcase">
197 <fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
198 </batchtest>
199 </junit>
200 <fail if="tests.failed">Tests failed!</fail>
201 </target>
202
203 <target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000204 <java classname="org.apache.thrift.test.EqualityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000205 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000206 <java classname="org.apache.thrift.test.ToStringTest"
David Reiss36a5a252009-04-29 23:20:56 +0000207 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury986d7052009-01-29 01:51:08 +0000208 <java classname="org.apache.thrift.test.MetaDataTest"
David Reiss36a5a252009-04-29 23:20:56 +0000209 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000210 <java classname="org.apache.thrift.test.JavaBeansTest"
David Reiss36a5a252009-04-29 23:20:56 +0000211 classpathref="test.classpath" failonerror="true" />
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000212 <java classname="org.apache.thrift.test.UnionTest"
213 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000214 </target>
215
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000216 <target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
217
David Reiss2727fab2009-12-09 19:30:01 +0000218 <target name="testclient" description="Run a test client">
219 <java classname="org.apache.thrift.test.TestClient"
220 classpathref="test.classpath" failonerror="true">
221 <arg line="${testargs}" />
222 </java>
223 </target>
224
225 <target name="testserver" description="Run a test server">
226 <java classname="org.apache.thrift.test.TestServer"
227 classpathref="test.classpath" failonerror="true">
228 <arg line="${testargs}" />
229 </java>
230 </target>
231
232 <target name="testnonblockingserver" description="Run a test nonblocking server">
233 <java classname="org.apache.thrift.test.TestNonblockingServer"
234 classpathref="test.classpath" failonerror="true">
235 <arg line="${testargs}" />
236 </java>
237 </target>
238
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000239 <target name="generate">
Bryan Duxbury2845b162009-11-09 15:55:22 +0000240 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000241 <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
242 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000243 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000244 <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" />
245 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000246 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000247 <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" />
248 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000249 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000250 <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
251 </exec>
252 </target>
253
Bryan Duxbury547edc72010-03-28 21:02:38 +0000254 <target name="mvn.init">
255 <get src="${mvn_ant_task_url}" dest="${mvn.ant.task.jar}" usetimestamp="true" />
256 <path id="maven-ant-tasks.classpath" path="${mvn.ant.task.jar}" />
257 <taskdef resource="org/apache/maven/artifact/ant/antlib.xml"
258 uri="antlib:org.apache.maven.artifact.ant"
259 classpathref="maven-ant-tasks.classpath" />
260 </target>
261
262 <target name="pack.src">
263 <zip destfile="${sources.zip}" basedir="${src}" />
264 </target>
265
266 <target name="generate.pom" depends="init,resolve" description="Generate a Maven POM file for libthrift">
267 <ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${pom.file}" >
268 <mapping conf="default" scope="compile" />
269 <mapping conf="runtime" scope="runtime" />
270 </ivy:makepom>
271 </target>
272
273 <target name="publish" depends="test,dist,mvn.init,generate.pom,pack.src">
274 <artifact:pom id="pom" file="${pom.file}" />
275
276 <artifact:install file="${jar.file}">
277 <pom refid="pom"/>
278 <attach file="${sources.zip}" classifier="source" />
279 </artifact:install>
280
281 <artifact:remoteRepository id="remote.repository" url="${apache.snapshot.repository}" />
282
283 <artifact:deploy file="${jar.file}">
284 <remoteRepository refid="remote.repository" />
285 <pom refid="pom"/>
286 <attach file="${sources.zip}" classifier="source" />
287 </artifact:deploy>
288 </target>
Mark Slee83c52a82006-06-07 06:51:18 +0000289</project>