Roger Meier | e5e50de | 2010-11-02 12:36:52 +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="test" basedir="." |
| 20 | xmlns:artifact="antlib:org.apache.maven.artifact.ant"> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 21 | |
| 22 | <description>Thrift JavaScript Tutorial</description> |
| 23 | |
| 24 | <property name="src" location="src" /> |
| 25 | <property name="javasrc" location="../java/src" /> |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 26 | <property name="gen" location="../java/gen-java" /> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 27 | <property name="build" location="build" /> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 28 | <property file="${basedir}/build.properties"/> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 29 | |
| 30 | <!-- the root directory, where you unpack thrift distibution (e.g. thrift-0.x.x.tar.gz) --> |
| 31 | <property name="thrift.dir" location="../../" /> |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 32 | <!-- JavaScript tutorial depends on the java tutorial thrift handler and server infrastructure --> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 33 | <property name="thrift.java.dir" location="${thrift.dir}/lib/java" /> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 34 | <property name="build.tools.dir" location="${thrift.java.dir}/build/tools/"/> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 35 | |
| 36 | <path id="libs.classpath"> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 37 | <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 Meier | 5fc6973 | 2011-04-08 21:28:50 +0000 | [diff] [blame] | 42 | </fileset> |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 43 | <fileset dir="${build}/lib"> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 44 | <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 Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 56 | <mkdir dir="${build}/lib"/> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 57 | </target> |
| 58 | |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 59 | <target name="compile" depends="init, resolve"> |
James E. King, III | cf25489 | 2017-01-25 20:34:04 -0500 | [diff] [blame] | 60 | <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 Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 62 | <exclude name="JavaClient.java"/> |
| 63 | <exclude name="JavaServer.java"/> |
| 64 | <include name="CalculatorHandler.java"/> |
| 65 | </javac> |
James E. King, III | cf25489 | 2017-01-25 20:34:04 -0500 | [diff] [blame] | 66 | <javac compiler="modern" includeantruntime="false" srcdir="${src}" destdir="${build}" classpathref="build.classpath"> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 67 | <compilerarg value="-Xlint:all"/> |
| 68 | </javac> |
| 69 | </target> |
| 70 | |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 71 | <target name="test" depends="tutorial" /> |
| 72 | |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 73 | <target name="tutorial" depends="compile"> |
| 74 | <jar jarfile="tutorial-js.jar" basedir="${build}"/> |
| 75 | </target> |
| 76 | |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 77 | <target name="tutorialserver" description="run the test server" depends="tutorial, generate"> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 78 | <java classname="Httpd" fork="true" |
| 79 | classpathref="build.classpath" failonerror="true"> |
| 80 | <arg value="../../" /> |
| 81 | </java> |
| 82 | </target> |
| 83 | |
Roger Meier | fa89932 | 2012-10-22 19:27:38 +0000 | [diff] [blame] | 84 | <target name="generate"> |
| 85 | <exec executable="../../compiler/cpp/thrift" failonerror="true"> |
| 86 | <arg line="--gen js -r ../tutorial.thrift"/> |
| 87 | </exec> |
| 88 | </target> |
Alex Volanis | 7004a61 | 2018-01-24 10:30:13 -0500 | [diff] [blame] | 89 | |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 90 | <target name="clean"> |
| 91 | <delete dir="${build}" /> |
Roger Meier | 18a90d1 | 2012-10-24 18:40:06 +0000 | [diff] [blame] | 92 | <delete dir="gen-js"/> |
Roger Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 93 | <delete file="tutorial-js.jar" /> |
| 94 | </target> |
| 95 | |
Jiayu Liu | eb62fa8 | 2022-05-08 13:01:41 +0800 | [diff] [blame] | 96 | <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 Meier | e5e50de | 2010-11-02 12:36:52 +0000 | [diff] [blame] | 127 | </project> |