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