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