blob: fc9fbdf33fab0096094881819ae57803b51723bf [file] [log] [blame]
Roger Meiere5e50de2010-11-02 12:36:52 +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="test" basedir="."
20 xmlns:artifact="antlib:org.apache.maven.artifact.ant">
Roger Meiere5e50de2010-11-02 12:36:52 +000021
22 <description>Thrift JavaScript Tutorial</description>
23
24 <property name="src" location="src" />
25 <property name="javasrc" location="../java/src" />
Roger Meierfa899322012-10-22 19:27:38 +000026 <property name="gen" location="../java/gen-java" />
Roger Meiere5e50de2010-11-02 12:36:52 +000027 <property name="build" location="build" />
Jiayu Liueb62fa82022-05-08 13:01:41 +080028 <property file="${basedir}/build.properties"/>
Roger Meiere5e50de2010-11-02 12:36:52 +000029
30 <!-- the root directory, where you unpack thrift distibution (e.g. thrift-0.x.x.tar.gz) -->
31 <property name="thrift.dir" location="../../" />
Roger Meierfa899322012-10-22 19:27:38 +000032 <!-- JavaScript tutorial depends on the java tutorial thrift handler and server infrastructure -->
Roger Meiere5e50de2010-11-02 12:36:52 +000033 <property name="thrift.java.dir" location="${thrift.dir}/lib/java" />
Jiayu Liueb62fa82022-05-08 13:01:41 +080034 <property name="build.tools.dir" location="${thrift.java.dir}/build/tools/"/>
Roger Meiere5e50de2010-11-02 12:36:52 +000035
36 <path id="libs.classpath">
Alex Volanis7004a612018-01-24 10:30:13 -050037 <fileset dir="${thrift.java.dir}/build/libs">
38 <include name="libthrift*.jar" />
39 <exclude name="libthrift*test.jar" />
40 <exclude name="libthrift*javadoc.jar" />
41 <exclude name="libthrift*sources.jar" />
Roger Meier5fc69732011-04-08 21:28:50 +000042 </fileset>
Jiayu Liueb62fa82022-05-08 13:01:41 +080043 <fileset dir="${build}/lib">
Roger Meiere5e50de2010-11-02 12:36:52 +000044 <include name="*.jar" />
45 </fileset>
46 </path>
47 <path id="build.classpath">
48 <path refid="libs.classpath" />
49 <pathelement path="${gen}" />
50 <pathelement path="${build}" />
51 </path>
52
53 <target name="init">
54 <tstamp />
55 <mkdir dir="${build}"/>
Jiayu Liueb62fa82022-05-08 13:01:41 +080056 <mkdir dir="${build}/lib"/>
Roger Meiere5e50de2010-11-02 12:36:52 +000057 </target>
58
Jiayu Liueb62fa82022-05-08 13:01:41 +080059 <target name="compile" depends="init, resolve">
James E. King, IIIcf254892017-01-25 20:34:04 -050060 <javac compiler="modern" includeantruntime="false" srcdir="${gen}" destdir="${build}" classpathref="libs.classpath" />
61 <javac compiler="modern" includeantruntime="false" srcdir="${javasrc}" destdir="${build}" classpathref="build.classpath">
Roger Meiere5e50de2010-11-02 12:36:52 +000062 <exclude name="JavaClient.java"/>
63 <exclude name="JavaServer.java"/>
64 <include name="CalculatorHandler.java"/>
65 </javac>
James E. King, IIIcf254892017-01-25 20:34:04 -050066 <javac compiler="modern" includeantruntime="false" srcdir="${src}" destdir="${build}" classpathref="build.classpath">
Roger Meiere5e50de2010-11-02 12:36:52 +000067 <compilerarg value="-Xlint:all"/>
68 </javac>
69 </target>
70
Roger Meierfa899322012-10-22 19:27:38 +000071 <target name="test" depends="tutorial" />
72
Roger Meiere5e50de2010-11-02 12:36:52 +000073 <target name="tutorial" depends="compile">
74 <jar jarfile="tutorial-js.jar" basedir="${build}"/>
75 </target>
76
Roger Meierfa899322012-10-22 19:27:38 +000077 <target name="tutorialserver" description="run the test server" depends="tutorial, generate">
Roger Meiere5e50de2010-11-02 12:36:52 +000078 <java classname="Httpd" fork="true"
79 classpathref="build.classpath" failonerror="true">
80 <arg value="../../" />
81 </java>
82 </target>
83
Roger Meierfa899322012-10-22 19:27:38 +000084 <target name="generate">
85 <exec executable="../../compiler/cpp/thrift" failonerror="true">
86 <arg line="--gen js -r ../tutorial.thrift"/>
87 </exec>
88 </target>
Alex Volanis7004a612018-01-24 10:30:13 -050089
Roger Meiere5e50de2010-11-02 12:36:52 +000090 <target name="clean">
91 <delete dir="${build}" />
Roger Meier18a90d12012-10-24 18:40:06 +000092 <delete dir="gen-js"/>
Roger Meiere5e50de2010-11-02 12:36:52 +000093 <delete file="tutorial-js.jar" />
94 </target>
95
Jiayu Liueb62fa82022-05-08 13:01:41 +080096 <target name="mvn.ant.tasks.download" depends="init, mvn.ant.tasks.check" unless="mvn.ant.tasks.found">
97 <get src="${mvn.ant.task.url}/${mvn.ant.task.jar}" dest="${build.tools.dir}/${mvn.ant.task.jar}" usetimestamp="true"/>
98 </target>
99
100 <target name="mvn.ant.tasks.check">
101 <condition property="mvn.ant.tasks.found">
102 <typefound uri="antlib:org.apache.maven.artifact.ant" name="artifact"/>
103 </condition>
104 </target>
105
106 <target name="resolve" depends="mvn.ant.tasks.download" unless="mvn.finished">
107 <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/>
108
109 <artifact:dependencies filesetId="tutorial.dependency.jars">
110 <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/>
111 <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/>
112 <dependency groupId="eu.medsea.mimeutil" artifactId="mime-util" version="2.1.3"/>
113 <dependency groupId="javax.annotation" artifactId="javax.annotation-api" version="1.3.2"/>
114 <dependency groupId="org.slf4j" artifactId="slf4j-api" version="1.7.5"/>
115 <remoteRepository url="${mvn.repo}"/>
116 </artifact:dependencies>
117
118 <!-- Copy the dependencies to the build/lib dir -->
119 <copy todir="${build}/lib">
120 <fileset refid="tutorial.dependency.jars"/>
121 <mapper type="flatten"/>
122 </copy>
123
124 <property name="mvn.finished" value="true"/>
125 </target>
126
Roger Meiere5e50de2010-11-02 12:36:52 +0000127</project>