blob: a378215a8eb05096d6daa2030370d5bd103b1f4b [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"
Bryan Duxburyd8c77572010-07-29 19:30:47 +0000132 doctitle="Thrift Java API"
133 classpathref="test.classpath">
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000134 </javadoc>
Mark Slee83c52a82006-06-07 06:51:18 +0000135 </target>
136
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000137 <target name="dist" depends="compile">
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000138 <mkdir dir="${build}/META-INF"/>
139 <copy file="${thrift.root}/LICENSE" tofile="${build}/META-INF/LICENSE.txt"/>
140 <copy file="${thrift.root}/NOTICE" tofile="${build}/META-INF/NOTICE.txt"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +0000141 <jar jarfile="${jar.file}">
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000142 <fileset dir="${build}">
Bryan Duxbury52611212010-02-10 23:23:35 +0000143 <include name="org/apache/thrift/**/*.class" />
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000144 <include name="META-INF/*.txt" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000145 </fileset>
146 <fileset dir="src">
147 <include name="**/*.java" />
148 </fileset>
149 </jar>
150 </target>
151
152 <target name="install" depends="dist,javadoc">
David Reiss56c2c212009-06-04 02:05:25 +0000153 <copy todir="${install.path}">
154 <fileset dir="."><include name="*.jar" /></fileset>
155 </copy>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000156 <copy todir="${install.javadoc.path}">
157 <fileset dir="${javadoc}">
158 <include name="**/*" />
159 </fileset>
160 </copy>
Mark Slee83c52a82006-06-07 06:51:18 +0000161 </target>
162
163 <target name="clean">
164 <delete dir="${build}" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000165 <delete dir="${gen}"/>
166 <delete dir="${genbean}"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000167 <delete dir="${javadoc}"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +0000168 <delete file="${jar.file}" />
Mark Slee83c52a82006-06-07 06:51:18 +0000169 </target>
170
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000171 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
David Reiss36a5a252009-04-29 23:20:56 +0000172 <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" />
173 <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" />
174 <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000175 </target>
176
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000177 <property name="build.test" location="${build.dir}/test"/>
178 <property name="test.junit.output.format" value="plain"/>
179 <property name="test.timeout" value="2000000"/>
180 <property name="test.src.dir" location="${basedir}/test"/>
181 <property name="test.log.dir" value="${build.test}/log"/>
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000182 <property name="test.port" value="9090" />
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000183
184 <target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
185 <mkdir dir="${test.log.dir}"/>
186 <junit
187 printsummary="yes" showoutput="${test.output}"
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000188 haltonfailure="no" fork="yes" maxmemory="512m"
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000189 errorProperty="tests.failed" failureProperty="tests.failed"
190 timeout="${test.timeout}"
191 >
192 <sysproperty key="build.test" value="${build.test}"/>
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000193 <sysproperty key="test.port" value="${test.port}" />
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000194 <classpath refid="test.classpath"/>
195 <formatter type="${test.junit.output.format}" />
196 <batchtest todir="${test.log.dir}" unless="testcase">
197 <fileset dir="${test.src.dir}" includes="**/Test*.java" />
198 </batchtest>
199 <batchtest todir="${test.log.dir}" if="testcase">
200 <fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
201 </batchtest>
202 </junit>
203 <fail if="tests.failed">Tests failed!</fail>
204 </target>
205
206 <target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000207 <java classname="org.apache.thrift.test.EqualityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000208 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000209 <java classname="org.apache.thrift.test.JavaBeansTest"
David Reiss36a5a252009-04-29 23:20:56 +0000210 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000211 </target>
212
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000213 <target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
214
David Reiss2727fab2009-12-09 19:30:01 +0000215 <target name="testclient" description="Run a test client">
216 <java classname="org.apache.thrift.test.TestClient"
217 classpathref="test.classpath" failonerror="true">
218 <arg line="${testargs}" />
219 </java>
220 </target>
221
222 <target name="testserver" description="Run a test server">
223 <java classname="org.apache.thrift.test.TestServer"
224 classpathref="test.classpath" failonerror="true">
225 <arg line="${testargs}" />
226 </java>
227 </target>
228
229 <target name="testnonblockingserver" description="Run a test nonblocking server">
230 <java classname="org.apache.thrift.test.TestNonblockingServer"
231 classpathref="test.classpath" failonerror="true">
232 <arg line="${testargs}" />
233 </java>
234 </target>
235
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000236 <target name="generate">
Bryan Duxbury2845b162009-11-09 15:55:22 +0000237 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000238 <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
239 </exec>
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}/DebugProtoTest.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}/OptionalRequiredTest.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:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
248 </exec>
249 </target>
250
Bryan Duxbury547edc72010-03-28 21:02:38 +0000251 <target name="mvn.init">
252 <get src="${mvn_ant_task_url}" dest="${mvn.ant.task.jar}" usetimestamp="true" />
253 <path id="maven-ant-tasks.classpath" path="${mvn.ant.task.jar}" />
254 <taskdef resource="org/apache/maven/artifact/ant/antlib.xml"
255 uri="antlib:org.apache.maven.artifact.ant"
256 classpathref="maven-ant-tasks.classpath" />
257 </target>
258
259 <target name="pack.src">
260 <zip destfile="${sources.zip}" basedir="${src}" />
261 </target>
262
263 <target name="generate.pom" depends="init,resolve" description="Generate a Maven POM file for libthrift">
264 <ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${pom.file}" >
265 <mapping conf="default" scope="compile" />
266 <mapping conf="runtime" scope="runtime" />
267 </ivy:makepom>
268 </target>
269
270 <target name="publish" depends="test,dist,mvn.init,generate.pom,pack.src">
271 <artifact:pom id="pom" file="${pom.file}" />
272
273 <artifact:install file="${jar.file}">
274 <pom refid="pom"/>
275 <attach file="${sources.zip}" classifier="source" />
276 </artifact:install>
277
278 <artifact:remoteRepository id="remote.repository" url="${apache.snapshot.repository}" />
279
280 <artifact:deploy file="${jar.file}">
281 <remoteRepository refid="remote.repository" />
282 <pom refid="pom"/>
283 <attach file="${sources.zip}" classifier="source" />
284 </artifact:deploy>
285 </target>
Mark Slee83c52a82006-06-07 06:51:18 +0000286</project>