|  | <!-- | 
|  | Licensed to the Apache Software Foundation (ASF) under one | 
|  | or more contributor license agreements. See the NOTICE file | 
|  | distributed with this work for additional information | 
|  | regarding copyright ownership. The ASF licenses this file | 
|  | to you under the Apache License, Version 2.0 (the | 
|  | "License"); you may not use this file except in compliance | 
|  | with the License. You may obtain a copy of the License at | 
|  |  | 
|  | http://www.apache.org/licenses/LICENSE-2.0 | 
|  |  | 
|  | Unless required by applicable law or agreed to in writing, | 
|  | software distributed under the License is distributed on an | 
|  | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | 
|  | KIND, either express or implied. See the License for the | 
|  | specific language governing permissions and limitations | 
|  | under the License. | 
|  | --> | 
|  | <project name="Java Script Test" default="test" basedir="." | 
|  | xmlns:artifact="antlib:org.apache.maven.artifact.ant" | 
|  | xmlns:jsl="antlib:com.googlecode.jslint4java"> | 
|  |  | 
|  | <description>Java Script Test based on Thrift Java Library</description> | 
|  |  | 
|  | <property name="src" location="src" /> | 
|  | <property name="genjava" location="gen-java" /> | 
|  | <property name="genjs" location="gen-js" /> | 
|  | <property name="build" location="build" /> | 
|  | <property name="jar.file" location="${basedir}/jstest.jar" /> | 
|  |  | 
|  | <!-- the root directory, where you unpack thrift distibution (e.g. thrift-0.x.x.tar.gz) --> | 
|  | <property name="thrift.dir" location="../../../" /> | 
|  | <property name="thrift.java.dir" location="${thrift.dir}/lib/java" /> | 
|  |  | 
|  | <!-- Include the base java properties file --> | 
|  | <property file="${thrift.java.dir}/build.properties" /> | 
|  |  | 
|  | <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" /> | 
|  |  | 
|  | <path id="libs.classpath"> | 
|  | <fileset dir="${thrift.java.dir}/build/"> | 
|  | <include name="*.jar" /> | 
|  | </fileset> | 
|  | <fileset dir="${thrift.java.dir}/build/lib"> | 
|  | <include name="*.jar" /> | 
|  | </fileset> | 
|  | <fileset dir="${build}/lib"> | 
|  | <include name="*.jar" /> | 
|  | </fileset> | 
|  | </path> | 
|  |  | 
|  | <path id="test.classpath"> | 
|  | <path refid="libs.classpath" /> | 
|  | <pathelement location="${jar.file}" /> | 
|  | </path> | 
|  |  | 
|  | <target name="dependencies"> | 
|  | <fail> | 
|  | <condition> | 
|  | <not> | 
|  | <resourcecount count="2"> | 
|  | <fileset id="fs" dir="${thrift.java.dir}/build"> | 
|  | <include name="libthrift*.jar" /> | 
|  | <exclude name="libthrift*javadoc.jar" /> | 
|  | </fileset> | 
|  | </resourcecount> | 
|  | </not> | 
|  | </condition> | 
|  | You need libthrift*.jar and libthrift*test.jar located at | 
|  | ${thrift.java.dir}/build | 
|  | Did you compile Thrift Java library and its test suite by "ant compile-test"? | 
|  | </fail> | 
|  | <fail> | 
|  | <condition> | 
|  | <not> | 
|  | <resourcecount count="1"> | 
|  | <fileset id="fs" dir="${thrift.dir}" includes="compiler/cpp/thrift"/> | 
|  | </resourcecount> | 
|  | </not> | 
|  | </condition> | 
|  | Thrift compiler is missing ! | 
|  | </fail> | 
|  | </target> | 
|  |  | 
|  | <target name="init" depends="dependencies"> | 
|  | <tstamp /> | 
|  | <mkdir dir="${build}"/> | 
|  | <mkdir dir="${build}/lib"/> | 
|  | </target> | 
|  |  | 
|  | <target name="compile" description="compile the test suite" depends="init, generate, resolve"> | 
|  | <javac srcdir="${genjava}" destdir="${build}" classpathref="libs.classpath" /> | 
|  | <javac srcdir="${src}" destdir="${build}" classpathref="libs.classpath" /> | 
|  | </target> | 
|  |  | 
|  | <target name="jstest" description="" depends="compile, lint"> | 
|  | <jar jarfile="${jar.file}" basedir="${build}"/> | 
|  | </target> | 
|  |  | 
|  | <target name="testserver" description="run the test server" depends="jstest"> | 
|  | <java classname="test.Httpd" fork="true" | 
|  | classpathref="test.classpath" failonerror="true"> | 
|  | <arg value="../" /> | 
|  | </java> | 
|  | </target> | 
|  |  | 
|  | <target name="generate"> | 
|  | <exec executable="${thrift.compiler}" failonerror="true"> | 
|  | <arg line="--gen java ${thrift.dir}/test/ThriftTest.thrift" /> | 
|  | </exec> | 
|  | <exec executable="${thrift.compiler}" failonerror="true"> | 
|  | <arg line="--gen js:jquery ${thrift.dir}/test/ThriftTest.thrift" /> | 
|  | </exec> | 
|  | </target> | 
|  |  | 
|  | <!-- @TODO QUnit tests as part of the testsuite--> | 
|  | <target name="test" description="run test suite" depends="init, generate, resolve, lint"/> | 
|  |  | 
|  | <target name="lint" description="code quality checks" depends="generate, gjslint, jslint"/> | 
|  |  | 
|  | <target name="jslint"> | 
|  | <taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpathref="libs.classpath" /> | 
|  | <!-- | 
|  | the following options would probably make sense in the future: | 
|  | browser,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed | 
|  | --> | 
|  | <jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed"> | 
|  | <formatter type="plain" /> | 
|  | <fileset dir="${genjs}" includes="**/*.js" /> | 
|  | <fileset dir=".." includes="thrift.js" /> | 
|  | </jsl:jslint> | 
|  | </target> | 
|  |  | 
|  | <target name="check-gjslint"> | 
|  | <echo>check if gjslint is available:</echo> | 
|  | <exec executable="gjslint" failifexecutionfails="no" resultproperty="gjslint.present" failonerror="false"> | 
|  | <arg line="--helpshort"/> | 
|  | </exec> | 
|  | </target> | 
|  |  | 
|  | <target name="gjslint" depends="check-gjslint" if="gjslint.present"> | 
|  | <exec executable="gjslint" failifexecutionfails="no"> | 
|  | <arg line="--nojsdoc"/> | 
|  | <arg line="${genjs}/*.js"/> | 
|  | <arg line="../thrift.js"/> | 
|  | </exec> | 
|  | </target> | 
|  |  | 
|  | <target name="clean"> | 
|  | <delete dir="${build}" /> | 
|  | <delete dir="${genjava}" /> | 
|  | <delete dir="${genjs}" /> | 
|  | <delete file="${jar.file}" /> | 
|  | </target> | 
|  |  | 
|  | <target name="resolve" unless="mvn.finished"> | 
|  | <typedef uri="antlib:org.apache.maven.artifact.ant" classpath="${thrift.java.dir}/build/tools/${mvn.ant.task.jar}"/> | 
|  |  | 
|  | <artifact:dependencies filesetId="js.test.dependency.jars"> | 
|  | <dependency groupId="org.apache.httpcomponents" artifactId="httpclient" version="4.0.1"/> | 
|  | <dependency groupId="com.googlecode.jslint4java" artifactId="jslint4java-ant" version="1.4.6"/> | 
|  | </artifact:dependencies> | 
|  |  | 
|  | <!-- Copy the dependencies to the build/lib dir --> | 
|  | <copy todir="${build}/lib"> | 
|  | <fileset refid="js.test.dependency.jars"/> | 
|  | <mapper type="flatten"/> | 
|  | </copy> | 
|  |  | 
|  | <property name="mvn.finished" value="true"/> | 
|  | </target> | 
|  | </project> | 
|  |  |