xref: /trunk/test/build.xml (revision f5cdefa4)
1<?xml version="1.0"?>
2<!--***********************************************************
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 ***********************************************************-->
22
23
24
25<project basedir="." default="test">
26    <property environment="env" />
27	<property name="junit.home" value="${env.JUNIT_HOME}" />
28	<property name="dist.dir" value="." />
29	<property name="dist.name" value="aoo_test" />
30	<property name="junit.jar.repos" value="https://repo1.maven.org/maven2/junit/junit/4.13.2/junit-4.13.2.jar" />
31	<property name="hamcrest.jar.repos" value="https://repo1.maven.org/maven2/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar" />
32
33	<path id="uno.classpath">
34		<fileset dir="${env.OUTDIR}/bin" erroronmissingdir="false">
35			<include name="juh.jar" />
36			<include name="unoil.jar" />
37			<include name="ridl.jar" />
38			<include name="jurt.jar" />
39		</fileset>
40		<fileset dir="${openoffice.home}" erroronmissingdir="false">
41			<include name="**/juh.jar" />
42			<include name="**/unoil.jar" />
43			<include name="**/ridl.jar" />
44			<include name="**/jurt.jar" />
45		</fileset>
46	</path>
47
48	<target name="check.junit">
49	    <copy todir="lib" >
50	        <fileset dir="${junit.home}" erroronmissingdir="false">
51	            <include name="junit*.jar" />
52			</fileset>
53			<globmapper from="*" to="junit.jar" />
54        </copy>
55		<available file="lib/junit.jar" property="junit.jar.exists"/>
56	</target>
57
58	<target name="check.hamcrest">
59		<copy todir="lib" >
60			<fileset dir="${junit.home}" erroronmissingdir="false">
61				<include name="hamcrest*.jar" />
62			</fileset>
63			<globmapper from="*" to="hamcrest.jar" />
64		</copy>
65		<available file="lib/hamcrest.jar" property="hamcrest.jar.exists"/>
66	</target>
67
68	<target name="prepare.junit" depends="check.junit, prepare.hamcrest" unless="junit.jar.exists">
69		<mkdir dir="lib" />
70		<get src="${junit.jar.repos}" dest="lib/junit.jar" skipexisting="true" />
71	</target>
72
73	<target name="prepare.hamcrest" depends="check.hamcrest" unless="hamcrest.jar.exists">
74		<mkdir dir="lib" />
75		<get src="${hamcrest.jar.repos}" dest="lib/hamcrest.jar" skipexisting="true" />
76	</target>
77
78	<target name="testcommon.init">
79		<mkdir dir="testcommon/bin" />
80		<copy includeemptydirs="false" todir="testcommon/bin">
81			<fileset dir="testcommon/source">
82				<exclude name="**/*.java" />
83			</fileset>
84		</copy>
85	</target>
86
87	<target name="testcommon.compile" depends="testcommon.init, prepare.junit">
88		<javac destdir="testcommon/bin" debug="on" source="1.6" target="1.6" encoding="utf-8" includeantruntime="false">
89			<src path="testcommon/source"/>
90			<classpath>
91				<fileset dir="lib">
92					<include name="*.jar" />
93				</fileset>
94			</classpath>
95		</javac>
96	</target>
97
98	<target name="testgui.init">
99		<mkdir dir="testgui/bin" />
100		<copy includeemptydirs="false" todir="testgui/bin">
101			<fileset dir="testgui/source">
102				<exclude name="**/*.java" />
103			</fileset>
104		</copy>
105	</target>
106
107	<target name="testgui.compile" depends="testcommon.compile, testgui.init">
108		<javac destdir="testgui/bin" debug="on" source="1.6" target="1.6" encoding="utf-8" includeantruntime="false">
109			<src path="testgui/source"/>
110			<classpath>
111				<fileset dir="lib">
112				    <include name="*.jar" />
113				</fileset>
114				<pathelement location="testcommon/bin" />
115			</classpath>
116		</javac>
117	</target>
118
119	<target name="testuno.init">
120		<mkdir dir="testuno/bin" />
121		<copy includeemptydirs="false" todir="testuno/bin">
122			<fileset dir="testuno/source">
123				<exclude name="**/*.java" />
124			</fileset>
125		</copy>
126	</target>
127
128	<target name="testuno.compile" depends="testcommon.compile, testuno.init">
129		<javac destdir="testuno/bin" debug="on" source="1.6" target="1.6" encoding="utf-8" includeantruntime="false">
130			<src path="testuno/source"/>
131			<classpath>
132				<fileset dir="lib">
133					<include name="*.jar" />
134				</fileset>
135				<pathelement location="testcommon/bin" />
136				<path refid="uno.classpath"/>
137			</classpath>
138		</javac>
139	</target>
140
141	<target name="clean" description="Clean all output">
142		<delete dir="testcommon/bin" />
143		<delete dir="testgui/bin" />
144		<delete dir="testuno/bin" />
145		<ant antfile="smoketestdoc/build.xml" target="clean" inheritAll="false" useNativeBasedir="true"/>
146	</target>
147
148	<target name="compile" depends="testcommon.compile,testgui.compile,testuno.compile" description="Compile source code">
149		<ant antfile="smoketestdoc/build.xml" inheritAll="false" useNativeBasedir="true"/>
150	</target>
151
152	<target name="dist" depends="clean,compile">
153		<tstamp/>
154        	<zip destfile="${dist.dir}/${dist.name}_${DSTAMP}.zip" update="false">
155			<zipfileset dir="." includes="lib/**, testcommon/**,testgui/**,testuno/**,build.xml,run,run.bat" filemode="751" prefix="aoo_test/"/>
156		</zip>
157	</target>
158
159	<target name="test" depends="compile" description="start test">
160		<!-- Try the specified ${openoffice.home} first -->
161		<condition property="test.arg0" value="-Dopenoffice.home=${openoffice.home}">
162			<isset property="openoffice.home" />
163		</condition>
164
165		<!-- Next try the internal install path that the with-package-format=installed option to configure uses -->
166		<available type="dir" file="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/openoffice4"
167			property="internalInstalledDirNix" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/openoffice4"/>
168		<condition property="test.arg0" value="-Dopenoffice.home=${internalInstalledDirNix}">
169			<isset property="internalInstalledDirNix" />
170		</condition>
171		<available type="dir" file="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/OpenOffice 4"
172			property="internalInstalledDirWin" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/OpenOffice 4"/>
173		<condition property="test.arg0" value="-Dopenoffice.home=${internalInstalledDirWin}">
174			<isset property="internalInstalledDirWin" />
175		</condition>
176
177		<!-- Finally try the tar.gz and zip archives which build by default -->
178		<pathconvert property="openoffice.pack" setonempty="false">
179			<path>
180				<fileset dir="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/archive/install/en-US" includes="*.tar.gz,*.zip"  erroronmissingdir="false"/>
181			</path>
182		</pathconvert>
183		<condition property="test.arg0" value="-Dopenoffice.pack=${openoffice.pack}">
184			<isset property="openoffice.pack" />
185		</condition>
186
187		<fail message="No OpenOffice available!" unless="test.arg0"/>
188		<condition property="test.executable" value="./run.bat">
189			<os family="windows" />
190		</condition>
191		<property name="test.executable" value="./run"/>
192		<property name="test.args" value="-tp bvt"/>
193		<echo message="Executing: ${test.executable} ${test.arg0} ${test.args}" level="info"/>
194		<exec executable="${test.executable}">
195			<arg value="${test.arg0}"/>
196			<arg line="${test.args}"/>
197		</exec>
198	</target>
199</project>
200