xref: /aoo42x/test/build.xml (revision 2b3f926e)
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		<copy todir="lib" >
56			<fileset dir="${junit.home}" erroronmissingdir="false">
57				<include name="hamcrest*.jar" />
58			</fileset>
59			<globmapper from="*" to="hamcrest.jar" />
60		</copy>
61		<available file="lib/junit.jar" property="junit.jar.exists"/>
62		<available file="lib/hamcrest.jar" property="hamcrest.jar.exists"/>
63	</target>
64
65	<target name="prepare.junit" depends="check.junit" unless="junit.jar.exists">
66		<mkdir dir="lib" />
67		<get src="${junit.jar.repos}" dest="lib/junit.jar" skipexisting="true" />
68		<get src="${hamcrest.jar.repos}" dest="lib/hamcrest.jar" skipexisting="true" />
69	</target>
70
71	<target name="testcommon.init">
72		<mkdir dir="testcommon/bin" />
73		<copy includeemptydirs="false" todir="testcommon/bin">
74			<fileset dir="testcommon/source">
75				<exclude name="**/*.java" />
76			</fileset>
77		</copy>
78	</target>
79
80	<target name="testcommon.compile" depends="testcommon.init, prepare.junit">
81		<javac destdir="testcommon/bin" debug="on" source="1.6" target="1.6" encoding="utf-8" includeantruntime="false">
82			<src path="testcommon/source"/>
83			<classpath>
84				<fileset dir="lib">
85					<include name="*.jar" />
86				</fileset>
87			</classpath>
88		</javac>
89	</target>
90
91	<target name="testgui.init">
92		<mkdir dir="testgui/bin" />
93		<copy includeemptydirs="false" todir="testgui/bin">
94			<fileset dir="testgui/source">
95				<exclude name="**/*.java" />
96			</fileset>
97		</copy>
98	</target>
99
100	<target name="testgui.compile" depends="testcommon.compile, testgui.init">
101		<javac destdir="testgui/bin" debug="on" source="1.6" target="1.6" encoding="utf-8" includeantruntime="false">
102			<src path="testgui/source"/>
103			<classpath>
104				<fileset dir="lib">
105				    <include name="*.jar" />
106				</fileset>
107				<pathelement location="testcommon/bin" />
108			</classpath>
109		</javac>
110	</target>
111
112	<target name="testuno.init">
113		<mkdir dir="testuno/bin" />
114		<copy includeemptydirs="false" todir="testuno/bin">
115			<fileset dir="testuno/source">
116				<exclude name="**/*.java" />
117			</fileset>
118		</copy>
119	</target>
120
121	<target name="testuno.compile" depends="testcommon.compile, testuno.init">
122		<javac destdir="testuno/bin" debug="on" source="1.6" target="1.6" encoding="utf-8" includeantruntime="false">
123			<src path="testuno/source"/>
124			<classpath>
125				<fileset dir="lib">
126					<include name="*.jar" />
127				</fileset>
128				<pathelement location="testcommon/bin" />
129				<path refid="uno.classpath"/>
130			</classpath>
131		</javac>
132	</target>
133
134	<target name="clean" description="Clean all output">
135		<delete dir="testcommon/bin" />
136		<delete dir="testgui/bin" />
137		<delete dir="testuno/bin" />
138		<ant antfile="smoketestdoc/build.xml" target="clean" inheritAll="false" useNativeBasedir="true"/>
139	</target>
140
141	<target name="compile" depends="testcommon.compile,testgui.compile,testuno.compile" description="Compile source code">
142		<ant antfile="smoketestdoc/build.xml" inheritAll="false" useNativeBasedir="true"/>
143	</target>
144
145	<target name="dist" depends="clean,compile">
146		<tstamp/>
147        	<zip destfile="${dist.dir}/${dist.name}_${DSTAMP}.zip" update="false">
148			<zipfileset dir="." includes="lib/**, testcommon/**,testgui/**,testuno/**,build.xml,run,run.bat" filemode="751" prefix="aoo_test/"/>
149		</zip>
150	</target>
151
152	<target name="test" depends="compile" description="start test">
153		<!-- Try the specified ${openoffice.home} first -->
154		<condition property="test.arg0" value="-Dopenoffice.home=${openoffice.home}">
155			<isset property="openoffice.home" />
156		</condition>
157
158		<!-- Next try the internal install path that the with-package-format=installed option to configure uses -->
159		<available type="dir" file="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/openoffice4"
160			property="internalInstalledDirNix" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/openoffice4"/>
161		<condition property="test.arg0" value="-Dopenoffice.home=${internalInstalledDirNix}">
162			<isset property="internalInstalledDirNix" />
163		</condition>
164		<available type="dir" file="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/OpenOffice 4"
165			property="internalInstalledDirWin" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/OpenOffice 4"/>
166		<condition property="test.arg0" value="-Dopenoffice.home=${internalInstalledDirWin}">
167			<isset property="internalInstalledDirWin" />
168		</condition>
169
170		<!-- Finally try the tar.gz and zip archives which build by default -->
171		<pathconvert property="openoffice.pack" setonempty="false">
172			<path>
173				<fileset dir="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/archive/install/en-US" includes="*.tar.gz,*.zip"  erroronmissingdir="false"/>
174			</path>
175		</pathconvert>
176		<condition property="test.arg0" value="-Dopenoffice.pack=${openoffice.pack}">
177			<isset property="openoffice.pack" />
178		</condition>
179
180		<fail message="No OpenOffice available!" unless="test.arg0"/>
181		<condition property="test.executable" value="./run.bat">
182			<os family="windows" />
183		</condition>
184		<property name="test.executable" value="./run"/>
185		<property name="test.args" value="-tp bvt"/>
186		<exec executable="${test.executable}">
187			<arg value="${test.arg0}"/>
188			<arg line="${test.args}"/>
189		</exec>
190	</target>
191</project>
192