xref: /aoo42x/main/solenv/ant/aoo-ant.xml (revision cede1e5b)
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    <property name="main.src.dir" location="src/main/java"/>
39    <property name="main.build.dir" location="${build.base.dir}/main"/>
40    <property name="test.src.dir" location="src/test/java"/>
41    <property name="test.build.dir" location="${build.base.dir}/test"/>
42    <property name="test.reports.dir" location="${build.base.dir}/test-reports"/>
43    <property name="jar.dir" location="${WORKDIR}/Ant"/>
44
45    <property name="main.debug" value="true"/>
46    <property name="main.deprecation" value="false"/>
47    <property name="test.debug" value="true"/>
48    <property name="test.deprecation" value="false"/>
49
50    <import file="${aoo-ant.basedir}/externals.xml"/>
51    <import file="${aoo-ant.basedir}/idl.xml"/>
52
53    <target name="init-project"/>
54
55    <target name="prepare" depends="init-project">
56        <property name="jar.enabled" value="true"/>
57        <property name="jar.name" value="${ant.project.name}"/>
58        <property name="jar.classpath" value=""/>
59        <property name="jar.manifest" value ="${aoo-ant.basedir}/manifest.empty"/>
60
61        <local name="has.main.classpath"/>
62        <condition property="has.main.classpath">
63            <isreference refid="main.classpath"/>
64        </condition>
65        <path id="main.classpath" unless:set="has.main.classpath"/>
66
67        <local name="has.test.classpath"/>
68        <condition property="has.test.classpath">
69            <isreference refid="test.classpath"/>
70        </condition>
71        <path id="internal.test.classpath">
72            <pathelement location="${main.build.dir}"/>
73            <pathelement location="${test.build.dir}"/>
74            <path refid="main.classpath"/>
75            <path refid="test.classpath" if:set="has.test.classpath"/>
76            <pathelement location="${idl.classes.build.dir}"/>
77            <pathelement location="${OOO_JUNIT_JAR}"/>
78        </path>
79
80        <local name="has.idl.files"/>
81        <condition property="has.idl.files">
82            <isreference refid="idl.files"/>
83        </condition>
84        <filelist id="idl.files" unless:set="has.idl.files"/>
85    </target>
86
87    <target name="res" depends="prepare">
88        <mkdir dir="${main.build.dir}"/>
89        <copy todir="${main.build.dir}">
90             <fileset dir="${main.src.dir}">
91                 <include name="**/*.properties"/>
92                 <include name="**/*.css"/>
93                 <include name="**/*.dtd"/>
94                 <include name="**/*.form"/>
95                 <include name="**/*.gif "/>
96                 <include name="**/*.htm"/>
97                 <include name="**/*.html"/>
98                 <include name="**/*.js"/>
99                 <include name="**/*.mod"/>
100                 <include name="**/*.sql"/>
101                 <include name="**/*.xml"/>
102                 <include name="**/*.xsl"/>
103                 <include name="**/*.map"/>
104             </fileset>
105        </copy>
106    </target>
107
108    <extension-point name="pre-compile" depends="prepare,res"/>
109
110    <target name="compile" depends="pre-compile">
111        <mkdir dir="${main.build.dir}"/>
112        <javac srcdir="${main.src.dir}"
113               destdir="${main.build.dir}"
114               debug="${main.debug}"
115               debuglevel="lines,vars,source"
116               deprecation="${main.deprecation}"
117               classpathref="main.classpath"
118               includeantruntime="false"/>
119    </target>
120
121    <target name="test-check">
122        <local name="tests.present"/>
123        <available type="dir" file="${test.src.dir}" property="tests.present"/>
124        <echo message="No tests" unless:set="tests.present"/>
125
126        <local name="only.junit.absent"/>
127        <condition property="only.junit.absent">
128            <and>
129                <isset property="tests.present"/>
130                <not><isset property="OOO_JUNIT_JAR"/></not>
131            </and>
132        </condition>
133        <echo message="No junit, skipping tests" if:set="only.junit.absent"/>
134
135        <condition property="test.skip">
136            <or>
137                <not><isset property="test.present"/></not>
138                <not><isset property="OOO_JUNIT_JAR"/></not>
139            </or>
140        </condition>
141    </target>
142
143    <target name="test-compile" depends="compile,idl,test-check">
144        <mkdir dir="${test.build.dir}" unless:set="test.skip"/>
145        <javac srcdir="${test.src.dir}"
146               destdir="${test.build.dir}"
147               debug="${test.debug}"
148               debuglevel="lines,vars,source"
149               deprecation="${test.deprecation}"
150               classpathref="internal.test.classpath"
151               includeantruntime="false"
152               unless:set="test.skip"/>
153    </target>
154
155    <!-- fork="true" is sadly necessary on Ubuntu due to multiple versions of junit confusing Ant,
156         see https://github.com/real-logic/simple-binary-encoding/issues/96 -->
157    <target name="test" depends="test-compile" unless="${test.skip}">
158        <mkdir dir="${test.reports.dir}"/>
159        <junit printsummary="yes" haltonfailure="yes" showoutput="true" filtertrace="false" fork="true">
160            <classpath refid="internal.test.classpath"/>
161            <formatter type="plain"/>
162            <batchtest todir="${test.reports.dir}">
163                <fileset dir="${test.src.dir}">
164                    <include name="**/*_Test.java"/>
165                </fileset>
166            </batchtest>
167        </junit>
168    </target>
169
170    <target name="jar" depends="compile" if="${jar.enabled}">
171        <jar destfile="${jar.dir}/${jar.name}.jar"
172             basedir="${main.build.dir}"
173             manifest="${jar.manifest}">
174            <manifest>
175                <attribute name="Class-Path" value="${jar.classpath}" unless:blank="${jar.classpath}"/>
176                <attribute name="Solar-Version" value="${RSCREVISION}"/>
177            </manifest>
178            <include name="**/*.class"/>
179            <include name="**/*.properties"/>
180            <include name="**/*.css"/>
181            <include name="**/*.dtd"/>
182            <include name="**/*.form"/>
183            <include name="**/*.gif "/>
184            <include name="**/*.htm"/>
185            <include name="**/*.html"/>
186            <include name="**/*.js"/>
187            <include name="**/*.mod"/>
188            <include name="**/*.sql"/>
189            <include name="**/*.xml"/>
190            <include name="**/*.xsl"/>
191            <include name="**/*.map"/>
192        </jar>
193    </target>
194
195    <target name="clean" depends="prepare">
196        <delete dir="${build.base.dir}"/>
197        <delete file="${jar.dir}/${jar.name}.jar"/>
198    </target>
199
200    <target name="main" depends="test,jar"/>
201
202</project>
203
204