blob: 90a8eaf11fcd53ad7204d38f9207855f4bde55b4 [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
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000025 <property name="gen" location="gen-java" />
26 <property name="genbean" location="gen-javabean" />
27
Mark Slee83c52a82006-06-07 06:51:18 +000028 <property name="src" location="src" />
29 <property name="build" location="build" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +000030 <property name="javadoc" location="${build}/javadoc" />
David Reissf0c21a72008-07-11 01:26:16 +000031 <property name="install.path" value="/usr/local/lib" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000032 <property name="src.test" location="test" />
33 <property name="build.test" location="${build}/test" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000034 <property name="test.thrift.home" location="../../test"/>
35
36 <property file="${user.home}/.thrift-build.properties" />
Bryan Duxbury538e3442009-02-10 04:49:39 +000037
David Reiss36a5a252009-04-29 23:20:56 +000038 <!-- ivy properties -->
39 <property name="ivy.version" value="2.0.0-rc2" />
40 <property name="ivy.dir" location="${build}/ivy" />
41 <property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/>
42 <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
43 <property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
44 <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
45
46 <path id="compile.classpath">
47 <fileset dir="${ivy.lib.dir}">
48 <include name="**/*.jar" />
49 </fileset>
50 </path>
51
52 <path id="test.classpath">
53 <path refid="compile.classpath" />
54 <pathelement location="build/test" />
55 <pathelement location="libthrift.jar" />
56 </path>
Bryan Duxbury538e3442009-02-10 04:49:39 +000057
Mark Slee83c52a82006-06-07 06:51:18 +000058 <target name="init">
59 <tstamp />
60 <mkdir dir="${build}"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000061 <mkdir dir="${build.test}" />
David Reiss36a5a252009-04-29 23:20:56 +000062 <!--
63 Allow Ivy to be disabled with "-Dnoivy=".
64 It is kind of a hack to pretend that we already found it,
65 but Ant doesn't provide an easy way of blocking dependencies
66 from executing or checking multiple conditions.
67 -->
68 <condition property="ivy.found"><isset property="noivy" /></condition>
69 <condition property="offline"><isset property="noivy" /></condition>
Mark Slee83c52a82006-06-07 06:51:18 +000070 </target>
71
David Reiss36a5a252009-04-29 23:20:56 +000072 <target name="ivy-init-dirs">
73 <mkdir dir="${ivy.dir}" />
74 <mkdir dir="${ivy.lib.dir}" />
75 </target>
76
77 <target name="ivy-download" depends="ivy-init-dirs" description="To download ivy" unless="offline">
78 <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
79 </target>
80
81 <target name="ivy-probe-antlib">
82 <condition property="ivy.found">
83 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
84 </condition>
85 </target>
86
87 <target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib" unless="ivy.found">
88 <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
89 loaderRef="ivyLoader">
90 <classpath>
91 <pathelement location="${ivy.jar}"/>
92 </classpath>
93 </typedef>
94 <fail>
95 <condition >
96 <not>
97 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
98 </not>
99 </condition>
100 You need Apache Ivy 2.0 or later from http://ant.apache.org/
101 It could not be loaded from ${ivy_repo_url}
102 </fail>
103 </target>
104
105 <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
106 <ivy:retrieve />
107 </target>
108
109 <target name="compile" depends="init,resolve">
Bryan Duxbury78753892009-05-06 17:22:11 +0000110 <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" />
Mark Slee83c52a82006-06-07 06:51:18 +0000111 </target>
112
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000113 <target name="javadoc" depends="init">
114 <javadoc sourcepath="${src}"
115 destdir="${javadoc}"
116 version="true"
117 windowtitle="Thrift Java API"
118 doctitle="Thrift Java API">
119 </javadoc>
Mark Slee83c52a82006-06-07 06:51:18 +0000120 </target>
121
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000122 <target name="dist" depends="compile">
123 <jar jarfile="libthrift.jar">
124 <fileset dir="${build}">
125 <include name="**/*.class" />
126 </fileset>
127 <fileset dir="src">
128 <include name="**/*.java" />
129 </fileset>
130 </jar>
131 </target>
132
133 <target name="install" depends="dist,javadoc">
Mark Slee54b7ab92007-03-06 00:06:27 +0000134 <exec executable="install">
David Reissf0c21a72008-07-11 01:26:16 +0000135 <arg line="libthrift.jar ${install.path}" />
Mark Slee83c52a82006-06-07 06:51:18 +0000136 </exec>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000137 <copy todir="${install.javadoc.path}">
138 <fileset dir="${javadoc}">
139 <include name="**/*" />
140 </fileset>
141 </copy>
Mark Slee83c52a82006-06-07 06:51:18 +0000142 </target>
143
144 <target name="clean">
145 <delete dir="${build}" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000146 <delete dir="${gen}"/>
147 <delete dir="${genbean}"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000148 <delete dir="${javadoc}"/>
Mark Slee83c52a82006-06-07 06:51:18 +0000149 <delete file="libthrift.jar" />
150 </target>
151
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000152 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
David Reiss36a5a252009-04-29 23:20:56 +0000153 <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" />
154 <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" />
155 <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000156 </target>
157
158 <target name="test" description="Run the full test suite" depends="compile-test">
159 <java classname="org.apache.thrift.test.JSONProtoTest"
David Reiss36a5a252009-04-29 23:20:56 +0000160 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury538e3442009-02-10 04:49:39 +0000161 <java classname="org.apache.thrift.test.TCompactProtocolTest"
David Reiss36a5a252009-04-29 23:20:56 +0000162 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000163 <java classname="org.apache.thrift.test.IdentityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000164 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000165 <java classname="org.apache.thrift.test.EqualityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000166 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000167 <java classname="org.apache.thrift.test.ToStringTest"
David Reiss36a5a252009-04-29 23:20:56 +0000168 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000169 <java classname="org.apache.thrift.test.DeepCopyTest"
David Reiss36a5a252009-04-29 23:20:56 +0000170 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury986d7052009-01-29 01:51:08 +0000171 <java classname="org.apache.thrift.test.MetaDataTest"
David Reiss36a5a252009-04-29 23:20:56 +0000172 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000173 <java classname="org.apache.thrift.test.JavaBeansTest"
David Reiss36a5a252009-04-29 23:20:56 +0000174 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000175 </target>
176
177 <target name="generate">
178 <exec executable="../../compiler/cpp/thrift">
179 <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
180 </exec>
181 <exec executable="../../compiler/cpp/thrift">
182 <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" />
183 </exec>
184 <exec executable="../../compiler/cpp/thrift">
185 <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" />
186 </exec>
187 <exec executable="../../compiler/cpp/thrift">
188 <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
189 </exec>
190 </target>
191
Mark Slee83c52a82006-06-07 06:51:18 +0000192</project>