| <?xml version="1.0"?> | |
| <project name="annotation-file-utilities" default="zipfile"> | |
| <description> | |
| Ant build file for the annotation file utilities. | |
| Run "ant -projecthelp" for a full list of options. | |
| </description> | |
| <property environment="env"/> | |
| <property name="java-version" value="8"/> | |
| <tstamp> | |
| <format property="TIME" pattern="yy-MM-dd-HH-mm-ss-SS" /> | |
| </tstamp> | |
| <!-- Avoid conflicts between multiple users on the same computer. --> | |
| <property name="tmpdir" location="${java.io.tmpdir}/${user.name}/${TIME}" /> | |
| <!-- The distribution is the result of zipping this directory. --> | |
| <property name="temp-annotation-tools" location="${tmpdir}/annotation-tools" /> | |
| <!-- Can't I just reuse temp-annotation-file-utilities, rather than | |
| having this separate directory? --> | |
| <property name="temp-jarfile" location="${tmpdir}/annotation-file-utilities-jarfile" /> | |
| <target name="init-properties"> | |
| <condition property="exists.build.properties"> | |
| <available file="build.properties"/> | |
| </condition> | |
| <fail | |
| unless="exists.build.properties" | |
| message="Local build.properites file is missing."/> | |
| <property file="build.properties"/> | |
| <fail | |
| unless="global.build.properties" | |
| message="Local build.properties file did not define global buildfile in property global.build.properties"/> | |
| <condition property="exists.global.build.properties"> | |
| <available file="${global.build.properties}"/> | |
| </condition> | |
| <fail | |
| unless="exists.global.build.properties" | |
| message="File ${global.build.properties} file not found."/> | |
| <property file="${global.build.properties}"/> | |
| <fail | |
| unless="user.build.properties" | |
| message="Local build.properties file did not define global buildfile in property user.build.properties"/> | |
| <condition property="exists.user.build.properties"> | |
| <available file="${user.build.properties}"/> | |
| </condition> | |
| <fail | |
| unless="exists.user.build.properties" | |
| message="File ${user.build.properties} file not found."/> | |
| <property file="${user.build.properties}"/> | |
| <echo message="annotations-compiler: ${annotations-compiler}"/> | |
| <!-- convert relative to absolute pathname --> | |
| <property name="annotations-compiler-absolute" location="${annotations-compiler}" /> | |
| </target> | |
| <!-- Compiles all the subparts of the Annotation File Utilities. --> | |
| <target name="init-dependencies" | |
| depends="init-properties"> | |
| <ant dir="${asmx}" target="bin"> | |
| <property name="product.noshrink" value="true"/> | |
| </ant> | |
| <ant dir="${scene-lib}" target="bin"/> | |
| <!-- repository version only: --> | |
| <!-- I don't see the need for this. --> | |
| <!-- <ant dir="${annotations-compiler}" antfile="make/build.xml" target="build"/> --> | |
| </target> | |
| <target name="init" | |
| depends="init-properties, init-dependencies"> | |
| <fileset dir="src" id="src-files"> | |
| <include name="**/*.java"/> | |
| </fileset> | |
| <path id="libpath"> | |
| <!-- alternate for distribution: | |
| <pathelement location="${annotations-compiler}/bin"/> | |
| --> | |
| <pathelement location="${annotations-compiler}/dist/lib/javac.jar"/> | |
| <pathelement location="${annotation-tools}/annotation-file-utilities/lib/plume-core.jar"/> | |
| <pathelement location="${annotation-tools}/annotation-file-utilities/lib/guava-20.0.jar"/> | |
| <pathelement location="${scene-lib}/bin"/> | |
| <pathelement location="${asmx}/bin"/> | |
| <!-- needed for optionsdoc target --> | |
| <pathelement location="bin"/> | |
| <!-- additional for distribution: | |
| <pathelement location="${jre1.6.0}"/> | |
| --> | |
| </path> | |
| </target> | |
| <path id="javadoc-sourcepath"> | |
| <pathelement location="src"/> | |
| </path> | |
| <target name="javadoc-clean"> | |
| <delete dir="javadoc"/> | |
| </target> | |
| <target name="javadoc" depends="javadoc-clean, init"> | |
| <javadoc sourcepathref="javadoc-sourcepath" | |
| classpathref="libpath" | |
| failonerror="true" | |
| packagenames="*" | |
| destdir="javadoc" | |
| access="public" | |
| /> | |
| <!-- | |
| noqualifier="annotations:annotations.el:annotations.field:annotations.io:annotations.io.classfile:annotations.util:annotations.util.coll:java.lang" | |
| --> | |
| </target> | |
| <target name="optionsdoc" depends="javadoc, init"> | |
| <javadoc sourcepathref="javadoc-sourcepath" | |
| sourcefiles="src/annotator/Main.java" | |
| classpathref="libpath" | |
| docletpathref="libpath" | |
| failonerror="true" | |
| > | |
| <doclet name="plume.OptionsDoclet"> | |
| <param name="-format" value="javadoc"/> | |
| <param name="-i"/> | |
| <param name="-docfile" value="src/annotator/Main.java"/> | |
| </doclet> | |
| </javadoc> | |
| <javadoc sourcepathref="javadoc-sourcepath" | |
| sourcefiles="src/annotator/Main.java" | |
| classpathref="libpath" | |
| docletpathref="libpath" | |
| failonerror="true" | |
| > | |
| <doclet name="plume.OptionsDoclet"> | |
| <param name="-format" value="html"/> | |
| <param name="-i"/> | |
| <param name="-docfile" value="annotation-file-utilities.html"/> | |
| </doclet> | |
| </javadoc> | |
| </target> | |
| <target name="jarfile.check.uptodate"> | |
| <uptodate property="bin.uptodate" targetfile="annotation-file-utilities.jar"> | |
| <srcfiles dir="bin" /> | |
| </uptodate> | |
| <uptodate property="asmx.bin.uptodate" targetfile="annotation-file-utilities.jar"> | |
| <srcfiles dir="${asmx}/bin" excludes="tmp/**"/> | |
| </uptodate> | |
| <uptodate property="scene-lib.bin.uptodate" targetfile="annotation-file-utilities.jar"> | |
| <srcfiles dir="${scene-lib}/bin" excludes="annotations-expected/**,annotations/tests/**"/> | |
| </uptodate> | |
| <uptodate property="annotations-compiler.uptodate" targetfile="annotation-file-utilities.jar" srcfile="${annotations-compiler}/dist/lib/javac.jar"/> | |
| <uptodate property="plume.uptodate" targetfile="annotation-file-utilities.jar" srcfile="lib/plume-core.jar"/> | |
| <uptodate property="google-collect.uptodate" targetfile="annotation-file-utilities.jar" srcfile="lib/guava-20.0.jar"/> | |
| <condition property="jarfile.uptodate"> | |
| <and> | |
| <isset property="bin.uptodate"/> | |
| <isset property="asmx.bin.uptodate"/> | |
| <isset property="scene-lib.bin.uptodate"/> | |
| <isset property="annotations-compiler.uptodate"/> | |
| <isset property="plume.uptodate"/> | |
| <isset property="google-collect.uptodate"/> | |
| </and> | |
| </condition> | |
| <echo message="bin.uptodate: ${bin.uptodate}"/> | |
| <echo message="asmx.bin.uptodate: ${asmx.bin.uptodate}"/> | |
| <echo message="scene-lib.bin.uptodate: ${scene-lib.bin.uptodate}"/> | |
| <echo message="annotations-compiler.uptodate: ${annotations-compiler.uptodate}"/> | |
| <echo message="plume.uptodate: ${plume.uptodate}"/> | |
| <echo message="google-collect.uptodate: ${google-collect.uptodate}"/> | |
| <echo message="jarfile.uptodate: ${jarfile.uptodate}"/> | |
| </target> | |
| <target name="jarfile" | |
| depends="init,build,jarfile.check.uptodate" | |
| unless="jarfile.uptodate" | |
| description="create the class library annotation-file-utilities.jar"> | |
| <echo message="Using temporary directory: ${temp-jarfile}"/> | |
| <delete dir="${temp-jarfile}"/> | |
| <mkdir dir="${temp-jarfile}"/> | |
| <echo message="Copying .class files to ${temp-jarfile}"/> | |
| <copy todir="${temp-jarfile}"> | |
| <fileset dir="bin" /> | |
| <fileset dir="${asmx}/bin" excludes="tmp/**"/> | |
| <fileset dir="${scene-lib}/bin" excludes="annotations-expected/**,annotations/tests/**"/> | |
| </copy> | |
| <!-- Also need to get class files in libraries --> | |
| <unjar src="lib/plume-core.jar" dest="${temp-jarfile}"> | |
| <patternset> | |
| <include name="**/*.class"/> | |
| <exclude name="META-INF/" /> | |
| </patternset> | |
| </unjar> | |
| <unjar src="lib/guava-20.0.jar" dest="${temp-jarfile}"> | |
| <patternset> | |
| <include name="com/google/common/base/**/*.class"/> | |
| <include name="com/google/common/collect/**/*.class"/> | |
| <include name="com/google/common/escape/**/*.class"/> | |
| <exclude name="META-INF/" /> | |
| </patternset> | |
| </unjar> | |
| <unjar src="${annotations-compiler}/dist/lib/javac.jar" dest="${temp-jarfile}"> | |
| <patternset> | |
| <include name="**/*.class"/> | |
| <exclude name="META-INF/" /> | |
| </patternset> | |
| </unjar> | |
| <!-- Actually create a single .jar file of all the class files, | |
| scripts and documentation --> | |
| <echo message="Creating jarfile annotation-file-utilities.jar"/> | |
| <jar destfile="annotation-file-utilities.jar"> | |
| <fileset dir="${temp-jarfile}"/> | |
| </jar> | |
| <!-- Delete class files copied over --> | |
| <echo message="Deleting temporary directory: ${temp-jarfile}"/> | |
| <delete dir="${temp-jarfile}"/> | |
| </target> | |
| <target name="check-git-status" depends="init-properties"> | |
| <exec executable="git" failonerror="true" | |
| outputproperty="status.output"> | |
| <arg value="status" /> | |
| </exec> | |
| <condition property="status.output.empty"> | |
| <equals | |
| arg1="${status.output}" | |
| arg2=""/> | |
| </condition> | |
| <fail unless="status.output.empty" | |
| message="`git status' did not return empty output. | |
| Commit/add/remove files as appropriate, then re-try."/> | |
| </target> | |
| <!-- Copy files from repository to temporary directory from which they | |
| will be packaged up. --> | |
| <target name="update-workspace" depends="init-properties"> | |
| <delete dir="${temp-annotation-tools}" /> | |
| <exec executable="git" failonerror="true"> | |
| <arg value="clone" /> | |
| <arg value="${annotation-tools}" /> | |
| <arg value="${temp-annotation-tools}" /> | |
| </exec> | |
| <delete dir="${temp-annotation-tools}/scene-lib.orig-hand-annos" /> | |
| <delete dir="${temp-annotation-tools}/.git" /> | |
| <delete file="${temp-annotation-tools}/.gitignore" /> | |
| <delete file="${temp-annotation-tools}/.hg_archival.txt" /> | |
| <delete file="${temp-annotation-tools}/.hgignore" /> | |
| <copy todir="${temp-annotation-tools}/annotation-file-utilities"> | |
| <fileset dir="${afu}"> | |
| <include name="annotation-file-format.dvi"/> | |
| <include name="annotation-file-format.html"/> | |
| <include name="annotation-file-format.pdf"/> | |
| <include name="annotation-file-utilities.jar"/> | |
| <include name="bin/**"/> | |
| </fileset> | |
| </copy> | |
| <copy todir="${temp-annotation-tools}/asmx"> | |
| <fileset dir="${asmx}"> | |
| <include name="bin/**"/> | |
| </fileset> | |
| </copy> | |
| <copy todir="${temp-annotation-tools}/scene-lib"> | |
| <fileset dir="${scene-lib}"> | |
| <include name="bin/**"/> | |
| </fileset> | |
| </copy> | |
| </target> | |
| <target name="zipfile" | |
| depends="jarfile,annotation-file-format,run-tests,update-workspace" | |
| description="create the distribution: annotation-tools.zip"> | |
| <!-- Create a new directory containing all the files and then zip that | |
| directory, so that when the user unzips they extract exactly one | |
| directory. --> | |
| <!-- In order for the shell scripts to have the proper execution bit set, | |
| include them specifically with the right permissions. Ant presently | |
| does not use the file's permissions themselves to do this. --> | |
| <zip destfile="annotation-tools.zip" compress="true"> | |
| <fileset dir="${tmpdir}"> | |
| <include name="annotation-tools/"/> | |
| <exclude name="annotation-tools/annotation-file-utilities/scripts/extract-annotations"/> | |
| <exclude name="annotation-tools/annotation-file-utilities/scripts/insert-annotations"/> | |
| <exclude name="annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source"/> | |
| </fileset> | |
| <zipfileset dir="${tmpdir}" filemode="755"> | |
| <include name="annotation-tools/annotation-file-utilities/scripts/extract-annotations"/> | |
| <include name="annotation-tools/annotation-file-utilities/scripts/insert-annotations"/> | |
| <include name="annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source"/> | |
| </zipfileset> | |
| </zip> | |
| <!-- Delete temporary files once they have been zipped. --> | |
| <!-- | |
| <delete dir="${temp-annotation-file-utilities}"/> | |
| --> | |
| </target> | |
| <macrodef name="update"> | |
| <attribute name="file"/> | |
| <attribute name="start"/> | |
| <attribute name="end" default=""/> | |
| <attribute name="with"/> | |
| <sequential> | |
| <echo level="info" message="updating @{file}"/> | |
| <replaceregexp file="@{file}" byline="true" | |
| match="@{start}.*@{end}" replace="@{start}@{with}@{end}"/> | |
| </sequential> | |
| </macrodef> | |
| <target name="update-versions" depends="init-properties"> | |
| <fail unless="release.ver" message="You must specify a release version to update to"/> | |
| <fail unless="release.date" message="You must specify a release date to update to"/> | |
| <property name="release.version.regexp" value="\d\.\d\.\d+(?:\.\d)"/> | |
| <property name="afuWebPage" value="${annotation-tools}/annotation-file-utilities/annotation-file-utilities.html"/> | |
| <replaceregexp file="${afuWebPage}" byline="true" | |
| match="annotation-tools-${release.version.regexp}{0,1}.zip" replace="annotation-tools-${release.ver}.zip"/> | |
| <update file="${afuWebPage}" | |
| start="${afu.zip.ver.0}" end="${afu.zip.ver.1}" | |
| with="annotation-tools-${release.ver}.zip"/> | |
| <update file="${afuWebPage}" | |
| start="${afu.ver.0}" end="${afu.ver.1}" | |
| with="${release.ver}, ${release.date}"/> | |
| <update file="${afuWebPage}" | |
| start="${afu.date.0}" end="${afu.date.1}" | |
| with="${release.date}"/> | |
| <property name="newCfrValue" value="Annotation File Utilities v${release.ver}"/> | |
| <property name="ClassFileReaderPath" value="${annotation-tools}/scene-lib/src/annotations/io/classfile/ClassFileReader.java"/> | |
| <echo level="info" message="updating ${ClassFileReaderPath}"/> | |
| <replaceregexp file="${ClassFileReaderPath}" byline="true" | |
| match="${afu.cfr.pattern}" replace="${newCfrValue}"/> | |
| </target> | |
| <!-- TODO: I am not sure this target works as the original author intended | |
| TODO: (i.e. I don't think check-git-status gets executed twice) | |
| TODO: but I am maintaining the previous behavior. | |
| --> | |
| <target name="web" depends="check-git-status,web-no-checks,check-git-status"/> | |
| <!-- New release process runs checks prior to running the web-no-checks target--> | |
| <target name="web-no-checks" depends="clean,zipfile" | |
| description="export the zipfile, etc. to its website"> | |
| <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_"/> | |
| <fail unless="afu.version" message="You must specify an afu.version, such as 3.6.22"/> | |
| <echo message="Export location: ${deploy-dir}"/> | |
| <echo message="Copying annotation-tools.zip"/> | |
| <copy file="annotation-tools.zip" | |
| tofile="${deploy-dir}/annotation-tools-${afu.version}.zip"/> | |
| <echo message="Copying annotation-file-utilities.html"/> | |
| <copy file="annotation-file-utilities.html" | |
| todir="${deploy-dir}"/> | |
| <copy file="changelog.html" | |
| todir="${deploy-dir}"/> | |
| <echo message="Copying annotation-file-format.{html,pdf}"/> | |
| <copy file="annotation-file-format.html" | |
| todir="${deploy-dir}"/> | |
| <copy file="annotation-file-format.pdf" | |
| todir="${deploy-dir}"/> | |
| <copy todir="${deploy-dir}/figures" flatten="true"> | |
| <fileset dir="figures"> | |
| <include name="*.svg"/> | |
| <include name="*.png"/> | |
| <include name="*.gif"/> | |
| </fileset> | |
| </copy> | |
| <symlink overwrite="true" | |
| link="${deploy-dir}/index.html" | |
| resource="annotation-file-utilities.html"/> | |
| </target> | |
| <target name="annotation-file-format-clean" | |
| description="removes generated documentation files"> | |
| <delete file="annotation-file-format.aux"/> | |
| <delete file="annotation-file-format.dvi"/> | |
| <delete file="annotation-file-format.haux"/> | |
| <delete file="annotation-file-format.html"/> | |
| <delete file="annotation-file-format.htoc"/> | |
| <delete file="annotation-file-format.log"/> | |
| <delete file="annotation-file-format.pdf"/> | |
| <delete file="annotation-file-format.toc"/> | |
| <exec executable="make" failonerror="true"> | |
| <arg value="-C"/> | |
| <arg value="figures"/> | |
| <arg value="clean"/> | |
| </exec> | |
| <delete file="scene-lib-type-hierarchy.png"/> | |
| </target> | |
| <!-- | |
| A problem is that the document date is the date that LaTeX was run | |
| rather than the date of last modification; that should be fixed in | |
| the document, perhaps. --> | |
| <target name="annotation-file-format" | |
| description="Make documentation: annotation-file-format.{html,pdf}"> | |
| <exec executable="make" failonerror="true"> | |
| <arg value="-C"/> | |
| <arg value="figures"/> | |
| </exec> | |
| <exec executable="latex" failonerror="true"> | |
| <arg value="annotation-file-format.tex"/> | |
| </exec> | |
| <exec executable="bibtex" failonerror="true"> | |
| <arg value="annotation-file-format"/> | |
| </exec> | |
| <exec executable="latex" failonerror="true"> | |
| <arg value="annotation-file-format.tex"/> | |
| </exec> | |
| <exec executable="latex" failonerror="true"> | |
| <arg value="annotation-file-format.tex"/> | |
| </exec> | |
| <exec executable="pdflatex" failonerror="true"> | |
| <arg value="annotation-file-format.tex"/> | |
| </exec> | |
| <exec executable="hevea" failonerror="true"> | |
| <arg value="-fix"/> | |
| <arg value="-exec"/> | |
| <arg value="xxdate.exe"/> | |
| <arg value="urlhref.hva"/> | |
| <arg value="annotation-file-format.tex"/> | |
| </exec> | |
| </target> | |
| <target name="clean" depends="annotation-file-format-clean,clean-tests" | |
| description="removes generated files (e.g., .jar, .zip)"> | |
| <delete dir="bin"/> | |
| <!-- <echo message="Deleting temporary directory: ${temp-jarfile}"/> --> | |
| <delete dir="${temp-jarfile}"/> | |
| <delete dir="${temp-annotation-file-utilities}"/> | |
| <!-- <echo message="Deleting previous distribution: annotation-file-utilities.{jar,zip}"/> --> | |
| <delete file="annotation-file-utilities.jar"/> | |
| <delete file="annotation-tools.zip"/> | |
| </target> | |
| <target name="run-tests" depends="init-properties" | |
| description="run tests for the annotator"> | |
| <exec dir="tests/" executable="make" failonerror="true"> | |
| <env key="XJAVAC" value="${annotations-compiler-absolute}/dist/bin/javac -g ${xjavac.args}"/> | |
| <env key="JAVAC_JAR" value="${annotations-compiler-absolute}/dist/lib/javac.jar"/> | |
| </exec> | |
| </target> | |
| <target name="clean-tests" description="removes generated test files"> | |
| <exec dir="tests/" executable="make" failonerror="true"> | |
| <arg value="clean"/> | |
| </exec> | |
| <exec dir="tests/source-extension/" executable="make" failonerror="true"> | |
| <arg value="clean"/> | |
| </exec> | |
| <exec dir="tests/system-test/" executable="make" failonerror="true"> | |
| <arg value="clean"/> | |
| </exec> | |
| </target> | |
| <target name="bin" | |
| depends="build"/> | |
| <target name="build" | |
| depends="init" | |
| description="compile all source files"> | |
| <mkdir dir="bin"/> | |
| <fileset dir="src" id="javacSrc"> | |
| <include name="**/*.java" /> | |
| </fileset> | |
| <pathconvert property="cmdTxts" refid="javacSrc" pathsep=" " /> | |
| <java fork="true" | |
| failonerror="true" | |
| classpathref="libpath" | |
| classname="com.sun.tools.javac.Main"> | |
| <arg value="-Xlint:-options"/> | |
| <arg value="-Werror"/> | |
| <arg value="-g"/> | |
| <arg line="-sourcepath src"/> | |
| <arg line="-d bin"/> | |
| <arg line="${cmdTxts}"/> | |
| <arg line="-version"/> | |
| <!-- To prevent a cyclic dependency with the Checker | |
| Framework, ignore type annotations in comments here. | |
| Separate targets exist to check the qualifiers. --> | |
| <arg line="-XDTA:noannotationsincomments"/> | |
| <!-- Make sure we only have Java 7 source code and generate Java 7 bytecode. --> | |
| <arg value="-source"/> | |
| <arg value="7"/> | |
| <arg value="-target"/> | |
| <arg value="7"/> | |
| </java> | |
| </target> | |
| <!-- Boilerplate to set jsr308javac property. Is there a better way? --> | |
| <property environment="env"/> | |
| <condition property="isUnix"> | |
| <os family="unix" /> | |
| </condition> | |
| <condition property="isWindows"> | |
| <os family="windows" /> | |
| </condition> | |
| <target name="init-jsr308javac-unix" if="isUnix"> | |
| <property name="jsr308javac" value="${env.CHECKERFRAMEWORK}/checker/bin/javac" /> | |
| </target> | |
| <target name="init-jsr308javac-windows" if="isWindows"> | |
| <property name="jsr308javac" value="${env.CHECKERFRAMEWORK}/checker/bin/javac.bat" /> | |
| </target> | |
| <target name="check-nullness" | |
| description="Check for nullness errors." | |
| depends="init,clean,init-jsr308javac-unix,init-jsr308javac-windows"> | |
| <mkdir dir="bin"/> | |
| <javac srcdir="src" destdir="bin" debug="true" encoding="8859_1" | |
| fork="yes" | |
| executable="${jsr308javac}"> | |
| <compilerarg value="-version"/> | |
| <compilerarg line="-target 5"/> | |
| <compilerarg line="-processor org.checkerframework.checker.nonnull.NonNullFbcChecker"/> | |
| <compilerarg value="-implicit:class"/> | |
| <compilerarg line="-Awarns -Xmaxwarns 10000"/> | |
| <classpath> | |
| <path refid="libpath"/> | |
| <pathelement location="${env.annotations}/checker/dist/checker.jar"/> | |
| </classpath> | |
| </javac> | |
| </target> | |
| <!-- This tags table includes the scene library. --> | |
| <target name="etags" depends="tags"> | |
| </target> | |
| <target name="tags" | |
| description="create Emacs TAGS table, including scene-lib files"> | |
| <exec executable="/bin/sh" failonerror="true"> | |
| <arg value="-c"/> | |
| <arg value="etags `find src -name '*.java' | sort-directory-order` `find ../scene-lib -name '*.java' | sort-directory-order`"/> | |
| </exec> | |
| </target> | |
| </project> |