Home | History | Annotate | Download | only in annotation-tools
      1 <project name="annotation-tools" default="all"
      2          xmlns:if="ant:if" xmlns:unless="ant:unless">
      3 
      4   <property file="${user.home}/.annotations-tools.properties" />
      5   <property file="build.properties" />
      6 
      7   <!-- default location of projects, has effect only if not previously set -->
      8   <property name="asmx" location="asmx"/>
      9   <property name="scene-lib" location="scene-lib"/>
     10   <property name="afu" location="annotation-file-utilities"/>
     11 
     12   <target name="prep" description="Create required directories/files">
     13     <!-- Ant's copy task does not retain file permissions,
     14          so use <exec executable="cp"> instead.
     15     <copy file="bin-devel/git.pre-commit" tofile="../.git/hooks/pre-commit" preservelastmodified="true" />
     16     -->
     17 <!-- TODO
     18     <exec executable="cp">
     19       <arg value="-p"/>
     20       <arg value=".git.pre-commit"/>
     21       <arg value=".git/hooks/pre-commit"/>
     22     </exec>
     23 -->
     24   </target>
     25 
     26   <target name="all" description="Compile, run Javadoc, and run tests"
     27       depends="prep,compile,javadoc,test"/>
     28 
     29   <target name="compile" description="Compile all annotation tools"
     30       depends="compile-all"/>
     31 
     32   <target name="test" description="Test all the tools"
     33       depends="test-all"/>
     34 
     35   <target name="clean" depends="clean-all"/>
     36 
     37   <target name="compile-asmx">
     38       <ant dir="${asmx}" target="compile">
     39 	  <property name="product.noshrink" value="true"/>
     40       </ant>
     41   </target>
     42 
     43   <!-- TODO: Get this working -->
     44   <!-- Known to fail -->
     45   <target name="test-asmx">
     46       <ant dir="${asmx}" target="test"/>
     47   </target>
     48 
     49   <target name="compile-scene-lib">
     50       <ant dir="${scene-lib}" target="bin"/>
     51   </target>
     52 
     53   <target name="javadoc-scene-lib">
     54       <ant dir="${scene-lib}" target="javadoc"/>
     55   </target>
     56 
     57   <target name="test-scene-lib">
     58       <ant dir="${scene-lib}" target="test"/>
     59   </target>
     60 
     61   <target name="compile-afu">
     62       <ant dir="${afu}" target="jarfile"/>
     63   </target>
     64 
     65   <target name="javadoc-afu">
     66       <ant dir="${afu}" target="javadoc"/>
     67   </target>
     68 
     69   <target name="test-afu">
     70       <ant dir="${afu}" target="run-tests"/>
     71   </target>
     72 
     73   <target name="compile-all"
     74 	 depends="compile-asmx,compile-scene-lib,compile-afu"/>
     75   <!-- TODO: Add asmx tests when they work -->
     76   <target name="test-all"
     77 	 depends="test-scene-lib,test-afu"/>
     78   <target name="clean-all">
     79     <ant dir="${asmx}" target="clean"/>
     80     <ant dir="${scene-lib}" target="clean"/>
     81     <ant dir="${afu}" target="clean"/>
     82   </target>
     83 
     84   <target name="javadoc" depends="javadoc-scene-lib,javadoc-afu">
     85   </target>
     86 
     87   <target name="tags-scene-lib">
     88       <ant dir="${scene-lib}" target="tags"/>
     89   </target>
     90 
     91   <target name="tags-afu">
     92       <ant dir="${afu}" target="tags"/>
     93   </target>
     94 
     95   <target name="tags" depends="tags-scene-lib,tags-afu">
     96     <exec executable="etags" failonerror="true">
     97       <arg value="-i"/>
     98       <arg value="${scene-lib}/TAGS"/>
     99       <arg value="-i"/>
    100       <arg value="${afu}/TAGS"/>
    101     </exec>
    102   </target>
    103 
    104   <target name="html-validate"
    105 	  description="Validate that HTML files are well-formed; only works with JDK 8"
    106 	  depends="prep">
    107     <exec executable="html5validator">
    108       <arg value="--ignore"/>
    109       <arg value="/api/"/>
    110       <arg value="/build/"/>
    111       <arg value="/javadoc/"/>
    112       <arg value="/annotation-file-utilities/annotation-file-format.html"/>
    113       <arg value="/scene-lib/javadoc/"/>
    114     </exec>
    115   </target>
    116 
    117   <property name="style.args1" value="-r -n -e"/>
    118   <property name="style.args2" value="--exclude-dir=.git --exclude-dir=api --exclude-dir=asmx --exclude-dir=javadoc --exclude='*.aux' --exclude='*.class' --exclude='*.dvi' --exclude='*.eps' --exclude='*.jaif' --exclude='*.jar' --exclude='*.jtr' --exclude='*.log' --exclude='*.patch' --exclude='*.pdf' --exclude='*.png' --exclude='*.sty' --exclude='*.zip' --exclude='*~' --exclude='CFLogo.ai' --exclude='logfile.log.rec.index' --exclude='annotation-file-format.html' ."/>
    119 
    120   <target name="check-style"
    121 	  description="Check basic style guidelines"
    122 	  depends="prep">
    123     <!-- There should be a way to templatize the following. -->
    124     <exec executable="grep" outputproperty="trailingwhitespace" failonerror="false">
    125       <arg line="${style.args1}"/>
    126       <arg value=" $"/>
    127       <arg line="${style.args2}"/>
    128     </exec>
    129     <fail message="Trailing whitespace:${line.separator}${trailingwhitespace}">
    130       <condition>
    131 	<not>
    132 	  <equals arg1="${trailingwhitespace}" arg2=""/>
    133 	</not>
    134       </condition>
    135     </fail>
    136     <exec executable="grep" outputproperty="missingspace" failonerror="false">
    137       <arg line="${style.args1}"/>
    138       <arg value="[^\\]\b\(else\|finally\|try\){\|}\(catch\|else\|finally\)\b\|){\($\|[^0-9]\)\|\b\(catch\|for\|if\|while\)("/>
    139       <arg line="${style.args2}"/>
    140       <arg line="--exclude=build.xml"/>
    141     </exec>
    142     <fail message="Missing space:${line.separator}${missingspace}">
    143       <condition>
    144 	<not>
    145 	  <equals arg1="${missingspace}" arg2=""/>
    146 	</not>
    147       </condition>
    148     </fail>
    149   </target>
    150 
    151   <fileset id="formatted.java.files" dir="." includes="**/*.java" excludes="**/asmx/"/>
    152 
    153   <condition property="isMac">
    154     <os family="mac" />
    155   </condition>
    156 
    157   <!-- Avoids "Argument list too long" message.  You can also set
    158        this property in file local.properties. -->
    159   <condition property="maxparallel" value="1000" else="-1">
    160     <isset property="isMac"/>
    161   </condition>
    162 
    163   <target name="-run-google-java-format.check">
    164     <condition property="run-google-java-format.exists">
    165       <available file=".run-google-java-format" type="dir"/>
    166     </condition>
    167   </target>
    168 
    169   <target name="-get-run-google-java-format"
    170           description="Obtain the run-google-java-format project"
    171           depends="-run-google-java-format.check"
    172           unless="run-google-java-format.exists">
    173     <exec executable="git"
    174           dir=".">
    175       <arg value="clone"/>
    176       <arg value="-q"/>
    177       <arg value="https://github.com/plume-lib/run-google-java-format.git"/>
    178       <arg value=".run-google-java-format"/>
    179     </exec>
    180   </target>
    181 
    182   <target name="-update-run-google-java-format"
    183           description="Update the run-google-java-format project"
    184           depends="-get-run-google-java-format">
    185     <exec executable="git"
    186           dir=".run-google-java-format">
    187       <arg value="pull"/>
    188       <arg value="-q"/>
    189     </exec>
    190   </target>
    191 
    192 <!-- TEMPORARY: Do not run this until branches have been merged. -->
    193   <target name="reformat" depends="-update-run-google-java-format"
    194           description="Reformat Java code">
    195     <apply executable="python" parallel="true" maxparallel="${maxparallel}" failonerror="true">
    196       <arg value="./.run-google-java-format/run-google-java-format.py"/>
    197       <fileset refid="formatted.java.files"/>
    198     </apply>
    199   </target>
    200 
    201   <target name="check-format" depends="-update-run-google-java-format"
    202           description="Check Java code formatting">
    203     <apply executable="python" parallel="true" maxparallel="${maxparallel}"
    204        failonerror="false" resultproperty="check.format.result"
    205        outputproperty="check.format.stdout" errorproperty="check.format.stderr">
    206       <arg value="./.run-google-java-format/check-google-java-format.py"/>
    207       <fileset refid="formatted.java.files"/>
    208     </apply>
    209     <echo unless:blank="${check.format.stdout}">${check.format.stdout}</echo>
    210     <echo unless:blank="${check.format.stderr}">${check.format.stderr}</echo>
    211     <echo unless:blank="${check.format.stderr}">Fix syntax errors, then re-run:  ant check-format</echo>
    212     <echo unless:blank="${check.format.stdout}" if:blank="${check.format.stderr}">Try running:  ant reformat</echo>
    213     <fail>
    214       <condition>
    215         <not>
    216           <equals arg1="0" arg2="${check.format.result}"/>
    217         </not>
    218       </condition>
    219     </fail>
    220   </target>
    221 
    222 </project>
    223