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