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