blob: 6bd5e89c6a4440abed30c50ba4bb7ac346b2382b [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"/>
37
38 <property file="${user.home}/.thrift-build.properties" />
Bryan Duxbury538e3442009-02-10 04:49:39 +000039
David Reiss36a5a252009-04-29 23:20:56 +000040 <!-- ivy properties -->
41 <property name="ivy.version" value="2.0.0-rc2" />
42 <property name="ivy.dir" location="${build}/ivy" />
43 <property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/>
44 <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
45 <property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
46 <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
47
48 <path id="compile.classpath">
49 <fileset dir="${ivy.lib.dir}">
50 <include name="**/*.jar" />
51 </fileset>
52 </path>
53
54 <path id="test.classpath">
55 <path refid="compile.classpath" />
David Reiss089164a2009-05-22 19:50:32 +000056 <pathelement path="${env.CLASSPATH}" />
David Reiss36a5a252009-04-29 23:20:56 +000057 <pathelement location="build/test" />
58 <pathelement location="libthrift.jar" />
59 </path>
Bryan Duxbury538e3442009-02-10 04:49:39 +000060
Mark Slee83c52a82006-06-07 06:51:18 +000061 <target name="init">
62 <tstamp />
63 <mkdir dir="${build}"/>
Bryan Duxbury249d7cb2009-01-29 01:21:20 +000064 <mkdir dir="${build.test}" />
David Reiss36a5a252009-04-29 23:20:56 +000065 <!--
66 Allow Ivy to be disabled with "-Dnoivy=".
67 It is kind of a hack to pretend that we already found it,
68 but Ant doesn't provide an easy way of blocking dependencies
69 from executing or checking multiple conditions.
70 -->
71 <condition property="ivy.found"><isset property="noivy" /></condition>
72 <condition property="offline"><isset property="noivy" /></condition>
Mark Slee83c52a82006-06-07 06:51:18 +000073 </target>
74
David Reiss36a5a252009-04-29 23:20:56 +000075 <target name="ivy-init-dirs">
76 <mkdir dir="${ivy.dir}" />
77 <mkdir dir="${ivy.lib.dir}" />
78 </target>
79
80 <target name="ivy-download" depends="ivy-init-dirs" description="To download ivy" unless="offline">
81 <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
82 </target>
83
84 <target name="ivy-probe-antlib">
85 <condition property="ivy.found">
86 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
87 </condition>
88 </target>
89
90 <target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib" unless="ivy.found">
91 <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
92 loaderRef="ivyLoader">
93 <classpath>
94 <pathelement location="${ivy.jar}"/>
95 </classpath>
96 </typedef>
97 <fail>
98 <condition >
99 <not>
100 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
101 </not>
102 </condition>
103 You need Apache Ivy 2.0 or later from http://ant.apache.org/
104 It could not be loaded from ${ivy_repo_url}
105 </fail>
106 </target>
107
108 <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
109 <ivy:retrieve />
110 </target>
111
112 <target name="compile" depends="init,resolve">
Bryan Duxbury78753892009-05-06 17:22:11 +0000113 <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" />
Mark Slee83c52a82006-06-07 06:51:18 +0000114 </target>
115
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000116 <target name="javadoc" depends="init">
117 <javadoc sourcepath="${src}"
118 destdir="${javadoc}"
119 version="true"
120 windowtitle="Thrift Java API"
121 doctitle="Thrift Java API">
122 </javadoc>
Mark Slee83c52a82006-06-07 06:51:18 +0000123 </target>
124
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000125 <target name="dist" depends="compile">
126 <jar jarfile="libthrift.jar">
127 <fileset dir="${build}">
128 <include name="**/*.class" />
129 </fileset>
130 <fileset dir="src">
131 <include name="**/*.java" />
132 </fileset>
133 </jar>
134 </target>
135
136 <target name="install" depends="dist,javadoc">
David Reiss56c2c212009-06-04 02:05:25 +0000137 <copy todir="${install.path}">
138 <fileset dir="."><include name="*.jar" /></fileset>
139 </copy>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000140 <copy todir="${install.javadoc.path}">
141 <fileset dir="${javadoc}">
142 <include name="**/*" />
143 </fileset>
144 </copy>
Mark Slee83c52a82006-06-07 06:51:18 +0000145 </target>
146
147 <target name="clean">
148 <delete dir="${build}" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000149 <delete dir="${gen}"/>
150 <delete dir="${genbean}"/>
Bryan Duxbury32e04b42009-03-20 16:43:06 +0000151 <delete dir="${javadoc}"/>
Mark Slee83c52a82006-06-07 06:51:18 +0000152 <delete file="libthrift.jar" />
153 </target>
154
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000155 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
David Reiss36a5a252009-04-29 23:20:56 +0000156 <javac debug="true" srcdir="${gen}" destdir="${build.test}" classpathref="test.classpath" />
157 <javac debug="true" srcdir="${genbean}" destdir="${build.test}" classpathref="test.classpath" />
158 <javac debug="true" srcdir="${src.test}" destdir="${build.test}" classpathref="test.classpath" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000159 </target>
160
161 <target name="test" description="Run the full test suite" depends="compile-test">
162 <java classname="org.apache.thrift.test.JSONProtoTest"
David Reiss36a5a252009-04-29 23:20:56 +0000163 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury538e3442009-02-10 04:49:39 +0000164 <java classname="org.apache.thrift.test.TCompactProtocolTest"
David Reiss36a5a252009-04-29 23:20:56 +0000165 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000166 <java classname="org.apache.thrift.test.IdentityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000167 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000168 <java classname="org.apache.thrift.test.EqualityTest"
David Reiss36a5a252009-04-29 23:20:56 +0000169 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000170 <java classname="org.apache.thrift.test.ToStringTest"
David Reiss36a5a252009-04-29 23:20:56 +0000171 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000172 <java classname="org.apache.thrift.test.DeepCopyTest"
David Reiss36a5a252009-04-29 23:20:56 +0000173 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury986d7052009-01-29 01:51:08 +0000174 <java classname="org.apache.thrift.test.MetaDataTest"
David Reiss36a5a252009-04-29 23:20:56 +0000175 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000176 <java classname="org.apache.thrift.test.JavaBeansTest"
David Reiss36a5a252009-04-29 23:20:56 +0000177 classpathref="test.classpath" failonerror="true" />
Bryan Duxbury249d7cb2009-01-29 01:21:20 +0000178 </target>
179
180 <target name="generate">
181 <exec executable="../../compiler/cpp/thrift">
182 <arg line="--gen java:hashcode ${test.thrift.home}/ThriftTest.thrift" />
183 </exec>
184 <exec executable="../../compiler/cpp/thrift">
185 <arg line="--gen java:hashcode ${test.thrift.home}/DebugProtoTest.thrift" />
186 </exec>
187 <exec executable="../../compiler/cpp/thrift">
188 <arg line="--gen java:hashcode ${test.thrift.home}/OptionalRequiredTest.thrift" />
189 </exec>
190 <exec executable="../../compiler/cpp/thrift">
191 <arg line="--gen java:beans,nocamel ${test.thrift.home}/JavaBeansTest.thrift" />
192 </exec>
193 </target>
194
Mark Slee83c52a82006-06-07 06:51:18 +0000195</project>