David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | <!-- |
| 2 | Licensed to the Apache Software Foundation (ASF) under one |
| 3 | or more contributor license agreements. See the NOTICE file |
| 4 | distributed with this work for additional information |
| 5 | regarding copyright ownership. The ASF licenses this file |
| 6 | to you under the Apache License, Version 2.0 (the |
| 7 | "License"); you may not use this file except in compliance |
| 8 | with the License. You may obtain a copy of the License at |
| 9 | |
| 10 | http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | |
| 12 | Unless required by applicable law or agreed to in writing, |
| 13 | software distributed under the License is distributed on an |
| 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | KIND, either express or implied. See the License for the |
| 16 | specific language governing permissions and limitations |
| 17 | under the License. |
| 18 | --> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 19 | <project name="tutorial" default="tutorial" basedir="." |
| 20 | xmlns:artifact="antlib:org.apache.maven.artifact.ant"> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 21 | |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 22 | <description>Thrift Java Tutorial</description> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 23 | |
| 24 | <property name="src" location="src" /> |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 25 | <property name="gen" location="gen-java" /> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 26 | <property name="build" location="build" /> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 27 | <property file="${basedir}/build.properties"/> |
| 28 | |
| 29 | <!-- the root directory, where you unpack thrift distibution (e.g.: thrift-0.x.x.tar.gz) --> |
| 30 | <property name="thrift.dir" location="../.." /> |
| 31 | <property name="thrift.java.dir" location="${thrift.dir}/lib/java" /> |
| 32 | <property name="build.tools.dir" location="${thrift.java.dir}/build/tools/"/> |
Todd Lipcon | 515c238 | 2010-09-27 18:26:07 +0000 | [diff] [blame] | 33 | |
| 34 | <path id="libs.classpath"> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 35 | <fileset dir="${thrift.java.dir}/build/libs"> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 36 | <include name="libthrift*.jar" /> |
| 37 | <exclude name="libthrift*test.jar" /> |
| 38 | <exclude name="libthrift*javadoc.jar" /> |
| 39 | <exclude name="libthrift*sources.jar" /> |
Roger Meier | 5fc6973 | 2011-04-08 21:28:50 +0000 | [diff] [blame] | 40 | </fileset> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 41 | <fileset dir="${build}/lib"> |
Todd Lipcon | 515c238 | 2010-09-27 18:26:07 +0000 | [diff] [blame] | 42 | <include name="*.jar" /> |
| 43 | </fileset> |
| 44 | </path> |
| 45 | <path id="build.classpath"> |
| 46 | <path refid="libs.classpath" /> |
| 47 | <pathelement path="${gen}" /> |
| 48 | </path> |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 49 | <path id="tutorial.classpath"> |
| 50 | <path refid="build.classpath" /> |
| 51 | <pathelement path="${build}" /> |
| 52 | <pathelement path="tutorial.jar" /> |
| 53 | </path> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 54 | |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 55 | <target name="init"> |
| 56 | <tstamp /> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 57 | <mkdir dir="${build.tools.dir}"/> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 58 | <mkdir dir="${build}"/> |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 59 | <mkdir dir="${build}/log"/> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 60 | <mkdir dir="${build}/lib"/> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 61 | </target> |
| 62 | |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 63 | <target name="compile" depends="init, generate, resolve"> |
James E. King, III | cf25489 | 2017-01-25 20:34:04 -0500 | [diff] [blame] | 64 | <javac compiler="modern" includeantruntime="false" srcdir="${gen}" destdir="${build}" classpathref="libs.classpath" /> |
| 65 | <javac compiler="modern" includeantruntime="false" srcdir="${src}" destdir="${build}" classpathref="build.classpath" /> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 66 | </target> |
| 67 | |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 68 | <target name="test" depends="tutorial" /> |
| 69 | |
| 70 | <target name="tutorial" description="Run the tutorial" depends="compile"> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 71 | <jar jarfile="tutorial.jar" basedir="${build}"/> |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 72 | <parallel> |
| 73 | <java classname="JavaServer" fork="true" timeout="10000" |
| 74 | classpathref="tutorial.classpath" failonerror="false" output="${build}/log/tutorial.log"> |
| 75 | </java> |
| 76 | <sequential> |
| 77 | <sleep seconds="2"/> |
| 78 | <echo>tutorial client simple:</echo> |
| 79 | <java classname="JavaClient" |
| 80 | classpathref="tutorial.classpath" failonerror="true"> |
| 81 | <arg line="simple"/> |
| 82 | </java> |
| 83 | <echo>tutorial client secure:</echo> |
| 84 | <java classname="JavaClient" |
| 85 | classpathref="tutorial.classpath" failonerror="true"> |
| 86 | <arg line="secure"/> |
| 87 | </java> |
| 88 | </sequential> |
| 89 | </parallel> |
| 90 | </target> |
| 91 | |
| 92 | <target name="generate"> |
| 93 | <!-- Generate the thrift gen-java source --> |
| 94 | <exec executable="../../compiler/cpp/thrift" failonerror="true"> |
| 95 | <arg line="--gen java -r ../tutorial.thrift"/> |
| 96 | </exec> |
| 97 | </target> |
| 98 | |
| 99 | <target name="tutorialclient" description="Run a tutorial client" depends="compile"> |
| 100 | <echo>tutorial client simple:</echo> |
| 101 | <java classname="JavaClient" |
| 102 | classpathref="tutorial.classpath" failonerror="true"> |
| 103 | <arg line="simple"/> |
| 104 | </java> |
| 105 | <echo>tutorial client secure:</echo> |
| 106 | <java classname="JavaClient" |
| 107 | classpathref="tutorial.classpath" failonerror="true"> |
| 108 | <arg line="secure"/> |
| 109 | </java> |
| 110 | </target> |
| 111 | |
| 112 | <target name="tutorialserver" description="Run a tutorial server" depends="compile"> |
| 113 | <java classname="JavaServer" fork="true" |
| 114 | classpathref="tutorial.classpath" failonerror="false" output="${build}/log/tutorial.log"> |
| 115 | </java> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 116 | </target> |
| 117 | |
| 118 | <target name="clean"> |
| 119 | <delete dir="${build}" /> |
Roger Meier | 18a90d1 | 2012-10-24 18:40:06 +0000 | [diff] [blame] | 120 | <delete dir="${gen}"/> |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 121 | <delete file="tutorial.jar" /> |
| 122 | </target> |
| 123 | |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 124 | <target name="mvn.ant.tasks.download" depends="init, mvn.ant.tasks.check" unless="mvn.ant.tasks.found"> |
| 125 | <get src="${mvn.ant.task.url}/${mvn.ant.task.jar}" dest="${build.tools.dir}/${mvn.ant.task.jar}" usetimestamp="true"/> |
| 126 | </target> |
| 127 | |
| 128 | <target name="mvn.ant.tasks.check"> |
| 129 | <condition property="mvn.ant.tasks.found"> |
| 130 | <typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/> |
| 131 | </condition> |
| 132 | </target> |
| 133 | |
| 134 | <target name="resolve" depends="mvn.ant.tasks.download" unless="mvn.finished"> |
| 135 | <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/> |
| 136 | |
| 137 | <artifact:dependencies filesetId="tutorial.dependency.jars"> |
| 138 | <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/> |
| 139 | <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/> |
| 140 | <dependency groupId="eu.medsea.mimeutil" artifactId="mime-util" version="2.1.3"/> |
| 141 | <dependency groupId="javax.annotation" artifactId="javax.annotation-api" version="1.3.2"/> |
| 142 | <remoteRepository url="${mvn.repo}"/> |
| 143 | </artifact:dependencies> |
| 144 | |
| 145 | <!-- Copy the dependencies to the build/lib dir --> |
| 146 | <copy todir="${build}/lib"> |
| 147 | <fileset refid="tutorial.dependency.jars"/> |
| 148 | <mapper type="flatten"/> |
| 149 | </copy> |
| 150 | |
| 151 | <property name="mvn.finished" value="true"/> |
| 152 | </target> |
| 153 | |
Mark Slee | cb39f08 | 2007-04-10 02:30:30 +0000 | [diff] [blame] | 154 | </project> |