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