xref: /trunk/test/smoketestdoc/aoo-ant.xml (revision 6ad462b0)
1<?xml version="1.0" encoding="UTF-8"?>
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<!-- copied from main/solenv/ant and modified for standalone tests -->
24
25<project name="aoo-ant" default="main" xmlns:if="ant:if" xmlns:unless="ant:unless">
26
27    <!-- ================================================================= -->
28    <!-- settings                                                          -->
29    <!-- ================================================================= -->
30
31    <dirname property="aoo-ant.basedir" file="${ant.file.aoo-ant}"/>
32
33    <!-- RSCREVISION: -->
34    <property file="${aoo-ant.basedir}/../../main/solenv/inc/minor.mk"/>
35
36    <property name="main.src.dir" location="src/main/java"/>
37    <property name="res.src.dir" location="src/main/resources"/>
38    <property name="idl.src.dir" location="src/main/idl"/>
39    <property name="test.src.dir" location="src/test/java"/>
40    <property name="test-res.src.dir" location="src/test/resources"/>
41    <property name="test-idl.src.dir" location="src/test/idl"/>
42
43    <property name="main.build.dir" location="${build.base.dir}/main"/>
44    <property name="idl.build.dir" location="${build.base.dir}/idl"/>
45    <property name="idl.build.classes.dir" location="${build.base.dir}/idl/classes"/>
46    <property name="test.build.dir" location="${build.base.dir}/test"/>
47    <property name="test-idl.build.dir" location="${build.base.dir}/test-idl"/>
48    <property name="test-idl.classes.build.dir" location="${build.base.dir}/test-idl/classes"/>
49    <property name="test.reports.dir" location="${build.base.dir}/test-reports"/>
50
51    <property name="java.baseline.version" value="1.7"/>
52
53    <property name="main.debug" value="true"/>
54    <property name="main.deprecation" value="false"/>
55    <property name="test.debug" value="true"/>
56    <property name="test.deprecation" value="false"/>
57
58    <import file="${aoo-ant.basedir}/idl.xml"/>
59
60    <target name="init-project"/>
61
62    <target name="prepare" depends="init-project">
63        <property name="jar.enabled" value="true"/>
64        <property name="jar.name" value="${ant.project.name}"/>
65        <property name="jar.classpath" value=""/>
66        <property name="jar.manifest" value ="${aoo-ant.basedir}/manifest.empty"/>
67
68        <local name="has.main.classpath"/>
69        <condition property="has.main.classpath">
70            <isreference refid="main.classpath"/>
71        </condition>
72        <path id="internal.main.classpath">
73            <path refid="main.classpath" if:set="has.main.classpath"/>
74            <pathelement location="${idl.classes.build.dir}"/>
75        </path>
76
77        <local name="has.test.classpath"/>
78        <condition property="has.test.classpath">
79            <isreference refid="test.classpath"/>
80        </condition>
81        <path id="internal.test.classpath">
82            <pathelement location="${main.build.dir}"/>
83            <pathelement location="${idl.classes.build.dir}"/>
84            <pathelement location="${test.build.dir}"/>
85            <pathelement location="${test-idl.classes.build.dir}"/>
86            <path refid="main.classpath"/>
87            <path refid="test.classpath" if:set="has.test.classpath"/>
88            <pathelement location="${OOO_JUNIT_JAR}"/>
89            <pathelement location="${HAMCREST_CORE_JAR}" if:set="HAMCREST_CORE_JAR"/>
90        </path>
91    </target>
92
93    <target name="dependencies" depends="prepare">
94        <local name="has.main.classpath"/>
95        <condition property="has.main.classpath">
96            <isreference refid="main.classpath"/>
97        </condition>
98
99        <pathconvert refid="main.classpath" setonempty="true" pathsep=" " property="deps" if:set="has.main.classpath"/>
100        <property name="deps" value=""/>
101        <echo message="${deps}" file="${dependencies.outfile}"/>
102    </target>
103
104    <target name="res" depends="prepare">
105        <mkdir dir="${main.build.dir}"/>
106        <copy todir="${main.build.dir}" failonerror="false" quiet="true">
107             <fileset dir="${res.src.dir}">
108                 <include name="**/*"/>
109             </fileset>
110        </copy>
111    </target>
112
113    <extension-point name="pre-compile" depends="prepare,res"/>
114
115    <target name="idl" depends="pre-compile">
116        <fileset id="idl.files" dir="${idl.src.dir}" includes="**/*.idl" erroronmissingdir="false"/>
117        <idl-javamaker
118            idlFiles="idl.files"
119            idlBuildDir="${idl.build.dir}"/>
120    </target>
121
122    <target name="compile" depends="idl">
123        <mkdir dir="${main.build.dir}"/>
124        <javac srcdir="${main.src.dir}"
125               destdir="${main.build.dir}"
126               source="${java.baseline.version}"
127               target="${java.baseline.version}"
128               debug="${main.debug}"
129               debuglevel="lines,vars,source"
130               deprecation="${main.deprecation}"
131               classpathref="internal.main.classpath"
132               includeantruntime="false"/>
133    </target>
134
135    <macrodef name="check-test">
136        <sequential>
137            <local name="tests.present"/>
138            <available type="dir" file="${test.src.dir}" property="tests.present"/>
139            <echo message="No tests" unless:set="tests.present"/>
140
141            <local name="only.junit.absent"/>
142            <condition property="only.junit.absent">
143                <and>
144                    <isset property="tests.present"/>
145                    <not><isset property="OOO_JUNIT_JAR"/></not>
146                </and>
147            </condition>
148            <echo message="No junit, skipping tests" if:set="only.junit.absent"/>
149
150            <condition property="test.skip">
151                <or>
152                    <not><isset property="tests.present"/></not>
153                    <not><isset property="OOO_JUNIT_JAR"/></not>
154                </or>
155            </condition>
156        </sequential>
157    </macrodef>
158
159    <target name="test-res" depends="pre-compile">
160        <mkdir dir="${test.build.dir}" unless:set="test.skip"/>
161        <copy todir="${test.build.dir}" failonerror="false" quiet="true" unless:set="test.skip">
162             <fileset dir="${test-res.src.dir}">
163                 <include name="**/*"/>
164             </fileset>
165        </copy>
166    </target>
167
168    <target name="test-idl" depends="test-res">
169        <fileset id="test-idl.files" dir="${test-idl.src.dir}" includes="**/*.idl" erroronmissingdir="false"/>
170        <idl-javamaker
171            idlFiles="test-idl.files"
172            idlBuildDir="${test-idl.build.dir}"/>
173    </target>
174
175    <target name="test-compile" depends="compile,test-idl">
176        <check-test/>
177        <mkdir dir="${test.build.dir}" unless:set="test.skip"/>
178        <javac srcdir="${test.src.dir}"
179               destdir="${test.build.dir}"
180               source="${java.baseline.version}"
181               target="${java.baseline.version}"
182               debug="${test.debug}"
183               debuglevel="lines,vars,source"
184               deprecation="${test.deprecation}"
185               classpathref="internal.test.classpath"
186               includeantruntime="false"
187               unless:set="test.skip"/>
188    </target>
189
190    <!-- fork="true" is sadly necessary on Ubuntu due to multiple versions of junit confusing Ant,
191         see https://github.com/real-logic/simple-binary-encoding/issues/96 -->
192    <target name="test" depends="test-compile" unless="${test.skip}">
193        <mkdir dir="${test.reports.dir}"/>
194        <junit printsummary="yes" haltonfailure="yes" showoutput="true" filtertrace="false" fork="true">
195            <classpath refid="internal.test.classpath"/>
196            <formatter type="plain"/>
197            <batchtest todir="${test.reports.dir}">
198                <fileset dir="${test.src.dir}">
199                    <include name="**/*_Test.java"/>
200                </fileset>
201            </batchtest>
202        </junit>
203    </target>
204
205    <target name="jar" depends="compile" if="${jar.enabled}">
206        <jar destfile="${jar.dir}/${jar.name}.jar"
207             manifest="${jar.manifest}"
208             duplicate="fail">
209            <manifest>
210                <attribute name="Class-Path" value="${jar.classpath}" unless:blank="${jar.classpath}"/>
211                <attribute name="Solar-Version" value="${RSCREVISION}"/>
212            </manifest>
213            <fileset dir="${main.build.dir}"/>
214<!-- Breaks trunk/test/smoketestdoc by packaging different classes with the same name: -->
215<!--            <fileset dir="${idl.build.classes.dir}" erroronmissingdir="false"/> -->
216            <include name="**/*.class"/>
217            <include name="**/*.properties"/>
218            <include name="**/*.css"/>
219            <include name="**/*.dtd"/>
220            <include name="**/*.form"/>
221            <include name="**/*.gif "/>
222            <include name="**/*.htm"/>
223            <include name="**/*.html"/>
224            <include name="**/*.js"/>
225            <include name="**/*.mod"/>
226            <include name="**/*.sql"/>
227            <include name="**/*.xml"/>
228            <include name="**/*.xsl"/>
229            <include name="**/*.map"/>
230        </jar>
231    </target>
232
233    <extension-point name="pre-clean" depends="prepare"/>
234
235    <target name="clean" depends="pre-clean">
236        <delete dir="${build.base.dir}"/>
237        <delete file="${jar.dir}/${jar.name}.jar"/>
238    </target>
239
240    <target name="main" depends="test,jar"/>
241
242</project>
243
244