David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 1 | <?xml version="1.0"?> |
David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 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 | --> |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 20 | <project name="libthrift" default="dist" basedir="." |
| 21 | xmlns:ivy="antlib:org.apache.ivy.ant"> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 22 | |
| 23 | <description>Thrift Build File</description> |
| 24 | |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 25 | <property name="gen" location="gen-java" /> |
| 26 | <property name="genbean" location="gen-javabean" /> |
| 27 | |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 28 | <property name="src" location="src" /> |
| 29 | <property name="build" location="build" /> |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 30 | <property name="javadoc" location="${build}/javadoc" /> |
David Reiss | f0c21a7 | 2008-07-11 01:26:16 +0000 | [diff] [blame] | 31 | <property name="install.path" value="/usr/local/lib" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 32 | <property name="src.test" location="test" /> |
| 33 | <property name="build.test" location="${build}/test" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 34 | <property name="test.thrift.home" location="../../test"/> |
| 35 | |
| 36 | <property file="${user.home}/.thrift-build.properties" /> |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 37 | |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 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> |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 57 | |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 58 | <target name="init"> |
| 59 | <tstamp /> |
| 60 | <mkdir dir="${build}"/> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 61 | <mkdir dir="${build.test}" /> |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 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> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 70 | </target> |
| 71 | |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 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"> |
Bryan Duxbury | 7875389 | 2009-05-06 17:22:11 +0000 | [diff] [blame^] | 110 | <javac srcdir="${src}" destdir="${build}" source="1.5" target="1.5" debug="true" classpathref="compile.classpath" /> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 111 | </target> |
| 112 | |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 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> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 120 | </target> |
| 121 | |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 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"> |
Mark Slee | 54b7ab9 | 2007-03-06 00:06:27 +0000 | [diff] [blame] | 134 | <exec executable="install"> |
David Reiss | f0c21a7 | 2008-07-11 01:26:16 +0000 | [diff] [blame] | 135 | <arg line="libthrift.jar ${install.path}" /> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 136 | </exec> |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 137 | <copy todir="${install.javadoc.path}"> |
| 138 | <fileset dir="${javadoc}"> |
| 139 | <include name="**/*" /> |
| 140 | </fileset> |
| 141 | </copy> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 142 | </target> |
| 143 | |
| 144 | <target name="clean"> |
| 145 | <delete dir="${build}" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 146 | <delete dir="${gen}"/> |
| 147 | <delete dir="${genbean}"/> |
Bryan Duxbury | 32e04b4 | 2009-03-20 16:43:06 +0000 | [diff] [blame] | 148 | <delete dir="${javadoc}"/> |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 149 | <delete file="libthrift.jar" /> |
| 150 | </target> |
| 151 | |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 152 | <target name="compile-test" description="Build the test suite classes" depends="generate,dist"> |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 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" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 156 | </target> |
| 157 | |
| 158 | <target name="test" description="Run the full test suite" depends="compile-test"> |
| 159 | <java classname="org.apache.thrift.test.JSONProtoTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 160 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 538e344 | 2009-02-10 04:49:39 +0000 | [diff] [blame] | 161 | <java classname="org.apache.thrift.test.TCompactProtocolTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 162 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 163 | <java classname="org.apache.thrift.test.IdentityTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 164 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 165 | <java classname="org.apache.thrift.test.EqualityTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 166 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 167 | <java classname="org.apache.thrift.test.ToStringTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 168 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 169 | <java classname="org.apache.thrift.test.DeepCopyTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 170 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 986d705 | 2009-01-29 01:51:08 +0000 | [diff] [blame] | 171 | <java classname="org.apache.thrift.test.MetaDataTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 172 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 173 | <java classname="org.apache.thrift.test.JavaBeansTest" |
David Reiss | 36a5a25 | 2009-04-29 23:20:56 +0000 | [diff] [blame] | 174 | classpathref="test.classpath" failonerror="true" /> |
Bryan Duxbury | 249d7cb | 2009-01-29 01:21:20 +0000 | [diff] [blame] | 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 | |
Mark Slee | 83c52a8 | 2006-06-07 06:51:18 +0000 | [diff] [blame] | 192 | </project> |