blob: dbbaf6b5783020756d61a08e3ef884e1191e1c36 [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
David Reiss089164a2009-05-22 19:50:32 +000025 <property environment="env" />
26
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000027 <property name="gen" location="gen-java" />
28 <property name="genbean" location="gen-javabean" />
29
Mark Slee83c52a82006-06-07 06:51:18 +000030 <property name="src" location="src" />
31 <property name="build" location="build" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +000032 <property name="javadoc" location="${build}/javadoc" />
David Reissf0c21a72008-07-11 01:26:16 +000033 <property name="install.path" value="/usr/local/lib" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000034 <property name="src.test" location="test" />
35 <property name="build.test" location="${build}/test" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000036 <property name="test.thrift.home" location="../../test"/>
Bryan Duxbury2f45e782009-08-20 00:55:12 +000037 <property name="thrift.root" location="../../"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000038
39 <property file="${user.home}/.thrift-build.properties" />
Bryan Duxbury538e3442009-02-10 04:49:39 +000040
David Reiss36a5a252009-04-29 23:20:56 +000041 <!-- ivy properties -->
42 <property name="ivy.version" value="2.0.0-rc2" />
43 <property name="ivy.dir" location="${build}/ivy" />
44 <property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/>
45 <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
46 <property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
47 <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
48
49 <path id="compile.classpath">
50 <fileset dir="${ivy.lib.dir}">
51 <include name="**/*.jar" />
52 </fileset>
53 </path>
54
55 <path id="test.classpath">
56 <path refid="compile.classpath" />
David Reiss089164a2009-05-22 19:50:32 +000057 <pathelement path="${env.CLASSPATH}" />
David Reiss36a5a252009-04-29 23:20:56 +000058 <pathelement location="build/test" />
59 <pathelement location="libthrift.jar" />
60 </path>
Bryan Duxbury538e3442009-02-10 04:49:39 +000061
Mark Slee83c52a82006-06-07 06:51:18 +000062 <target name="init">
63 <tstamp />
64 <mkdir dir="${build}"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000065 <mkdir dir="${build.test}" />
David Reiss36a5a252009-04-29 23:20:56 +000066 <!--
67 Allow Ivy to be disabled with "-Dnoivy=".
68 It is kind of a hack to pretend that we already found it,
69 but Ant doesn't provide an easy way of blocking dependencies
70 from executing or checking multiple conditions.
71 -->
72 <condition property="ivy.found"><isset property="noivy" /></condition>
73 <condition property="offline"><isset property="noivy" /></condition>
Mark Slee83c52a82006-06-07 06:51:18 +000074 </target>
75
David Reiss36a5a252009-04-29 23:20:56 +000076 <target name="ivy-init-dirs">
77 <mkdir dir="${ivy.dir}" />
78 <mkdir dir="${ivy.lib.dir}" />
79 </target>
80
81 <target name="ivy-download" depends="ivy-init-dirs" description="To download ivy" unless="offline">
82 <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
83 </target>
84
85 <target name="ivy-probe-antlib">
86 <condition property="ivy.found">
87 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
88 </condition>
89 </target>
90
91 <target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib" unless="ivy.found">
92 <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
93 loaderRef="ivyLoader">
94 <classpath>
95 <pathelement location="${ivy.jar}"/>
96 </classpath>
97 </typedef>
98 <fail>
99 <condition >
100 <not>
101 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
102 </not>
103 </condition>
104 You need Apache Ivy 2.0 or later from http://ant.apache.org/
105 It could not be loaded from ${ivy_repo_url}
106 </fail>
107 </target>
108
109 <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
110 <ivy:retrieve />
111 </target>
112
113 <target name="compile" depends="init,resolve">
Bryan Duxbury78753892009-05-06 17:22:11 +0000114 <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" />
Mark Slee83c52a82006-06-07 06:51:18 +0000115 </target>
116
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000117 <target name="javadoc" depends="init">
118 <javadoc sourcepath="${src}"
119 destdir="${javadoc}"
120 version="true"
121 windowtitle="Thrift Java API"
122 doctitle="Thrift Java API">
123 </javadoc>
Mark Slee83c52a82006-06-07 06:51:18 +0000124 </target>
125
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000126 <target name="dist" depends="compile">
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000127 <mkdir dir="${build}/META-INF"/>
128 <copy file="${thrift.root}/LICENSE" tofile="${build}/META-INF/LICENSE.txt"/>
129 <copy file="${thrift.root}/NOTICE" tofile="${build}/META-INF/NOTICE.txt"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000130 <jar jarfile="libthrift.jar">
131 <fileset dir="${build}">
132 <include name="**/*.class" />
Bryan Duxbury2f45e782009-08-20 00:55:12 +0000133 <include name="META-INF/*.txt" />
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000134 </fileset>
135 <fileset dir="src">
136 <include name="**/*.java" />
137 </fileset>
138 </jar>
139 </target>
140
141 <target name="install" depends="dist,javadoc">
David Reiss56c2c212009-06-04 02:05:25 +0000142 <copy todir="${install.path}">
143 <fileset dir="."><include name="*.jar" /></fileset>
144 </copy>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000145 <copy todir="${install.javadoc.path}">
146 <fileset dir="${javadoc}">
147 <include name="**/*" />
148 </fileset>
149 </copy>
Mark Slee83c52a82006-06-07 06:51:18 +0000150 </target>
151
152 <target name="clean">
153 <delete dir="${build}" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000154 <delete dir="${gen}"/>
155 <delete dir="${genbean}"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000156 <delete dir="${javadoc}"/>
Mark Slee83c52a82006-06-07 06:51:18 +0000157 <delete file="libthrift.jar" />
158 </target>
159
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000160 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
David Reiss36a5a252009-04-29 23:20:56 +0000161 <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" />
162 <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" />
163 <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000164 </target>
165
166 <target name="test" description="Run the full test suite" depends="compile-test">
167 <java classname="org.apache.thrift.test.JSONProtoTest"
David Reiss36a5a252009-04-29 23:20:56 +0000168 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury538e3442009-02-10 04:49:39 +0000169 <java classname="org.apache.thrift.test.TCompactProtocolTest"
David Reiss36a5a252009-04-29 23:20:56 +0000170 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000171 <java classname="org.apache.thrift.test.IdentityTest"
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.EqualityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000174 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000175 <java classname="org.apache.thrift.test.ToStringTest"
David Reiss36a5a252009-04-29 23:20:56 +0000176 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000177 <java classname="org.apache.thrift.test.DeepCopyTest"
David Reiss36a5a252009-04-29 23:20:56 +0000178 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury986d7052009-01-29 01:51:08 +0000179 <java classname="org.apache.thrift.test.MetaDataTest"
David Reiss36a5a252009-04-29 23:20:56 +0000180 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000181 <java classname="org.apache.thrift.test.JavaBeansTest"
David Reiss36a5a252009-04-29 23:20:56 +0000182 classpathref="test.classpath" failonerror="true" />
Bryan Duxburyab3666e2009-09-01 23:03:47 +0000183 <java classname="org.apache.thrift.test.UnionTest"
184 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000185 </target>
186
187 <target name="generate">
188 <exec executable="../../compiler/cpp/thrift">
189 <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
190 </exec>
191 <exec executable="../../compiler/cpp/thrift">
192 <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" />
193 </exec>
194 <exec executable="../../compiler/cpp/thrift">
195 <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" />
196 </exec>
197 <exec executable="../../compiler/cpp/thrift">
198 <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
199 </exec>
200 </target>
201
Mark Slee83c52a82006-06-07 06:51:18 +0000202</project>