Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +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 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 10 | http://www.apache.org/licenses/LICENSE-2.0 |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 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 | --> |
| 19 | <project name="Java Script Test" default="test" basedir="." |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 20 | xmlns:artifact="antlib:org.apache.maven.artifact.ant" |
| 21 | xmlns:jsl="antlib:com.googlecode.jslint4java"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 22 | |
| 23 | <description>Java Script Test based on Thrift Java Library</description> |
| 24 | |
| 25 | <property name="src" location="src" /> |
| 26 | <property name="genjava" location="gen-java" /> |
| 27 | <property name="genjs" location="gen-js" /> |
| 28 | <property name="build" location="build" /> |
| 29 | <property name="jar.file" location="${basedir}/jstest.jar" /> |
| 30 | |
| 31 | <!-- the root directory, where you unpack thrift distibution (e.g. thrift-0.x.x.tar.gz) --> |
| 32 | <property name="thrift.dir" location="../../../" /> |
| 33 | <property name="thrift.java.dir" location="${thrift.dir}/lib/java" /> |
| 34 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 35 | <!-- Include the base java properties file --> |
| 36 | <property file="${thrift.java.dir}/build.properties" /> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 37 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 38 | <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" /> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 39 | |
| 40 | <path id="libs.classpath"> |
Roger Meier | 2fdf05c | 2011-03-25 11:37:16 +0000 | [diff] [blame] | 41 | <fileset dir="${thrift.java.dir}/build/"> |
| 42 | <include name="*.jar" /> |
| 43 | </fileset> |
| 44 | <fileset dir="${thrift.java.dir}/build/lib"> |
| 45 | <include name="*.jar" /> |
| 46 | </fileset> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 47 | <fileset dir="${build}/lib"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 48 | <include name="*.jar" /> |
| 49 | </fileset> |
| 50 | </path> |
| 51 | |
| 52 | <path id="test.classpath"> |
| 53 | <path refid="libs.classpath" /> |
| 54 | <pathelement location="${jar.file}" /> |
| 55 | </path> |
| 56 | |
| 57 | <target name="dependencies"> |
| 58 | <fail> |
| 59 | <condition> |
| 60 | <not> |
Roger Meier | 2fdf05c | 2011-03-25 11:37:16 +0000 | [diff] [blame] | 61 | <resourcecount count="2"> |
Roger Meier | a35944b | 2011-07-15 20:16:43 +0000 | [diff] [blame] | 62 | <fileset id="fs" dir="${thrift.java.dir}/build"> |
| 63 | <include name="libthrift*.jar" /> |
| 64 | <exclude name="libthrift*javadoc.jar" /> |
| 65 | </fileset> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 66 | </resourcecount> |
| 67 | </not> |
| 68 | </condition> |
Roger Meier | 2fdf05c | 2011-03-25 11:37:16 +0000 | [diff] [blame] | 69 | You need libthrift*.jar and libthrift*test.jar located at |
Roger Meier | 08b3099 | 2011-04-06 21:30:53 +0000 | [diff] [blame] | 70 | ${thrift.java.dir}/build |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 71 | Did you compile Thrift Java library and its test suite by "ant compile-test"? |
| 72 | </fail> |
| 73 | <fail> |
| 74 | <condition> |
| 75 | <not> |
| 76 | <resourcecount count="1"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 77 | <fileset id="fs" dir="${thrift.dir}" includes="compiler/cpp/thrift"/> |
| 78 | </resourcecount> |
| 79 | </not> |
| 80 | </condition> |
| 81 | Thrift compiler is missing ! |
| 82 | </fail> |
| 83 | </target> |
| 84 | |
| 85 | <target name="init" depends="dependencies"> |
| 86 | <tstamp /> |
| 87 | <mkdir dir="${build}"/> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 88 | <mkdir dir="${build}/lib"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 89 | </target> |
| 90 | |
| 91 | <target name="compile" description="compile the test suite" depends="init, generate, resolve"> |
| 92 | <javac srcdir="${genjava}" destdir="${build}" classpathref="libs.classpath" /> |
| 93 | <javac srcdir="${src}" destdir="${build}" classpathref="libs.classpath" /> |
| 94 | </target> |
| 95 | |
Roger Meier | 08b3099 | 2011-04-06 21:30:53 +0000 | [diff] [blame] | 96 | <target name="jstest" description="" depends="compile, lint"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 97 | <jar jarfile="${jar.file}" basedir="${build}"/> |
| 98 | </target> |
| 99 | |
Roger Meier | f249576 | 2011-03-17 19:13:36 +0000 | [diff] [blame] | 100 | <target name="testserver" description="run the test server" depends="jstest"> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 101 | <java classname="test.Httpd" fork="true" |
| 102 | classpathref="test.classpath" failonerror="true"> |
| 103 | <arg value="../" /> |
| 104 | </java> |
| 105 | </target> |
| 106 | |
| 107 | <target name="generate"> |
| 108 | <exec executable="${thrift.compiler}" failonerror="true"> |
| 109 | <arg line="--gen java ${thrift.dir}/test/ThriftTest.thrift" /> |
| 110 | </exec> |
| 111 | <exec executable="${thrift.compiler}" failonerror="true"> |
Roger Meier | 08b3099 | 2011-04-06 21:30:53 +0000 | [diff] [blame] | 112 | <arg line="--gen js:jquery ${thrift.dir}/test/ThriftTest.thrift" /> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 113 | </exec> |
| 114 | </target> |
| 115 | |
Roger Meier | f249576 | 2011-03-17 19:13:36 +0000 | [diff] [blame] | 116 | <!-- @TODO QUnit tests as part of the testsuite--> |
| 117 | <target name="test" description="run test suite" depends="init, generate, resolve, lint"/> |
| 118 | |
Roger Meier | 08b3099 | 2011-04-06 21:30:53 +0000 | [diff] [blame] | 119 | <target name="lint" description="code quality checks" depends="generate, gjslint, jslint"/> |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 120 | |
| 121 | <target name="jslint"> |
Roger Meier | 42a6fa4 | 2011-03-21 21:26:35 +0000 | [diff] [blame] | 122 | <taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpathref="libs.classpath" /> |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 123 | <!-- |
| 124 | the following options would probably make sense in the future: |
| 125 | browser,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed |
| 126 | --> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 127 | <jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed"> |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 128 | <formatter type="plain" /> |
| 129 | <fileset dir="${genjs}" includes="**/*.js" /> |
| 130 | <fileset dir=".." includes="thrift.js" /> |
| 131 | </jsl:jslint> |
| 132 | </target> |
| 133 | |
| 134 | <target name="check-gjslint"> |
| 135 | <echo>check if gjslint is available:</echo> |
| 136 | <exec executable="gjslint" failifexecutionfails="no" resultproperty="gjslint.present" failonerror="false"> |
| 137 | <arg line="--helpshort"/> |
| 138 | </exec> |
| 139 | </target> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 140 | |
Roger Meier | da6e6ae | 2011-03-15 09:55:33 +0000 | [diff] [blame] | 141 | <target name="gjslint" depends="check-gjslint" if="gjslint.present"> |
| 142 | <exec executable="gjslint" failifexecutionfails="no"> |
| 143 | <arg line="--nojsdoc"/> |
| 144 | <arg line="${genjs}/*.js"/> |
| 145 | <arg line="../thrift.js"/> |
| 146 | </exec> |
| 147 | </target> |
| 148 | |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 149 | <target name="clean"> |
| 150 | <delete dir="${build}" /> |
| 151 | <delete dir="${genjava}" /> |
| 152 | <delete dir="${genjs}" /> |
| 153 | <delete file="${jar.file}" /> |
| 154 | </target> |
| 155 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 156 | <target name="resolve" unless="mvn.finished"> |
| 157 | <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 158 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 159 | <artifact:dependencies filesetId="js.test.dependency.jars"> |
| 160 | <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/> |
| 161 | <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/> |
| 162 | </artifact:dependencies> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 163 | |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 164 | <!-- Copy the dependencies to the build/lib dir --> |
| 165 | <copy todir="${build}/lib"> |
| 166 | <fileset refid="js.test.dependency.jars"/> |
| 167 | <mapper type="flatten"/> |
| 168 | </copy> |
| 169 | |
| 170 | <property name="mvn.finished" value="true"/> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 171 | </target> |
Roger Meier | 37b5bf8 | 2010-10-24 21:41:24 +0000 | [diff] [blame] | 172 | </project> |
Jake Farrell | ad6426c | 2011-04-20 16:35:20 +0000 | [diff] [blame] | 173 | |