1<?xml version="1.0"?> 2<project name="scene-lib" default="bin"> 3 4 <property environment="env"/> 5 6 <macrodef name="echo-fileset"> 7 <attribute name="filesetref" /> 8 <sequential> 9 <pathconvert pathsep=" 10" property="@{filesetref}.echopath"> 11 <path> 12 <fileset refid="@{filesetref}" /> 13 </path> 14 </pathconvert> 15 <echo> ------- echoing fileset @{filesetref} -------</echo> 16 <echo>${@{filesetref}.echopath}</echo> 17 </sequential> 18 </macrodef> 19 20 <taskdef resource="net/sf/antcontrib/antcontrib.properties"> 21 <classpath> 22 <pathelement location="ant-contrib.jar" /> 23 </classpath> 24 </taskdef> 25 26 <target name="init-properties"> 27 <condition property="exists.build.properties"> 28 <available file="build.properties"/> 29 </condition> 30 <fail 31 unless="exists.build.properties" 32 message="Local build.properites file is missing."/> 33 34 <property file="build.properties"/> 35 36 <fail 37 unless="global.build.properties" 38 message="Local build.properties file did not define global buildfile in property global.build.properties"/> 39 <condition property="exists.global.build.properties"> 40 <available file="${global.build.properties}"/> 41 </condition> 42 <fail 43 unless="exists.global.build.properties" 44 message="File ${global.build.properties} file not found."/> 45 <property file="${global.build.properties}"/> 46 47 <fail 48 unless="user.build.properties" 49 message="Local build.properties file did not define global buildfile in property user.build.properties"/> 50 <condition property="exists.user.build.properties"> 51 <available file="${user.build.properties}"/> 52 </condition> 53 <fail 54 unless="exists.user.build.properties" 55 message="File ${user.build.properties} file not found."/> 56 <property file="${user.build.properties}"/> 57 58 </target> 59 60 <target name="init-dependencies" 61 depends="init-properties"> 62 <!-- I should reinstate this after figuring out how to make 63 it remake only when necessary, not always. (I should 64 probably do that outside ASM rather than modifying ASM itself?) 65 And, supply -Dproduct.noshrink to asmx ant command, at least when 66 testing. 67 --> 68 <!-- 69 <ant dir="${asmx}" inheritAll="false" target="bin"/> 70 --> 71 <!-- Next 2 lines only for repository version. --> 72 <!-- 73 <ant dir="${annotations-compiler}" antfile="make/build.xml" inheritAll="false" target="build"/> 74 <ant dir="${checkers}" inheritAll="false" target="build"/> 75 --> 76 </target> 77 78 <target name="init-paths"> 79 <path id="sourcepath"> 80 <pathelement location="src"/> 81 </path> 82 <path id="testpath"> 83 <pathelement location="test/annotations/tests/executable"/> 84 <pathelement location="test/annotations/tests/classfile/foo"/> 85 </path> 86 87 <fileset dir="." id="source.files.java"> 88 <include name="src/**/*.java"/> 89 <exclude name="**/.svn"/> 90 <exclude name="**/package-info.java"/> 91 </fileset> 92 93 <fileset dir="." id="source.files.java.nopackageinfo"> 94 <include name="src/**/*.java"/> 95 <exclude name="**/.svn"/> 96 <exclude name="**/package-info.java"/> 97 </fileset> 98 99 <fileset dir="." id="source.files.java.packageinfo"> 100 <include name="**/package-info.java"/> 101 </fileset> 102 103 <fileset dir="." id="source.files.non-java"> 104 <include name="src/**/*"/> 105 <exclude name="**/.svn"/> 106 <exclude name="**/*.java"/> 107 </fileset> 108 109 <path id="javadoc-sourcepath"> 110 <pathelement location="src"/> 111 </path> 112 113 <path id="libpath"> 114 <pathelement location="${asmx}/bin"/> 115 <pathelement location="${junit}"/> 116 <pathelement location="${annotation-tools}/annotation-file-utilities/lib/plume-core.jar"/> 117 <pathelement location="${annotation-tools}/annotation-file-utilities/lib/guava-20.0.jar"/> 118 <!-- remainder only for repository version --> 119 <pathelement location="${annotations-compiler}/dist/lib/javac.jar"/> 120 <pathelement location="${annotations-compiler}/dist/lib/javap.jar"/> 121 <pathelement location="bin"/> 122 </path> 123 </target> 124 125 <target name="init" depends="init-properties, init-dependencies, init-paths"/> 126 127 <target name="bin-clean"> 128 <delete dir="bin"/> 129 </target> 130 131 <target name="bin-check-uptodate" depends="init"> 132 <uptodate property="source.files.non-java.uptodate"> 133 <srcfiles refid="source.files.non-java"/> 134 <mapper type="glob" from="src/*" to="bin/*"/> 135 </uptodate> 136 137 <uptodate property="source.files.java.nopackageinfo.uptodate"> 138 <srcfiles refid="source.files.java.nopackageinfo"/> 139 <mapper type="glob" from="src/*.java" to="bin/*.class"/> 140 </uptodate> 141 142 <!-- I want to say that package-info.java does not force 143 recompilation if it is older than all source files in its own 144 package. --> 145 <uptodate property="source.files.java.packageinfo.uptodate" targetfile="bin"> 146 <srcfiles refid="source.files.java.packageinfo"/> 147 </uptodate> 148 149 <condition property="bin.uptodate"> 150 <and> 151 <isset property="source.files.non-java.uptodate"/> 152 <isset property="source.files.java.nopackageinfo.uptodate"/> 153 <isset property="source.files.java.packageinfo.uptodate"/> 154 </and> 155 </condition> 156 157 <!-- These print "true" if set and the property name in curly braces, such as "${source.files.java.nopackageinfo.uptodate}", if not set. --> 158 <echo message="source.files.non-java.uptodate: ${source.files.non-java.uptodate}"/> 159 <echo message="source.files.java.nopackageinfo.uptodate: ${source.files.java.nopackageinfo.uptodate}"/> 160 <echo message="source.files.java.packageinfo.uptodate: ${source.files.java.packageinfo.uptodate}"/> 161 <echo message="bin.uptodate: ${bin.uptodate}"/> 162 </target> 163 164 <target name="bin" depends="init, bin-check-uptodate" unless="bin.uptodate"> 165 <echo message="Running bin"/> 166 <mkdir dir="bin"/> 167 <!-- Copy non-java files to bin. These are mostly .jaif files. --> 168 <copy todir="bin"> 169 <fileset dir="src" excludes="**/*.java"/> 170 <fileset dir="test" excludes="**/*.java"/> 171 </copy> 172 <javac 173 destdir="bin" 174 debug="true" 175 classpathref="libpath" 176 classpath="${libpath}" 177 includeantruntime="false" 178 fork="true" 179 executable="${annotations-compiler}/dist/bin/javac"> 180 <src refid="sourcepath"/> 181 <src refid="testpath"/> 182 <!-- To prevent a cyclic dependency with the Checker 183 Framework, ignore type annotations in comments here. 184 A separate target could be added to check the qualifiers 185 and have them in the generated code. --> 186 <compilerarg value="-XDTA:noannotationsincomments"/> 187 <compilerarg value="-Xlint:-options"/> 188 <compilerarg value="-Werror"/> 189 <compilerarg value="-version"/> 190 <!-- Make sure we only have Java 7 source code and generate Java 7 bytecode. --> 191 <compilerarg value="-source"/> 192 <compilerarg value="7"/> 193 <compilerarg value="-target"/> 194 <compilerarg value="7"/> 195 <classpath refid="libpath"/> 196 <!-- TODO: how can we include just these two files in testpath? --> 197 <compilerarg value="test/annotations/tests/classfile/AnnotationsTest.java"/> 198 <compilerarg value="test/annotations/tests/classfile/AnnotationVerifier.java"/> 199 </javac> 200<!-- 201 <pathconvert property="libpath" refid="libpath"/> 202 <pathconvert property="source.files.java.spaceseparated" refid="source.files.java" pathsep=" "/> 203 <exec executable="javac" failonerror="true"> 204 <arg value="-version"/> 205 <arg value="-d"/> 206 <arg value="bin"/> 207 <arg value="-g"/> 208 <arg value="-cp"/> 209 <arg value="${libpath}"/> 210 <arg line="source.files.java.spaceseparated"/> 211 </exec> 212--> 213 </target> 214 215 <target name="test-scene-lib" depends="init, bin"> 216 <mkdir dir="reports"/> 217 <junit printsummary="withOutAndErr" showoutput="true" fork="yes" dir="." haltonerror="yes" haltonfailure="yes"> 218 <classpath refid="libpath"/> 219 <formatter type="plain"/> 220 <test name="annotations.tests.executable.TestSceneLib" todir="reports"/> 221 <assertions> 222 <enable/> 223 </assertions> 224 </junit> 225 </target> 226 227 <target name="test-classfile" depends="init, bin"> 228 <mkdir dir="reports"/> 229 <junit printsummary="withOutAndErr" showoutput="true" fork="yes" dir="." haltonerror="yes" haltonfailure="yes"> 230 <classpath refid="libpath"/> 231 <formatter type="plain"/> 232 <test name="annotations.tests.classfile.AnnotationsTest" todir="reports"/> 233 <assertions> 234 <enable/> 235 </assertions> 236 </junit> 237 </target> 238 239 <target name="test-example" depends="init, bin"> 240 <!-- Working directory is ignored when same JVM is used. That means 241 that the relative path for ${scene-lib} works only if this target 242 is invoked from the same directory as the build.xml file appears 243 in. We can fix the java task by adding this: 244 fork="true" 245 dir="${scene-lib}/src/annotations/tests" 246 but there are other uses of ${scene-lib} in this target. 247 --> 248 <java classname="annotations.tests.executable.Example" 249 output="${scene-lib}/test/annotations/tests/executable/example-stdout.jaif" 250 classpathref="libpath"> 251 <arg value="${scene-lib}/test/annotations/tests/executable/example-input.jaif" /> 252 <arg value="foo.Bar" /> 253 <arg value="${scene-lib}/test/annotations/tests/executable/example-output.jaif" /> 254 </java> 255 <condition property="example.output.matches"> 256 <filesmatch file1="${scene-lib}/test/annotations/tests/executable/example-output.jaif.goal" 257 file2="${scene-lib}/test/annotations/tests/executable/example-output.jaif"/> 258 </condition> 259 <!-- Debugging output in case I don't have access to the filesystem. --> 260 <if> 261 <isfalse value="${example.output.matches}"/> 262 <then> 263 <exec executable="cat"> 264 <arg value="${scene-lib}/test/annotations/tests/executable/example-output.jaif.goal"/> 265 <arg value="${scene-lib}/test/annotations/tests/executable/example-output.jaif"/> 266 </exec> 267 </then> 268 </if> 269 <fail unless="example.output.matches" 270 message="In ${scene-lib}/test/annotations/tests/executable/, file example-output.jaif does not match goal."/> 271 <condition property="example.stdout.matches"> 272 <filesmatch file1="${scene-lib}/test/annotations/tests/executable/example-stdout.jaif.goal" 273 file2="${scene-lib}/test/annotations/tests/executable/example-stdout.jaif"/> 274 </condition> 275 <fail unless="example.stdout.matches" 276 message="In ${scene-lib}/test/annotations/tests/executable/, file example-stdout.jaif does not match goal."/> 277 278 </target> 279 280 <target name="test-clean"> 281 <delete dir="reports"/> 282 </target> 283 284 <target name="test" depends="test-scene-lib, test-classfile, test-example" 285 description="Run tests"/> 286 <target name="clean" depends="bin-clean, javadoc-clean, test-clean" 287 description="Remove generated files"/> 288 289 <target name="javadoc-clean"> 290 <delete dir="javadoc"/> 291 </target> 292 293 <target name="javadoc" depends="javadoc-clean, init" 294 description="Generate Javadoc API documentation"> 295 <javadoc sourcepathref="javadoc-sourcepath" 296 classpathref="libpath" 297 packagenames="*" 298 excludepackagenames="" 299 Overview="overview.html" 300 destdir="javadoc" 301 access="public" 302 noqualifier="annotations:annotations.el:annotations.field:annotations.io:annotations.io.classfile:annotations.util:annotations.util.coll:java.lang" 303 failonerror="true" 304 /> 305 </target> 306 307 <target name="test-package" depends="bin"> 308 <property name="test-package" value="scene-lib-test"/> 309 <mkdir dir="${test-package}"/> 310 <mkdir dir="${test-package}/src"/> 311 <copy todir="${test-package}/src"> 312 <fileset dir="src" excludes="**/.svn"/> 313 </copy> 314 <jar destfile="${test-package}/deps.jar"> 315 <fileset dir="${asmx}/bin" includes="org/**"/> 316 </jar> 317 <zip destfile="${test-package}.zip"> 318 <zipfileset dir="${test-package}" prefix="${test-package}"/> 319 </zip> 320 <delete dir="${test-package}"/> 321 </target> 322 323 <!-- = = = = = = = = = = = = = = = = = 324 macrodef: echopath 325 Use as: <echopath pathid="mypath"/> 326 = = = = = = = = = = = = = = = = = --> 327 <macrodef name="echopath"> 328 <attribute name="pathid"/> 329 <sequential> 330 <property name="line.pathprefix" value="| |-- "/> 331 <!-- get given path in a printable form --> 332 <pathconvert pathsep="${line.separator}${line.pathprefix}" 333 property="echo.@{pathid}" 334 refid="@{pathid}"> 335 </pathconvert> 336 <echo>Path @{pathid}</echo> 337 <echo>${line.pathprefix}${echo.@{pathid}}</echo> 338 </sequential> 339 </macrodef> 340 341 <target name="etags" depends="tags"> 342 </target> 343 <target name="tags" description="Create Emacs TAGS table"> 344 <exec executable="/bin/sh" failonerror="true"> 345 <arg value="-c"/> 346 <arg value="etags `find -name '*.java' | sort-directory-order`"/> 347 </exec> 348 </target> 349 350</project> 351