blob: be4e7d5aebf98edceac6535ec1d8e74049c4d098 [file] [log] [blame]
Roger Meier37b5bf82010-10-24 21:41:24 +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-->
19<project name="Java Script Test" default="test" basedir="."
20 xmlns:ivy="antlib:org.apache.ivy.ant"
Roger Meierda6e6ae2011-03-15 09:55:33 +000021 xmlns:artifact="antlib:org.apache.maven.artifact.ant"
22 xmlns:jsl="antlib:com.googlecode.jslint4java">
Roger Meier37b5bf82010-10-24 21:41:24 +000023
24 <description>Java Script Test based on Thrift Java Library</description>
25
26 <property name="src" location="src" />
27 <property name="genjava" location="gen-java" />
28 <property name="genjs" location="gen-js" />
29 <property name="build" location="build" />
30 <property name="jar.file" location="${basedir}/jstest.jar" />
31
32 <!-- the root directory, where you unpack thrift distibution (e.g. thrift-0.x.x.tar.gz) -->
33 <property name="thrift.dir" location="../../../" />
34 <property name="thrift.java.dir" location="${thrift.dir}/lib/java" />
35
36 <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
37
38 <!-- take ivy from java, test depends anyway on java! -->
39 <property name="ivy.dir" location="${thrift.java.dir}/build/ivy" />
40 <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
41
42 <path id="libs.classpath">
43 <pathelement path="${thrift.java.dir}/libthrift.jar" />
44 <pathelement path="${thrift.java.dir}/libthrift-test.jar" />
45 <fileset dir="${thrift.java.dir}/build/ivy/lib">
46 <include name="*.jar" />
47 </fileset>
48 </path>
49
50 <path id="test.classpath">
51 <path refid="libs.classpath" />
52 <pathelement location="${jar.file}" />
53 </path>
54
Roger Meierda6e6ae2011-03-15 09:55:33 +000055 <taskdef uri="antlib:com.googlecode.jslint4java" resource="com/googlecode/jslint4java/antlib.xml" classpathref="libs.classpath" />
56
Roger Meier37b5bf82010-10-24 21:41:24 +000057 <target name="dependencies">
58 <fail>
59 <condition>
60 <not>
61 <resourcecount count="1">
62 <fileset id="fs" dir="${thrift.java.dir}" includes="libthrift.jar"/>
63 </resourcecount>
64 </not>
65 </condition>
66 You need libthrift.jar located at
67 ${thrift.java.dir}
68 Did you compile Thrift Java library and its test suite by "ant compile-test"?
69 </fail>
70 <fail>
71 <condition>
72 <not>
73 <resourcecount count="1">
74 <fileset id="fs" dir="${ivy.dir}" includes="ivy-2*.jar"/>
75 </resourcecount>
76 </not>
77 </condition>
78 ivy is missing at ${ivy.dir}
79 </fail>
80 <fail>
81 <condition>
82 <not>
83 <resourcecount count="1">
84 <fileset id="fs" dir="${thrift.dir}" includes="compiler/cpp/thrift"/>
85 </resourcecount>
86 </not>
87 </condition>
88 Thrift compiler is missing !
89 </fail>
90 </target>
91
92 <target name="init" depends="dependencies">
93 <tstamp />
94 <mkdir dir="${build}"/>
95 </target>
96
97 <target name="compile" description="compile the test suite" depends="init, generate, resolve">
98 <javac srcdir="${genjava}" destdir="${build}" classpathref="libs.classpath" />
99 <javac srcdir="${src}" destdir="${build}" classpathref="libs.classpath" />
100 </target>
101
102 <target name="jstest" description="" depends="compile">
103 <jar jarfile="${jar.file}" basedir="${build}"/>
104 </target>
105
106 <target name="test" description="run the test server" depends="jstest">
107 <java classname="test.Httpd" fork="true"
108 classpathref="test.classpath" failonerror="true">
109 <arg value="../" />
110 </java>
111 </target>
112
113 <target name="generate">
114 <exec executable="${thrift.compiler}" failonerror="true">
115 <arg line="--gen java ${thrift.dir}/test/ThriftTest.thrift" />
116 </exec>
117 <exec executable="${thrift.compiler}" failonerror="true">
118 <arg line="--gen js ${thrift.dir}/test/ThriftTest.thrift" />
119 </exec>
120 </target>
121
Roger Meierda6e6ae2011-03-15 09:55:33 +0000122 <target name="lint" description="code quality checks" depends="gjslint, jslint"/>
123
124 <target name="jslint">
125 <!--
126 the following options would probably make sense in the future:
127 browser,undef,eqeqeq,plusplus,bitwise,regexp,strict,newcap,immed
128 -->
129 <jsl:jslint options="evil,forin,browser,bitwise,regexp,newcap,immed">
130 <formatter type="plain" />
131 <fileset dir="${genjs}" includes="**/*.js" />
132 <fileset dir=".." includes="thrift.js" />
133 </jsl:jslint>
134 </target>
135
136 <target name="check-gjslint">
137 <echo>check if gjslint is available:</echo>
138 <exec executable="gjslint" failifexecutionfails="no" resultproperty="gjslint.present" failonerror="false">
139 <arg line="--helpshort"/>
140 </exec>
141 </target>
142
143 <target name="gjslint" depends="check-gjslint" if="gjslint.present">
144 <exec executable="gjslint" failifexecutionfails="no">
145 <arg line="--nojsdoc"/>
146 <arg line="${genjs}/*.js"/>
147 <arg line="../thrift.js"/>
148 </exec>
149 </target>
150
Roger Meier37b5bf82010-10-24 21:41:24 +0000151 <target name="clean">
152 <delete dir="${build}" />
153 <delete dir="${genjava}" />
154 <delete dir="${genjs}" />
155 <delete file="${jar.file}" />
156 </target>
157
158 <!-- ivy tasks from java build.xml ... don't know how to import them instead of copying -->
159 <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
160 <ivy:retrieve />
161 </target>
162
163 <target name="ivy-probe-antlib">
164 <condition property="ivy.found">
165 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
166 </condition>
167 </target>
168
169 <target name="ivy-init-antlib" depends="ivy-probe-antlib" unless="ivy.found">
170 <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
171 loaderRef="ivyLoader">
172 <classpath>
173 <fileset dir="${ivy.dir}">
174 <include name="ivy-2.*.jar" />
175 </fileset>
176 </classpath>
177 </typedef>
178 <fail>
179 <condition >
180 <not>
181 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
182 </not>
183 </condition>
184 You need Apache Ivy 2.0 or later from http://ant.apache.org/
185 It could not be loaded from ${ivy_repo_url}
186 </fail>
187 </target>
188
189</project>