1 <?xml version="1.0"?> 2 3 <project name="annotation-file-utilities" default="zipfile"> 4 <description> 5 Ant build file for the annotation file utilities. 6 Run "ant -projecthelp" for a full list of options. 7 </description> 8 9 <property environment="env"/> 10 11 <property name="java-version" value="8"/> 12 13 <tstamp> 14 <format property="TIME" pattern="yy-MM-dd-HH-mm-ss-SS" /> 15 </tstamp> 16 <!-- Avoid conflicts between multiple users on the same computer. --> 17 <property name="tmpdir" location="${java.io.tmpdir}/${user.name}/${TIME}" /> 18 <!-- The distribution is the result of zipping this directory. --> 19 <property name="temp-annotation-tools" location="${tmpdir}/annotation-tools" /> 20 21 <!-- Can't I just reuse temp-annotation-file-utilities, rather than 22 having this separate directory? --> 23 <property name="temp-jarfile" location="${tmpdir}/annotation-file-utilities-jarfile" /> 24 25 <target name="init-properties"> 26 <condition property="exists.build.properties"> 27 <available file="build.properties"/> 28 </condition> 29 <fail 30 unless="exists.build.properties" 31 message="Local build.properites file is missing."/> 32 33 <property file="build.properties"/> 34 35 <fail 36 unless="global.build.properties" 37 message="Local build.properties file did not define global buildfile in property global.build.properties"/> 38 <condition property="exists.global.build.properties"> 39 <available file="${global.build.properties}"/> 40 </condition> 41 <fail 42 unless="exists.global.build.properties" 43 message="File ${global.build.properties} file not found."/> 44 <property file="${global.build.properties}"/> 45 46 <fail 47 unless="user.build.properties" 48 message="Local build.properties file did not define global buildfile in property user.build.properties"/> 49 <condition property="exists.user.build.properties"> 50 <available file="${user.build.properties}"/> 51 </condition> 52 <fail 53 unless="exists.user.build.properties" 54 message="File ${user.build.properties} file not found."/> 55 <property file="${user.build.properties}"/> 56 57 <echo message="annotations-compiler: ${annotations-compiler}"/> 58 59 <!-- convert relative to absolute pathname --> 60 <property name="annotations-compiler-absolute" location="${annotations-compiler}" /> 61 62 </target> 63 64 <!-- Compiles all the subparts of the Annotation File Utilities. --> 65 <target name="init-dependencies" 66 depends="init-properties"> 67 <ant dir="${asmx}" target="bin"> 68 <property name="product.noshrink" value="true"/> 69 </ant> 70 <ant dir="${scene-lib}" target="bin"/> 71 <!-- repository version only: --> 72 <!-- I don't see the need for this. --> 73 <!-- <ant dir="${annotations-compiler}" antfile="make/build.xml" target="build"/> --> 74 </target> 75 76 <target name="init" 77 depends="init-properties, init-dependencies"> 78 <fileset dir="src" id="src-files"> 79 <include name="**/*.java"/> 80 </fileset> 81 82 <path id="libpath"> 83 <!-- alternate for distribution: 84 <pathelement location="${annotations-compiler}/bin"/> 85 --> 86 <pathelement location="${annotations-compiler}/dist/lib/javac.jar"/> 87 <pathelement location="${annotation-tools}/annotation-file-utilities/lib/plume-core.jar"/> 88 <pathelement location="${annotation-tools}/annotation-file-utilities/lib/guava-20.0.jar"/> 89 <pathelement location="${scene-lib}/bin"/> 90 <pathelement location="${asmx}/bin"/> 91 <!-- needed for optionsdoc target --> 92 <pathelement location="bin"/> 93 <!-- additional for distribution: 94 <pathelement location="${jre1.6.0}"/> 95 --> 96 </path> 97 </target> 98 99 <path id="javadoc-sourcepath"> 100 <pathelement location="src"/> 101 </path> 102 103 <target name="javadoc-clean"> 104 <delete dir="javadoc"/> 105 </target> 106 107 <target name="javadoc" depends="javadoc-clean, init"> 108 <javadoc sourcepathref="javadoc-sourcepath" 109 classpathref="libpath" 110 failonerror="true" 111 packagenames="*" 112 destdir="javadoc" 113 access="public" 114 /> 115 <!-- 116 noqualifier="annotations:annotations.el:annotations.field:annotations.io:annotations.io.classfile:annotations.util:annotations.util.coll:java.lang" 117 --> 118 </target> 119 120 <target name="optionsdoc" depends="javadoc, init"> 121 <javadoc sourcepathref="javadoc-sourcepath" 122 sourcefiles="src/annotator/Main.java" 123 classpathref="libpath" 124 docletpathref="libpath" 125 failonerror="true" 126 > 127 <doclet name="plume.OptionsDoclet"> 128 <param name="-format" value="javadoc"/> 129 <param name="-i"/> 130 <param name="-docfile" value="src/annotator/Main.java"/> 131 </doclet> 132 </javadoc> 133 134 <javadoc sourcepathref="javadoc-sourcepath" 135 sourcefiles="src/annotator/Main.java" 136 classpathref="libpath" 137 docletpathref="libpath" 138 failonerror="true" 139 > 140 <doclet name="plume.OptionsDoclet"> 141 <param name="-format" value="html"/> 142 <param name="-i"/> 143 <param name="-docfile" value="annotation-file-utilities.html"/> 144 </doclet> 145 </javadoc> 146 147 </target> 148 149 <target name="jarfile.check.uptodate"> 150 <uptodate property="bin.uptodate" targetfile="annotation-file-utilities.jar"> 151 <srcfiles dir="bin" /> 152 </uptodate> 153 <uptodate property="asmx.bin.uptodate" targetfile="annotation-file-utilities.jar"> 154 <srcfiles dir="${asmx}/bin" excludes="tmp/**"/> 155 </uptodate> 156 <uptodate property="scene-lib.bin.uptodate" targetfile="annotation-file-utilities.jar"> 157 <srcfiles dir="${scene-lib}/bin" excludes="annotations-expected/**,annotations/tests/**"/> 158 </uptodate> 159 <uptodate property="annotations-compiler.uptodate" targetfile="annotation-file-utilities.jar" srcfile="${annotations-compiler}/dist/lib/javac.jar"/> 160 <uptodate property="plume.uptodate" targetfile="annotation-file-utilities.jar" srcfile="lib/plume-core.jar"/> 161 <uptodate property="google-collect.uptodate" targetfile="annotation-file-utilities.jar" srcfile="lib/guava-20.0.jar"/> 162 163 <condition property="jarfile.uptodate"> 164 <and> 165 <isset property="bin.uptodate"/> 166 <isset property="asmx.bin.uptodate"/> 167 <isset property="scene-lib.bin.uptodate"/> 168 <isset property="annotations-compiler.uptodate"/> 169 <isset property="plume.uptodate"/> 170 <isset property="google-collect.uptodate"/> 171 </and> 172 </condition> 173 174 <echo message="bin.uptodate: ${bin.uptodate}"/> 175 <echo message="asmx.bin.uptodate: ${asmx.bin.uptodate}"/> 176 <echo message="scene-lib.bin.uptodate: ${scene-lib.bin.uptodate}"/> 177 <echo message="annotations-compiler.uptodate: ${annotations-compiler.uptodate}"/> 178 <echo message="plume.uptodate: ${plume.uptodate}"/> 179 <echo message="google-collect.uptodate: ${google-collect.uptodate}"/> 180 <echo message="jarfile.uptodate: ${jarfile.uptodate}"/> 181 182 </target> 183 184 <target name="jarfile" 185 depends="init,build,jarfile.check.uptodate" 186 unless="jarfile.uptodate" 187 description="create the class library annotation-file-utilities.jar"> 188 189 <echo message="Using temporary directory: ${temp-jarfile}"/> 190 <delete dir="${temp-jarfile}"/> 191 <mkdir dir="${temp-jarfile}"/> 192 193 <echo message="Copying .class files to ${temp-jarfile}"/> 194 <copy todir="${temp-jarfile}"> 195 <fileset dir="bin" /> 196 <fileset dir="${asmx}/bin" excludes="tmp/**"/> 197 <fileset dir="${scene-lib}/bin" excludes="annotations-expected/**,annotations/tests/**"/> 198 </copy> 199 <!-- Also need to get class files in libraries --> 200 <unjar src="lib/plume-core.jar" dest="${temp-jarfile}"> 201 <patternset> 202 <include name="**/*.class"/> 203 <exclude name="META-INF/" /> 204 </patternset> 205 </unjar> 206 <unjar src="lib/guava-20.0.jar" dest="${temp-jarfile}"> 207 <patternset> 208 <include name="com/google/common/base/**/*.class"/> 209 <include name="com/google/common/collect/**/*.class"/> 210 <include name="com/google/common/escape/**/*.class"/> 211 <exclude name="META-INF/" /> 212 </patternset> 213 </unjar> 214 <unjar src="${annotations-compiler}/dist/lib/javac.jar" dest="${temp-jarfile}"> 215 <patternset> 216 <include name="**/*.class"/> 217 <exclude name="META-INF/" /> 218 </patternset> 219 </unjar> 220 221 <!-- Actually create a single .jar file of all the class files, 222 scripts and documentation --> 223 <echo message="Creating jarfile annotation-file-utilities.jar"/> 224 <jar destfile="annotation-file-utilities.jar"> 225 <fileset dir="${temp-jarfile}"/> 226 </jar> 227 228 <!-- Delete class files copied over --> 229 <echo message="Deleting temporary directory: ${temp-jarfile}"/> 230 <delete dir="${temp-jarfile}"/> 231 </target> 232 233 <target name="check-git-status" depends="init-properties"> 234 <exec executable="git" failonerror="true" 235 outputproperty="status.output"> 236 <arg value="status" /> 237 </exec> 238 239 <condition property="status.output.empty"> 240 <equals 241 arg1="${status.output}" 242 arg2=""/> 243 </condition> 244 245 <fail unless="status.output.empty" 246 message="`git status' did not return empty output. 247 Commit/add/remove files as appropriate, then re-try."/> 248 </target> 249 250 <!-- Copy files from repository to temporary directory from which they 251 will be packaged up. --> 252 <target name="update-workspace" depends="init-properties"> 253 <delete dir="${temp-annotation-tools}" /> 254 255 <exec executable="git" failonerror="true"> 256 <arg value="clone" /> 257 <arg value="${annotation-tools}" /> 258 <arg value="${temp-annotation-tools}" /> 259 </exec> 260 <delete dir="${temp-annotation-tools}/scene-lib.orig-hand-annos" /> 261 <delete dir="${temp-annotation-tools}/.git" /> 262 <delete file="${temp-annotation-tools}/.gitignore" /> 263 <delete file="${temp-annotation-tools}/.hg_archival.txt" /> 264 <delete file="${temp-annotation-tools}/.hgignore" /> 265 266 <copy todir="${temp-annotation-tools}/annotation-file-utilities"> 267 <fileset dir="${afu}"> 268 <include name="annotation-file-format.dvi"/> 269 <include name="annotation-file-format.html"/> 270 <include name="annotation-file-format.pdf"/> 271 <include name="annotation-file-utilities.jar"/> 272 <include name="bin/**"/> 273 </fileset> 274 </copy> 275 276 <copy todir="${temp-annotation-tools}/asmx"> 277 <fileset dir="${asmx}"> 278 <include name="bin/**"/> 279 </fileset> 280 </copy> 281 282 <copy todir="${temp-annotation-tools}/scene-lib"> 283 <fileset dir="${scene-lib}"> 284 <include name="bin/**"/> 285 </fileset> 286 </copy> 287 288 </target> 289 290 <target name="zipfile" 291 depends="jarfile,annotation-file-format,run-tests,update-workspace" 292 description="create the distribution: annotation-tools.zip"> 293 <!-- Create a new directory containing all the files and then zip that 294 directory, so that when the user unzips they extract exactly one 295 directory. --> 296 297 <!-- In order for the shell scripts to have the proper execution bit set, 298 include them specifically with the right permissions. Ant presently 299 does not use the file's permissions themselves to do this. --> 300 <zip destfile="annotation-tools.zip" compress="true"> 301 <fileset dir="${tmpdir}"> 302 <include name="annotation-tools/"/> 303 <exclude name="annotation-tools/annotation-file-utilities/scripts/extract-annotations"/> 304 <exclude name="annotation-tools/annotation-file-utilities/scripts/insert-annotations"/> 305 <exclude name="annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source"/> 306 </fileset> 307 <zipfileset dir="${tmpdir}" filemode="755"> 308 <include name="annotation-tools/annotation-file-utilities/scripts/extract-annotations"/> 309 <include name="annotation-tools/annotation-file-utilities/scripts/insert-annotations"/> 310 <include name="annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source"/> 311 </zipfileset> 312 </zip> 313 314 <!-- Delete temporary files once they have been zipped. --> 315 <!-- 316 <delete dir="${temp-annotation-file-utilities}"/> 317 --> 318 </target> 319 320 <macrodef name="update"> 321 <attribute name="file"/> 322 <attribute name="start"/> 323 <attribute name="end" default=""/> 324 <attribute name="with"/> 325 <sequential> 326 <echo level="info" message="updating @{file}"/> 327 <replaceregexp file="@{file}" byline="true" 328 match="@{start}.*@{end}" replace="@{start}@{with}@{end}"/> 329 </sequential> 330 </macrodef> 331 332 <target name="update-versions" depends="init-properties"> 333 <fail unless="release.ver" message="You must specify a release version to update to"/> 334 <fail unless="release.date" message="You must specify a release date to update to"/> 335 336 <property name="release.version.regexp" value="\d\.\d\.\d+(?:\.\d)"/> 337 <property name="afuWebPage" value="${annotation-tools}/annotation-file-utilities/annotation-file-utilities.html"/> 338 339 <replaceregexp file="${afuWebPage}" byline="true" 340 match="annotation-tools-${release.version.regexp}{0,1}.zip" replace="annotation-tools-${release.ver}.zip"/> 341 342 <update file="${afuWebPage}" 343 start="${afu.zip.ver.0}" end="${afu.zip.ver.1}" 344 with="annotation-tools-${release.ver}.zip"/> 345 346 <update file="${afuWebPage}" 347 start="${afu.ver.0}" end="${afu.ver.1}" 348 with="${release.ver}, ${release.date}"/> 349 350 <update file="${afuWebPage}" 351 start="${afu.date.0}" end="${afu.date.1}" 352 with="${release.date}"/> 353 354 <property name="newCfrValue" value="Annotation File Utilities v${release.ver}"/> 355 356 <property name="ClassFileReaderPath" value="${annotation-tools}/scene-lib/src/annotations/io/classfile/ClassFileReader.java"/> 357 <echo level="info" message="updating ${ClassFileReaderPath}"/> 358 <replaceregexp file="${ClassFileReaderPath}" byline="true" 359 match="${afu.cfr.pattern}" replace="${newCfrValue}"/> 360 </target> 361 362 <!-- TODO: I am not sure this target works as the original author intended 363 TODO: (i.e. I don't think check-git-status gets executed twice) 364 TODO: but I am maintaining the previous behavior. 365 --> 366 <target name="web" depends="check-git-status,web-no-checks,check-git-status"/> 367 368 <!-- New release process runs checks prior to running the web-no-checks target--> 369 <target name="web-no-checks" depends="clean,zipfile" 370 description="export the zipfile, etc. to its website"> 371 372 <fail unless="deploy-dir" message="You must specify a deploy-dir, the live site deploy-dir=/cse/www2/types/annotation-file-utilities/releases/_version num_"/> 373 374 <fail unless="afu.version" message="You must specify an afu.version, such as 3.6.22"/> 375 376 <echo message="Export location: ${deploy-dir}"/> 377 <echo message="Copying annotation-tools.zip"/> 378 <copy file="annotation-tools.zip" 379 tofile="${deploy-dir}/annotation-tools-${afu.version}.zip"/> 380 381 <echo message="Copying annotation-file-utilities.html"/> 382 <copy file="annotation-file-utilities.html" 383 todir="${deploy-dir}"/> 384 <copy file="changelog.html" 385 todir="${deploy-dir}"/> 386 387 <echo message="Copying annotation-file-format.{html,pdf}"/> 388 <copy file="annotation-file-format.html" 389 todir="${deploy-dir}"/> 390 <copy file="annotation-file-format.pdf" 391 todir="${deploy-dir}"/> 392 393 <copy todir="${deploy-dir}/figures" flatten="true"> 394 <fileset dir="figures"> 395 <include name="*.svg"/> 396 <include name="*.png"/> 397 <include name="*.gif"/> 398 </fileset> 399 </copy> 400 401 <symlink overwrite="true" 402 link="${deploy-dir}/index.html" 403 resource="annotation-file-utilities.html"/> 404 </target> 405 406 <target name="annotation-file-format-clean" 407 description="removes generated documentation files"> 408 <delete file="annotation-file-format.aux"/> 409 <delete file="annotation-file-format.dvi"/> 410 <delete file="annotation-file-format.haux"/> 411 <delete file="annotation-file-format.html"/> 412 <delete file="annotation-file-format.htoc"/> 413 <delete file="annotation-file-format.log"/> 414 <delete file="annotation-file-format.pdf"/> 415 <delete file="annotation-file-format.toc"/> 416 <exec executable="make" failonerror="true"> 417 <arg value="-C"/> 418 <arg value="figures"/> 419 <arg value="clean"/> 420 </exec> 421 <delete file="scene-lib-type-hierarchy.png"/> 422 </target> 423 424 <!-- 425 A problem is that the document date is the date that LaTeX was run 426 rather than the date of last modification; that should be fixed in 427 the document, perhaps. --> 428 <target name="annotation-file-format" 429 description="Make documentation: annotation-file-format.{html,pdf}"> 430 <exec executable="make" failonerror="true"> 431 <arg value="-C"/> 432 <arg value="figures"/> 433 </exec> 434 <exec executable="latex" failonerror="true"> 435 <arg value="annotation-file-format.tex"/> 436 </exec> 437 <exec executable="bibtex" failonerror="true"> 438 <arg value="annotation-file-format"/> 439 </exec> 440 <exec executable="latex" failonerror="true"> 441 <arg value="annotation-file-format.tex"/> 442 </exec> 443 <exec executable="latex" failonerror="true"> 444 <arg value="annotation-file-format.tex"/> 445 </exec> 446 <exec executable="pdflatex" failonerror="true"> 447 <arg value="annotation-file-format.tex"/> 448 </exec> 449 <exec executable="hevea" failonerror="true"> 450 <arg value="-fix"/> 451 <arg value="-exec"/> 452 <arg value="xxdate.exe"/> 453 <arg value="urlhref.hva"/> 454 <arg value="annotation-file-format.tex"/> 455 </exec> 456 </target> 457 458 <target name="clean" depends="annotation-file-format-clean,clean-tests" 459 description="removes generated files (e.g., .jar, .zip)"> 460 <delete dir="bin"/> 461 462 <!-- <echo message="Deleting temporary directory: ${temp-jarfile}"/> --> 463 <delete dir="${temp-jarfile}"/> 464 <delete dir="${temp-annotation-file-utilities}"/> 465 466 <!-- <echo message="Deleting previous distribution: annotation-file-utilities.{jar,zip}"/> --> 467 <delete file="annotation-file-utilities.jar"/> 468 <delete file="annotation-tools.zip"/> 469 </target> 470 471 <target name="run-tests" depends="init-properties" 472 description="run tests for the annotator"> 473 <exec dir="tests/" executable="make" failonerror="true"> 474 <env key="XJAVAC" value="${annotations-compiler-absolute}/dist/bin/javac -g ${xjavac.args}"/> 475 <env key="JAVAC_JAR" value="${annotations-compiler-absolute}/dist/lib/javac.jar"/> 476 </exec> 477 </target> 478 479 <target name="clean-tests" description="removes generated test files"> 480 <exec dir="tests/" executable="make" failonerror="true"> 481 <arg value="clean"/> 482 </exec> 483 <exec dir="tests/source-extension/" executable="make" failonerror="true"> 484 <arg value="clean"/> 485 </exec> 486 <exec dir="tests/system-test/" executable="make" failonerror="true"> 487 <arg value="clean"/> 488 </exec> 489 </target> 490 491 <target name="bin" 492 depends="build"/> 493 494 <target name="build" 495 depends="init" 496 description="compile all source files"> 497 498 <mkdir dir="bin"/> 499 500 <fileset dir="src" id="javacSrc"> 501 <include name="**/*.java" /> 502 </fileset> 503 <pathconvert property="cmdTxts" refid="javacSrc" pathsep=" " /> 504 505 <java fork="true" 506 failonerror="true" 507 classpathref="libpath" 508 classname="com.sun.tools.javac.Main"> 509 <arg value="-Xlint:-options"/> 510 <arg value="-Werror"/> 511 <arg value="-g"/> 512 <arg line="-sourcepath src"/> 513 <arg line="-d bin"/> 514 <arg line="${cmdTxts}"/> 515 <arg line="-version"/> 516 <!-- To prevent a cyclic dependency with the Checker 517 Framework, ignore type annotations in comments here. 518 Separate targets exist to check the qualifiers. --> 519 <arg line="-XDTA:noannotationsincomments"/> 520 <!-- Make sure we only have Java 7 source code and generate Java 7 bytecode. --> 521 <arg value="-source"/> 522 <arg value="7"/> 523 <arg value="-target"/> 524 <arg value="7"/> 525 </java> 526 527 </target> 528 529 <!-- Boilerplate to set jsr308javac property. Is there a better way? --> 530 <property environment="env"/> 531 <condition property="isUnix"> 532 <os family="unix" /> 533 </condition> 534 <condition property="isWindows"> 535 <os family="windows" /> 536 </condition> 537 <target name="init-jsr308javac-unix" if="isUnix"> 538 <property name="jsr308javac" value="${env.CHECKERFRAMEWORK}/checker/bin/javac" /> 539 </target> 540 <target name="init-jsr308javac-windows" if="isWindows"> 541 <property name="jsr308javac" value="${env.CHECKERFRAMEWORK}/checker/bin/javac.bat" /> 542 </target> 543 544 <target name="check-nullness" 545 description="Check for nullness errors." 546 depends="init,clean,init-jsr308javac-unix,init-jsr308javac-windows"> 547 <mkdir dir="bin"/> 548 <javac srcdir="src" destdir="bin" debug="true" encoding="8859_1" 549 fork="yes" 550 executable="${jsr308javac}"> 551 <compilerarg value="-version"/> 552 <compilerarg line="-target 5"/> 553 <compilerarg line="-processor org.checkerframework.checker.nonnull.NonNullFbcChecker"/> 554 <compilerarg value="-implicit:class"/> 555 <compilerarg line="-Awarns -Xmaxwarns 10000"/> 556 <classpath> 557 <path refid="libpath"/> 558 <pathelement location="${env.annotations}/checker/dist/checker.jar"/> 559 </classpath> 560 </javac> 561 </target> 562 563 564 <!-- This tags table includes the scene library. --> 565 <target name="etags" depends="tags"> 566 </target> 567 <target name="tags" 568 description="create Emacs TAGS table, including scene-lib files"> 569 <exec executable="/bin/sh" failonerror="true"> 570 <arg value="-c"/> 571 <arg value="etags `find src -name '*.java' | sort-directory-order` `find ../scene-lib -name '*.java' | sort-directory-order`"/> 572 </exec> 573 </target> 574 575 </project> 576