blob: a80f749c682cfb58fe8aa925ed3b9ccd0b31d952 [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" />
Todd Lipconfcaa8f52010-09-27 23:51:22 +000058
David Reiss36a5a252009-04-29 23:20:56 +000059 <path id="compile.classpath">
Todd Lipconfcaa8f52010-09-27 23:51:22 +000060 <path refid="ivy.compile.classpath" />
David Reiss36a5a252009-04-29 23:20:56 +000061 </path>
62
63 <path id="test.classpath">
64 <path refid="compile.classpath" />
Todd Lipconfcaa8f52010-09-27 23:51:22 +000065 <path refid="ivy.test.classpath" />
David Reiss089164a2009-05-22 19:50:32 +000066 <pathelement path="${env.CLASSPATH}" />
David Reiss36a5a252009-04-29 23:20:56 +000067 <pathelement location="build/test" />
Bryan Duxbury547edc72010-03-28 21:02:38 +000068 <pathelement location="${jar.file}" />
David Reiss36a5a252009-04-29 23:20:56 +000069 </path>
Bryan Duxbury538e3442009-02-10 04:49:39 +000070
Mark Slee83c52a82006-06-07 06:51:18 +000071 <target name="init">
72 <tstamp />
73 <mkdir dir="${build}"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000074 <mkdir dir="${build.test}" />
David Reiss36a5a252009-04-29 23:20:56 +000075 <!--
76 Allow Ivy to be disabled with "-Dnoivy=".
77 It is kind of a hack to pretend that we already found it,
78 but Ant doesn't provide an easy way of blocking dependencies
79 from executing or checking multiple conditions.
80 -->
81 <condition property="ivy.found"><isset property="noivy" /></condition>
82 <condition property="offline"><isset property="noivy" /></condition>
Mark Slee83c52a82006-06-07 06:51:18 +000083 </target>
84
David Reiss36a5a252009-04-29 23:20:56 +000085 <target name="ivy-init-dirs">
86 <mkdir dir="${ivy.dir}" />
87 <mkdir dir="${ivy.lib.dir}" />
88 </target>
89
90 <target name="ivy-download" depends="ivy-init-dirs" description="To download ivy" unless="offline">
91 <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
92 </target>
93
94 <target name="ivy-probe-antlib">
95 <condition property="ivy.found">
96 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
97 </condition>
98 </target>
99
100 <target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib" unless="ivy.found">
101 <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
102 loaderRef="ivyLoader">
103 <classpath>
104 <pathelement location="${ivy.jar}"/>
105 </classpath>
106 </typedef>
107 <fail>
108 <condition >
109 <not>
110 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
111 </not>
112 </condition>
113 You need Apache Ivy 2.0 or later from http://ant.apache.org/
114 It could not be loaded from ${ivy_repo_url}
115 </fail>
116 </target>
117
118 <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
119 <ivy:retrieve />
Todd Lipconfcaa8f52010-09-27 23:51:22 +0000120 <ivy:cachepath pathid="ivy.compile.classpath" conf="compile" />
121 <ivy:cachepath pathid="ivy.test.classpath" conf="test" />
David Reiss36a5a252009-04-29 23:20:56 +0000122 </target>
123
124 <target name="compile" depends="init,resolve">
Bryan Duxbury78753892009-05-06 17:22:11 +0000125 <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" />
Mark Slee83c52a82006-06-07 06:51:18 +0000126 </target>
127
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000128 <target name="javadoc" depends="init">
129 <javadoc sourcepath="${src}"
130 destdir="${javadoc}"
131 version="true"
132 windowtitle="Thrift Java API"
Bryan Duxburyd8c77572010-07-29 19:30:47 +0000133 doctitle="Thrift Java API"
134 classpathref="test.classpath">
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000135 </javadoc>
Mark Slee83c52a82006-06-07 06:51:18 +0000136 </target>
137
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000138 <target name="dist" depends="compile">
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000139 <mkdir dir="${build}/META-INF"/>
140 <copy file="${thrift.root}/LICENSE" tofile="${build}/META-INF/LICENSE.txt"/>
141 <copy file="${thrift.root}/NOTICE" tofile="${build}/META-INF/NOTICE.txt"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +0000142 <jar jarfile="${jar.file}">
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000143 <fileset dir="${build}">
Bryan Duxbury52611212010-02-10 23:23:35 +0000144 <include name="org/apache/thrift/**/*.class" />
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000145 <include name="META-INF/*.txt" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000146 </fileset>
147 <fileset dir="src">
148 <include name="**/*.java" />
149 </fileset>
150 </jar>
151 </target>
152
153 <target name="install" depends="dist,javadoc">
David Reiss56c2c212009-06-04 02:05:25 +0000154 <copy todir="${install.path}">
155 <fileset dir="."><include name="*.jar" /></fileset>
156 </copy>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000157 <copy todir="${install.javadoc.path}">
158 <fileset dir="${javadoc}">
159 <include name="**/*" />
160 </fileset>
161 </copy>
Mark Slee83c52a82006-06-07 06:51:18 +0000162 </target>
163
164 <target name="clean">
165 <delete dir="${build}" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000166 <delete dir="${gen}"/>
167 <delete dir="${genbean}"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000168 <delete dir="${javadoc}"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +0000169 <delete file="${jar.file}" />
Mark Slee83c52a82006-06-07 06:51:18 +0000170 </target>
171
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000172 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
David Reiss36a5a252009-04-29 23:20:56 +0000173 <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" />
174 <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" />
175 <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
Todd Lipconfcaa8f52010-09-27 23:51:22 +0000176 <copy todir="${build.test}">
177 <fileset dir="${src.test}" includes="log4j.properties" />
178 </copy>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000179 </target>
180
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000181 <property name="build.test" location="${build.dir}/test"/>
182 <property name="test.junit.output.format" value="plain"/>
183 <property name="test.timeout" value="2000000"/>
184 <property name="test.src.dir" location="${basedir}/test"/>
185 <property name="test.log.dir" value="${build.test}/log"/>
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000186 <property name="test.port" value="9090" />
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000187
188 <target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
189 <mkdir dir="${test.log.dir}"/>
190 <junit
191 printsummary="yes" showoutput="${test.output}"
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000192 haltonfailure="no" fork="yes" maxmemory="512m"
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000193 errorProperty="tests.failed" failureProperty="tests.failed"
194 timeout="${test.timeout}"
195 >
196 <sysproperty key="build.test" value="${build.test}"/>
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000197 <sysproperty key="test.port" value="${test.port}" />
Bryan Duxbury1b130832010-10-19 17:20:57 +0000198 <sysproperty key="javax.net.ssl.trustStore" value="${src.test}/.truststore"/>
199 <sysproperty key="javax.net.ssl.trustStorePassword" value="thrift"/>
200 <sysproperty key="javax.net.ssl.keyStore" value="${src.test}/.keystore"/>
201 <sysproperty key="javax.net.ssl.keyStorePassword" value="thrift"/>
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000202 <classpath refid="test.classpath"/>
203 <formatter type="${test.junit.output.format}" />
204 <batchtest todir="${test.log.dir}" unless="testcase">
205 <fileset dir="${test.src.dir}" includes="**/Test*.java" />
206 </batchtest>
207 <batchtest todir="${test.log.dir}" if="testcase">
208 <fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
209 </batchtest>
210 </junit>
211 <fail if="tests.failed">Tests failed!</fail>
212 </target>
213
214 <target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000215 <java classname="org.apache.thrift.test.EqualityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000216 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000217 <java classname="org.apache.thrift.test.JavaBeansTest"
David Reiss36a5a252009-04-29 23:20:56 +0000218 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000219 </target>
220
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000221 <target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
222
David Reiss2727fab2009-12-09 19:30:01 +0000223 <target name="testclient" description="Run a test client">
224 <java classname="org.apache.thrift.test.TestClient"
225 classpathref="test.classpath" failonerror="true">
226 <arg line="${testargs}" />
227 </java>
228 </target>
229
230 <target name="testserver" description="Run a test server">
231 <java classname="org.apache.thrift.test.TestServer"
232 classpathref="test.classpath" failonerror="true">
233 <arg line="${testargs}" />
234 </java>
235 </target>
236
237 <target name="testnonblockingserver" description="Run a test nonblocking server">
238 <java classname="org.apache.thrift.test.TestNonblockingServer"
239 classpathref="test.classpath" failonerror="true">
240 <arg line="${testargs}" />
241 </java>
242 </target>
243
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000244 <target name="generate">
Bryan Duxbury2845b162009-11-09 15:55:22 +0000245 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000246 <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
247 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000248 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000249 <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" />
250 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000251 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000252 <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" />
253 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000254 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000255 <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
256 </exec>
257 </target>
258
Bryan Duxbury547edc72010-03-28 21:02:38 +0000259 <target name="mvn.init">
260 <get src="${mvn_ant_task_url}" dest="${mvn.ant.task.jar}" usetimestamp="true" />
261 <path id="maven-ant-tasks.classpath" path="${mvn.ant.task.jar}" />
262 <taskdef resource="org/apache/maven/artifact/ant/antlib.xml"
263 uri="antlib:org.apache.maven.artifact.ant"
264 classpathref="maven-ant-tasks.classpath" />
265 </target>
266
267 <target name="pack.src">
268 <zip destfile="${sources.zip}" basedir="${src}" />
269 </target>
270
271 <target name="generate.pom" depends="init,resolve" description="Generate a Maven POM file for libthrift">
272 <ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${pom.file}" >
273 <mapping conf="default" scope="compile" />
274 <mapping conf="runtime" scope="runtime" />
275 </ivy:makepom>
276 </target>
277
278 <target name="publish" depends="test,dist,mvn.init,generate.pom,pack.src">
279 <artifact:pom id="pom" file="${pom.file}" />
280
281 <artifact:install file="${jar.file}">
282 <pom refid="pom"/>
283 <attach file="${sources.zip}" classifier="source" />
284 </artifact:install>
285
286 <artifact:remoteRepository id="remote.repository" url="${apache.snapshot.repository}" />
287
288 <artifact:deploy file="${jar.file}">
289 <remoteRepository refid="remote.repository" />
290 <pom refid="pom"/>
291 <attach file="${sources.zip}" classifier="source" />
292 </artifact:deploy>
293 </target>
Mark Slee83c52a82006-06-07 06:51:18 +0000294</project>