blob: ee38edbe0993274557566aed6e344facca441d82 [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"
21 xmlns:artifact="antlib:org.apache.maven.artifact.ant">
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
35 <property name="thrift.compiler" location="${thrift.dir}/compiler/cpp/thrift" />
36
37 <!-- take ivy from java, test depends anyway on java! -->
38 <property name="ivy.dir" location="${thrift.java.dir}/build/ivy" />
39 <property name="ivy.lib.dir" location="${ivy.dir}/lib" />
40
41 <path id="libs.classpath">
42 <pathelement path="${thrift.java.dir}/libthrift.jar" />
43 <pathelement path="${thrift.java.dir}/libthrift-test.jar" />
44 <fileset dir="${thrift.java.dir}/build/ivy/lib">
45 <include name="*.jar" />
46 </fileset>
47 </path>
48
49 <path id="test.classpath">
50 <path refid="libs.classpath" />
51 <pathelement location="${jar.file}" />
52 </path>
53
54 <target name="dependencies">
55 <fail>
56 <condition>
57 <not>
58 <resourcecount count="1">
59 <fileset id="fs" dir="${thrift.java.dir}" includes="libthrift.jar"/>
60 </resourcecount>
61 </not>
62 </condition>
63 You need libthrift.jar located at
64 ${thrift.java.dir}
65 Did you compile Thrift Java library and its test suite by "ant compile-test"?
66 </fail>
67 <fail>
68 <condition>
69 <not>
70 <resourcecount count="1">
71 <fileset id="fs" dir="${ivy.dir}" includes="ivy-2*.jar"/>
72 </resourcecount>
73 </not>
74 </condition>
75 ivy is missing at ${ivy.dir}
76 </fail>
77 <fail>
78 <condition>
79 <not>
80 <resourcecount count="1">
81 <fileset id="fs" dir="${thrift.dir}" includes="compiler/cpp/thrift"/>
82 </resourcecount>
83 </not>
84 </condition>
85 Thrift compiler is missing !
86 </fail>
87 </target>
88
89 <target name="init" depends="dependencies">
90 <tstamp />
91 <mkdir dir="${build}"/>
92 </target>
93
94 <target name="compile" description="compile the test suite" depends="init, generate, resolve">
95 <javac srcdir="${genjava}" destdir="${build}" classpathref="libs.classpath" />
96 <javac srcdir="${src}" destdir="${build}" classpathref="libs.classpath" />
97 </target>
98
99 <target name="jstest" description="" depends="compile">
100 <jar jarfile="${jar.file}" basedir="${build}"/>
101 </target>
102
103 <target name="test" description="run the test server" depends="jstest">
104 <java classname="test.Httpd" fork="true"
105 classpathref="test.classpath" failonerror="true">
106 <arg value="../" />
107 </java>
108 </target>
109
110 <target name="generate">
111 <exec executable="${thrift.compiler}" failonerror="true">
112 <arg line="--gen java ${thrift.dir}/test/ThriftTest.thrift" />
113 </exec>
114 <exec executable="${thrift.compiler}" failonerror="true">
115 <arg line="--gen js ${thrift.dir}/test/ThriftTest.thrift" />
116 </exec>
117 </target>
118
119 <target name="clean">
120 <delete dir="${build}" />
121 <delete dir="${genjava}" />
122 <delete dir="${genjs}" />
123 <delete file="${jar.file}" />
124 </target>
125
126 <!-- ivy tasks from java build.xml ... don't know how to import them instead of copying -->
127 <target name="resolve" depends="ivy-init-antlib" description="retrieve dependencies with ivy" unless="noivy">
128 <ivy:retrieve />
129 </target>
130
131 <target name="ivy-probe-antlib">
132 <condition property="ivy.found">
133 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
134 </condition>
135 </target>
136
137 <target name="ivy-init-antlib" depends="ivy-probe-antlib" unless="ivy.found">
138 <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
139 loaderRef="ivyLoader">
140 <classpath>
141 <fileset dir="${ivy.dir}">
142 <include name="ivy-2.*.jar" />
143 </fileset>
144 </classpath>
145 </typedef>
146 <fail>
147 <condition >
148 <not>
149 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
150 </not>
151 </condition>
152 You need Apache Ivy 2.0 or later from http://ant.apache.org/
153 It could not be loaded from ${ivy_repo_url}
154 </fail>
155 </target>
156
157</project>