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