blob: 9dfc6c8b12d190f8fb093879f75663d1615486f6 [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" />
Roger Meier62b7cfb2010-10-23 22:25:04 +000041 <property name="test.jar.file" location="${basedir}/libthrift-test.jar" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000042
43 <property file="${user.home}/.thrift-build.properties" />
Bryan Duxbury538e3442009-02-10 04:49:39 +000044
David Reiss36a5a252009-04-29 23:20:56 +000045 <!-- ivy properties -->
46 <property name="ivy.version" value="2.0.0-rc2" />
47 <property name="ivy.dir" location="${build}/ivy" />
48 <property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/>
49 <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
50 <property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
51 <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
Bryan Duxbury547edc72010-03-28 21:02:38 +000052 <property name="mvn_ant_task_url" value="http://www.reverse.net/pub/apache/maven/binaries/maven-ant-tasks-${mvn.ant.task.version}.jar" />
53 <property name="mvn.ant.task.jar" location="${ivy.dir}/maven-ant-tasks-${mvn.ant.task.version}.jar" />
54 <property name="sources.zip" location="${build}/libthrift-src.zip" />
55 <property name="pom.file" location="${build}/pom.xml" />
56
57 <!-- TODO: Get the appropriate tokens / URL for upload -->
58 <property name="apache.snapshot.repository" value="https://repository.apache.org/content/repositories/snapshots" />
Todd Lipconfcaa8f52010-09-27 23:51:22 +000059
David Reiss36a5a252009-04-29 23:20:56 +000060 <path id="compile.classpath">
Todd Lipconfcaa8f52010-09-27 23:51:22 +000061 <path refid="ivy.compile.classpath" />
David Reiss36a5a252009-04-29 23:20:56 +000062 </path>
63
64 <path id="test.classpath">
65 <path refid="compile.classpath" />
Todd Lipconfcaa8f52010-09-27 23:51:22 +000066 <path refid="ivy.test.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 />
Todd Lipconfcaa8f52010-09-27 23:51:22 +0000121 <ivy:cachepath pathid="ivy.compile.classpath" conf="compile" />
122 <ivy:cachepath pathid="ivy.test.classpath" conf="test" />
David Reiss36a5a252009-04-29 23:20:56 +0000123 </target>
124
125 <target name="compile" depends="init,resolve">
Bryan Duxbury78753892009-05-06 17:22:11 +0000126 <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" />
Mark Slee83c52a82006-06-07 06:51:18 +0000127 </target>
128
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000129 <target name="javadoc" depends="init">
130 <javadoc sourcepath="${src}"
131 destdir="${javadoc}"
132 version="true"
133 windowtitle="Thrift Java API"
Bryan Duxburyd8c77572010-07-29 19:30:47 +0000134 doctitle="Thrift Java API"
135 classpathref="test.classpath">
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000136 </javadoc>
Mark Slee83c52a82006-06-07 06:51:18 +0000137 </target>
138
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000139 <target name="dist" depends="compile">
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000140 <mkdir dir="${build}/META-INF"/>
141 <copy file="${thrift.root}/LICENSE" tofile="${build}/META-INF/LICENSE.txt"/>
142 <copy file="${thrift.root}/NOTICE" tofile="${build}/META-INF/NOTICE.txt"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +0000143 <jar jarfile="${jar.file}">
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000144 <fileset dir="${build}">
Bryan Duxbury52611212010-02-10 23:23:35 +0000145 <include name="org/apache/thrift/**/*.class" />
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000146 <include name="META-INF/*.txt" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000147 </fileset>
148 <fileset dir="src">
149 <include name="**/*.java" />
150 </fileset>
151 </jar>
152 </target>
153
154 <target name="install" depends="dist,javadoc">
David Reiss56c2c212009-06-04 02:05:25 +0000155 <copy todir="${install.path}">
156 <fileset dir="."><include name="*.jar" /></fileset>
157 </copy>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000158 <copy todir="${install.javadoc.path}">
159 <fileset dir="${javadoc}">
160 <include name="**/*" />
161 </fileset>
162 </copy>
Mark Slee83c52a82006-06-07 06:51:18 +0000163 </target>
164
165 <target name="clean">
166 <delete dir="${build}" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000167 <delete dir="${gen}"/>
168 <delete dir="${genbean}"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000169 <delete dir="${javadoc}"/>
Bryan Duxbury547edc72010-03-28 21:02:38 +0000170 <delete file="${jar.file}" />
Roger Meier62b7cfb2010-10-23 22:25:04 +0000171 <delete file="${test.jar.file}" />
Mark Slee83c52a82006-06-07 06:51:18 +0000172 </target>
173
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000174 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
David Reiss36a5a252009-04-29 23:20:56 +0000175 <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" />
176 <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" />
177 <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
Todd Lipconfcaa8f52010-09-27 23:51:22 +0000178 <copy todir="${build.test}">
179 <fileset dir="${src.test}" includes="log4j.properties" />
180 </copy>
Roger Meier62b7cfb2010-10-23 22:25:04 +0000181 <jar jarfile="${test.jar.file}" basedir="${build}/test"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000182 </target>
183
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000184 <property name="build.test" location="${build.dir}/test"/>
185 <property name="test.junit.output.format" value="plain"/>
186 <property name="test.timeout" value="2000000"/>
187 <property name="test.src.dir" location="${basedir}/test"/>
188 <property name="test.log.dir" value="${build.test}/log"/>
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000189 <property name="test.port" value="9090" />
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000190
191 <target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
192 <mkdir dir="${test.log.dir}"/>
193 <junit
194 printsummary="yes" showoutput="${test.output}"
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000195 haltonfailure="no" fork="yes" maxmemory="512m"
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000196 errorProperty="tests.failed" failureProperty="tests.failed"
197 timeout="${test.timeout}"
198 >
199 <sysproperty key="build.test" value="${build.test}"/>
Todd Lipcon90ec5bf2010-08-27 06:16:37 +0000200 <sysproperty key="test.port" value="${test.port}" />
Bryan Duxbury1b130832010-10-19 17:20:57 +0000201 <sysproperty key="javax.net.ssl.trustStore" value="${src.test}/.truststore"/>
202 <sysproperty key="javax.net.ssl.trustStorePassword" value="thrift"/>
203 <sysproperty key="javax.net.ssl.keyStore" value="${src.test}/.keystore"/>
204 <sysproperty key="javax.net.ssl.keyStorePassword" value="thrift"/>
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000205 <classpath refid="test.classpath"/>
206 <formatter type="${test.junit.output.format}" />
207 <batchtest todir="${test.log.dir}" unless="testcase">
Roger Meier5013de22010-10-25 19:57:26 +0000208 <fileset dir="${test.src.dir}">
209 <include name="**/Test*.java"/>
210 <exclude name="**/TestClient.java"/>
211 <exclude name="**/TestServer.java"/>
212 <exclude name="**/TestNonblockingServer.java"/>
213 </fileset>
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000214 </batchtest>
215 <batchtest todir="${test.log.dir}" if="testcase">
216 <fileset dir="${test.src.dir}" includes="**/${testcase}.java" />
217 </batchtest>
218 </junit>
219 <fail if="tests.failed">Tests failed!</fail>
220 </target>
221
222 <target name="deprecated-test" description="Run the non-JUnit test suite" depends="compile-test">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000223 <java classname="org.apache.thrift.test.EqualityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000224 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000225 <java classname="org.apache.thrift.test.JavaBeansTest"
David Reiss36a5a252009-04-29 23:20:56 +0000226 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000227 </target>
228
Bryan Duxbury951e7e22010-03-26 05:05:59 +0000229 <target name="test" description="Run the full test suite" depends="junit-test,deprecated-test"/>
230
Roger Meier62b7cfb2010-10-23 22:25:04 +0000231 <target name="testclient" description="Run a test client" depends="compile-test">
David Reiss2727fab2009-12-09 19:30:01 +0000232 <java classname="org.apache.thrift.test.TestClient"
233 classpathref="test.classpath" failonerror="true">
234 <arg line="${testargs}" />
235 </java>
236 </target>
237
Roger Meier62b7cfb2010-10-23 22:25:04 +0000238 <target name="testserver" description="Run a test server" depends="compile-test">
David Reiss2727fab2009-12-09 19:30:01 +0000239 <java classname="org.apache.thrift.test.TestServer"
240 classpathref="test.classpath" failonerror="true">
241 <arg line="${testargs}" />
242 </java>
243 </target>
244
Roger Meier62b7cfb2010-10-23 22:25:04 +0000245 <target name="testnonblockingserver" description="Run a test nonblocking server" depends="compile-test">
David Reiss2727fab2009-12-09 19:30:01 +0000246 <java classname="org.apache.thrift.test.TestNonblockingServer"
247 classpathref="test.classpath" failonerror="true">
248 <arg line="${testargs}" />
249 </java>
250 </target>
251
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000252 <target name="generate">
Bryan Duxbury2845b162009-11-09 15:55:22 +0000253 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000254 <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
255 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000256 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000257 <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" />
258 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000259 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000260 <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" />
261 </exec>
Bryan Duxbury2845b162009-11-09 15:55:22 +0000262 <exec executable="../../compiler/cpp/thrift" failonerror="true">
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000263 <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
264 </exec>
265 </target>
266
Bryan Duxbury547edc72010-03-28 21:02:38 +0000267 <target name="mvn.init">
268 <get src="${mvn_ant_task_url}" dest="${mvn.ant.task.jar}" usetimestamp="true" />
269 <path id="maven-ant-tasks.classpath" path="${mvn.ant.task.jar}" />
270 <taskdef resource="org/apache/maven/artifact/ant/antlib.xml"
271 uri="antlib:org.apache.maven.artifact.ant"
272 classpathref="maven-ant-tasks.classpath" />
273 </target>
274
275 <target name="pack.src">
276 <zip destfile="${sources.zip}" basedir="${src}" />
277 </target>
278
279 <target name="generate.pom" depends="init,resolve" description="Generate a Maven POM file for libthrift">
280 <ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${pom.file}" >
281 <mapping conf="default" scope="compile" />
282 <mapping conf="runtime" scope="runtime" />
283 </ivy:makepom>
284 </target>
285
286 <target name="publish" depends="test,dist,mvn.init,generate.pom,pack.src">
287 <artifact:pom id="pom" file="${pom.file}" />
288
289 <artifact:install file="${jar.file}">
290 <pom refid="pom"/>
291 <attach file="${sources.zip}" classifier="source" />
292 </artifact:install>
293
294 <artifact:remoteRepository id="remote.repository" url="${apache.snapshot.repository}" />
295
296 <artifact:deploy file="${jar.file}">
297 <remoteRepository refid="remote.repository" />
298 <pom refid="pom"/>
299 <attach file="${sources.zip}" classifier="source" />
300 </artifact:deploy>
301 </target>
Mark Slee83c52a82006-06-07 06:51:18 +0000302</project>