blob: 3f837764e94a3b5cd81727f0aaff3fe9b807b984 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001<!--
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 Liueb62fa82022-05-08 13:01:41 +080019<project name="tutorial" default="tutorial" basedir="."
20 xmlns:artifact="antlib:org.apache.maven.artifact.ant">
Mark Sleecb39f082007-04-10 02:30:30 +000021
Roger Meierfa899322012-10-22 19:27:38 +000022 <description>Thrift Java Tutorial</description>
Mark Sleecb39f082007-04-10 02:30:30 +000023
24 <property name="src" location="src" />
Roger Meierfa899322012-10-22 19:27:38 +000025 <property name="gen" location="gen-java" />
Mark Sleecb39f082007-04-10 02:30:30 +000026 <property name="build" location="build" />
Jiayu Liueb62fa82022-05-08 13:01:41 +080027 <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 Lipcon515c2382010-09-27 18:26:07 +000033
34 <path id="libs.classpath">
Jiayu Liueb62fa82022-05-08 13:01:41 +080035 <fileset dir="${thrift.java.dir}/build/libs">
Alex Volanis7004a612018-01-24 10:30:13 -050036 <include name="libthrift*.jar" />
37 <exclude name="libthrift*test.jar" />
38 <exclude name="libthrift*javadoc.jar" />
39 <exclude name="libthrift*sources.jar" />
Roger Meier5fc69732011-04-08 21:28:50 +000040 </fileset>
Jiayu Liueb62fa82022-05-08 13:01:41 +080041 <fileset dir="${build}/lib">
Todd Lipcon515c2382010-09-27 18:26:07 +000042 <include name="*.jar" />
43 </fileset>
44 </path>
45 <path id="build.classpath">
46 <path refid="libs.classpath" />
47 <pathelement path="${gen}" />
48 </path>
Roger Meierfa899322012-10-22 19:27:38 +000049 <path id="tutorial.classpath">
50 <path refid="build.classpath" />
51 <pathelement path="${build}" />
52 <pathelement path="tutorial.jar" />
53 </path>
Alex Volanis7004a612018-01-24 10:30:13 -050054
Mark Sleecb39f082007-04-10 02:30:30 +000055 <target name="init">
56 <tstamp />
Jiayu Liueb62fa82022-05-08 13:01:41 +080057 <mkdir dir="${build.tools.dir}"/>
Mark Sleecb39f082007-04-10 02:30:30 +000058 <mkdir dir="${build}"/>
Roger Meierfa899322012-10-22 19:27:38 +000059 <mkdir dir="${build}/log"/>
Jiayu Liueb62fa82022-05-08 13:01:41 +080060 <mkdir dir="${build}/lib"/>
Mark Sleecb39f082007-04-10 02:30:30 +000061 </target>
62
Jiayu Liueb62fa82022-05-08 13:01:41 +080063 <target name="compile" depends="init, generate, resolve">
James E. King, IIIcf254892017-01-25 20:34:04 -050064 <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 Sleecb39f082007-04-10 02:30:30 +000066 </target>
67
Roger Meierfa899322012-10-22 19:27:38 +000068 <target name="test" depends="tutorial" />
69
70 <target name="tutorial" description="Run the tutorial" depends="compile">
Mark Sleecb39f082007-04-10 02:30:30 +000071 <jar jarfile="tutorial.jar" basedir="${build}"/>
Roger Meierfa899322012-10-22 19:27:38 +000072 <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 Sleecb39f082007-04-10 02:30:30 +0000116 </target>
117
118 <target name="clean">
119 <delete dir="${build}" />
Roger Meier18a90d12012-10-24 18:40:06 +0000120 <delete dir="${gen}"/>
Mark Sleecb39f082007-04-10 02:30:30 +0000121 <delete file="tutorial.jar" />
122 </target>
123
Jiayu Liueb62fa82022-05-08 13:01:41 +0800124 <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 Sleecb39f082007-04-10 02:30:30 +0000154</project>