xref: /trunk/test/build.xml (revision dfec5905470e2d65ae4b42a6e44455bb534cb66d)
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        <ant antfile="smoketestdoc/build.xml" target="clean" inheritAll="false" useNativeBasedir="true"/>
130    </target>
131
132    <target name="compile" depends="testcommon.compile,testgui.compile,testuno.compile" description="Compile source code">
133        <ant antfile="smoketestdoc/build.xml" inheritAll="false" useNativeBasedir="true"/>
134    </target>
135
136    <target name="dist" depends="clean,compile">
137        <tstamp/>
138            <zip destfile="${dist.dir}/${dist.name}_${DSTAMP}.zip" update="false">
139            <zipfileset dir="." includes="lib/**, testcommon/**,testgui/**,testuno/**,build.xml,run,run.bat" filemode="751" prefix="aoo_test/"/>
140        </zip>
141    </target>
142
143    <target name="test" depends="compile" description="start test">
144        <!-- Try the specified ${openoffice.home} first -->
145        <condition property="test.arg0" value="-Dopenoffice.home=${openoffice.home}">
146            <isset property="openoffice.home" />
147        </condition>
148
149        <!-- Next try the internal install path that the with-package-format=installed option to configure uses -->
150        <available type="dir" file="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/openoffice4"
151            property="internalInstalledDirNix" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/openoffice4"/>
152        <condition property="test.arg0" value="-Dopenoffice.home=${internalInstalledDirNix}">
153            <isset property="internalInstalledDirNix" />
154        </condition>
155        <available type="dir" file="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/OpenOffice 4"
156            property="internalInstalledDirWin" value="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/installed/install/en-US/OpenOffice 4"/>
157        <condition property="test.arg0" value="-Dopenoffice.home=${internalInstalledDirWin}">
158            <isset property="internalInstalledDirWin" />
159        </condition>
160
161        <!-- Finally try the tar.gz and zip archives which build by default -->
162        <pathconvert property="openoffice.pack" setonempty="false">
163            <path>
164                <fileset dir="${env.SRC_ROOT}/instsetoo_native/${env.INPATH}/Apache_OpenOffice/archive/install/en-US" includes="*.tar.gz,*.zip"  erroronmissingdir="false"/>
165            </path>
166        </pathconvert>
167        <condition property="test.arg0" value="-Dopenoffice.pack=${openoffice.pack}">
168            <isset property="openoffice.pack" />
169        </condition>
170
171        <fail message="No OpenOffice available!" unless="test.arg0"/>
172        <condition property="test.executable" value="./run.bat">
173            <os family="windows" />
174        </condition>
175        <property name="test.executable" value="./run"/>
176        <property name="test.args" value="-tp bvt"/>
177        <exec executable="${test.executable}">
178            <arg value="${test.arg0}"/>
179            <arg line="${test.args}"/>
180        </exec>
181    </target>
182</project>
183