blob: 0a7c8944d4c1035acaba948c43051dd40e8f3896 [file] [log] [blame]
Gavin McDonald0b75e1a2010-10-28 02:12:01 +00001<?xml version="1.0"?>
2<!--
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-->
20<project name="libthrift" default="dist" basedir="."
21 xmlns:ivy="antlib:org.apache.ivy.ant">
22
23 <description>Thrift Build File</description>
24
25 <property name="gen" location="gen-java" />
26 <property name="genbean" location="gen-javabean" />
27
28 <property name="src" location="src" />
29 <property name="build" location="build" />
30 <property name="javadoc" location="${build}/javadoc" />
31 <property name="install.path" value="/usr/local/lib" />
32 <property name="src.test" location="test" />
33 <property name="build.test" location="${build}/test" />
34 <property name="test.thrift.home" location="../../test"/>
35
36 <property file="${user.home}/.thrift-build.properties" />
37
38 <!-- 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>
57
58 <target name="init">
59 <tstamp />
60 <mkdir dir="${build}"/>
61 <mkdir dir="${build.test}" />
62 <!--
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>
70 </target>
71
72 <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">
110 <javac srcdir="${src}" destdir="${build}" source="1.5" debug="true" classpathref="compile.classpath" />
111 </target>
112
113 <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>
120 </target>
121
122 <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">
134 <exec executable="install">
135 <arg line="libthrift.jar ${install.path}" />
136 </exec>
137 <copy todir="${install.javadoc.path}">
138 <fileset dir="${javadoc}">
139 <include name="**/*" />
140 </fileset>
141 </copy>
142 </target>
143
144 <target name="clean">
145 <delete dir="${build}" />
146 <delete dir="${gen}"/>
147 <delete dir="${genbean}"/>
148 <delete dir="${javadoc}"/>
149 <delete file="libthrift.jar" />
150 </target>
151
152 <target name="compile-test" description="Build the test suite classes" depends="generate,dist">
153 <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" />
156 </target>
157
158 <target name="test" description="Run the full test suite" depends="compile-test">
159 <java classname="org.apache.thrift.test.JSONProtoTest"
160 classpathref="test.classpath" failonerror="true" />
161 <java classname="org.apache.thrift.test.TCompactProtocolTest"
162 classpathref="test.classpath" failonerror="true" />
163 <java classname="org.apache.thrift.test.IdentityTest"
164 classpathref="test.classpath" failonerror="true" />
165 <java classname="org.apache.thrift.test.EqualityTest"
166 classpathref="test.classpath" failonerror="true" />
167 <java classname="org.apache.thrift.test.ToStringTest"
168 classpathref="test.classpath" failonerror="true" />
169 <java classname="org.apache.thrift.test.DeepCopyTest"
170 classpathref="test.classpath" failonerror="true" />
171 <java classname="org.apache.thrift.test.MetaDataTest"
172 classpathref="test.classpath" failonerror="true" />
173 <java classname="org.apache.thrift.test.JavaBeansTest"
174 classpathref="test.classpath" failonerror="true" />
175 </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
192</project>