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