xref: /trunk/main/solenv/ant/aoo-ant.xml (revision 8cb913c4)
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    <target name="test-check">
125        <local name="tests.present"/>
126        <available type="dir" file="${test.src.dir}" property="tests.present"/>
127        <echo message="No tests" unless:set="tests.present"/>
128
129        <local name="only.junit.absent"/>
130        <condition property="only.junit.absent">
131            <and>
132                <isset property="tests.present"/>
133                <not><isset property="OOO_JUNIT_JAR"/></not>
134            </and>
135        </condition>
136        <echo message="No junit, skipping tests" if:set="only.junit.absent"/>
137
138        <condition property="test.skip">
139            <or>
140                <not><isset property="test.present"/></not>
141                <not><isset property="OOO_JUNIT_JAR"/></not>
142            </or>
143        </condition>
144    </target>
145
146    <target name="test-compile" depends="compile,idl,test-check">
147        <mkdir dir="${test.build.dir}" unless:set="test.skip"/>
148        <javac srcdir="${test.src.dir}"
149               destdir="${test.build.dir}"
150               source="${java.baseline.version}"
151               target="${java.baseline.version}"
152               debug="${test.debug}"
153               debuglevel="lines,vars,source"
154               deprecation="${test.deprecation}"
155               classpathref="internal.test.classpath"
156               includeantruntime="false"
157               unless:set="test.skip"/>
158    </target>
159
160    <!-- fork="true" is sadly necessary on Ubuntu due to multiple versions of junit confusing Ant,
161         see https://github.com/real-logic/simple-binary-encoding/issues/96 -->
162    <target name="test" depends="test-compile" unless="${test.skip}">
163        <mkdir dir="${test.reports.dir}"/>
164        <junit printsummary="yes" haltonfailure="yes" showoutput="true" filtertrace="false" fork="true">
165            <classpath refid="internal.test.classpath"/>
166            <formatter type="plain"/>
167            <batchtest todir="${test.reports.dir}">
168                <fileset dir="${test.src.dir}">
169                    <include name="**/*_Test.java"/>
170                </fileset>
171            </batchtest>
172        </junit>
173    </target>
174
175    <target name="jar" depends="compile" if="${jar.enabled}">
176        <jar destfile="${jar.dir}/${jar.name}.jar"
177             basedir="${main.build.dir}"
178             manifest="${jar.manifest}">
179            <manifest>
180                <attribute name="Class-Path" value="${jar.classpath}" unless:blank="${jar.classpath}"/>
181                <attribute name="Solar-Version" value="${RSCREVISION}"/>
182            </manifest>
183            <include name="**/*.class"/>
184            <include name="**/*.properties"/>
185            <include name="**/*.css"/>
186            <include name="**/*.dtd"/>
187            <include name="**/*.form"/>
188            <include name="**/*.gif "/>
189            <include name="**/*.htm"/>
190            <include name="**/*.html"/>
191            <include name="**/*.js"/>
192            <include name="**/*.mod"/>
193            <include name="**/*.sql"/>
194            <include name="**/*.xml"/>
195            <include name="**/*.xsl"/>
196            <include name="**/*.map"/>
197        </jar>
198    </target>
199
200    <extension-point name="pre-clean" depends="prepare"/>
201
202    <target name="clean" depends="pre-clean">
203        <delete dir="${build.base.dir}"/>
204        <delete file="${jar.dir}/${jar.name}.jar"/>
205    </target>
206
207    <target name="main" depends="test,jar"/>
208
209</project>
210
211