aboutsummaryrefslogtreecommitdiff
path: root/build.xml
blob: 6566935345c6019976d6bc5af3e700f3ecf93b49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<project name="annotation-tools" default="all"
         xmlns:if="ant:if" xmlns:unless="ant:unless">

  <property file="${user.home}/.annotations-tools.properties" />
  <property file="build.properties" />

  <!-- default location of projects, has effect only if not previously set -->
  <property name="asmx" location="asmx"/>
  <property name="scene-lib" location="scene-lib"/>
  <property name="afu" location="annotation-file-utilities"/>

  <target name="prep" description="Create required directories/files">
    <!-- Ant's copy task does not retain file permissions,
         so use <exec executable="cp"> instead.
    <copy file="bin-devel/git.pre-commit" tofile="../.git/hooks/pre-commit" preservelastmodified="true" />
    -->
<!-- TODO
    <exec executable="cp">
      <arg value="-p"/>
      <arg value=".git.pre-commit"/>
      <arg value=".git/hooks/pre-commit"/>
    </exec>
-->
  </target>

  <target name="all" description="Compile, run Javadoc, and run tests"
      depends="prep,compile,javadoc,test"/>

  <target name="compile" description="Compile all annotation tools"
      depends="compile-all"/>

  <target name="test" description="Test all the tools"
      depends="test-all"/>

  <target name="clean" depends="clean-all"/>

  <target name="compile-asmx">
      <ant dir="${asmx}" target="compile">
	  <property name="product.noshrink" value="true"/>
      </ant>
  </target>

  <!-- TODO: Get this working -->
  <!-- Known to fail -->
  <target name="test-asmx">
      <ant dir="${asmx}" target="test"/>
  </target>

  <target name="compile-scene-lib">
      <ant dir="${scene-lib}" target="bin"/>
  </target>

  <target name="javadoc-scene-lib">
      <ant dir="${scene-lib}" target="javadoc"/>
  </target>

  <target name="test-scene-lib">
      <ant dir="${scene-lib}" target="test"/>
  </target>

  <target name="compile-afu">
      <ant dir="${afu}" target="jarfile"/>
  </target>

  <target name="javadoc-afu">
      <ant dir="${afu}" target="javadoc"/>
  </target>

  <target name="test-afu">
      <ant dir="${afu}" target="run-tests"/>
  </target>

  <target name="compile-all"
	 depends="compile-asmx,compile-scene-lib,compile-afu"/>
  <!-- TODO: Add asmx tests when they work -->
  <target name="test-all"
	 depends="test-scene-lib,test-afu"/>
  <target name="clean-all">
    <ant dir="${asmx}" target="clean"/>
    <ant dir="${scene-lib}" target="clean"/>
    <ant dir="${afu}" target="clean"/>
  </target>

  <target name="javadoc" depends="javadoc-scene-lib,javadoc-afu">
  </target>

  <target name="tags-scene-lib">
      <ant dir="${scene-lib}" target="tags"/>
  </target>

  <target name="tags-afu">
      <ant dir="${afu}" target="tags"/>
  </target>

  <target name="tags" depends="tags-scene-lib,tags-afu">
    <exec executable="etags" failonerror="true">
      <arg value="-i"/>
      <arg value="${scene-lib}/TAGS"/>
      <arg value="-i"/>
      <arg value="${afu}/TAGS"/>
    </exec>
  </target>

  <target name="html-validate"
	  description="Validate that HTML files are well-formed; only works with JDK 8"
	  depends="prep">
    <exec executable="html5validator">
      <arg value="--ignore"/>
      <arg value="/api/"/>
      <arg value="/build/"/>
      <arg value="/javadoc/"/>
      <arg value="/annotation-file-utilities/annotation-file-format.html"/>
      <arg value="/scene-lib/javadoc/"/>
    </exec>
  </target>

  <property name="style.args1" value="-r -n -e"/>
  <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' ."/>

  <target name="check-style"
	  description="Check basic style guidelines"
	  depends="prep">
    <!-- There should be a way to templatize the following. -->
    <exec executable="grep" outputproperty="trailingwhitespace" failonerror="false">
      <arg line="${style.args1}"/>
      <arg value=" $"/>
      <arg line="${style.args2}"/>
    </exec>
    <fail message="Trailing whitespace:${line.separator}${trailingwhitespace}">
      <condition>
	<not>
	  <equals arg1="${trailingwhitespace}" arg2=""/>
	</not>
      </condition>
    </fail>
    <exec executable="grep" outputproperty="missingspace" failonerror="false">
      <arg line="${style.args1}"/>
      <arg value="[^\\]\b\(else\|finally\|try\){\|}\(catch\|else\|finally\)\b\|){\($\|[^0-9]\)\|\b\(catch\|for\|if\|while\)("/>
      <arg line="${style.args2}"/>
      <arg line="--exclude=build.xml"/>
    </exec>
    <fail message="Missing space:${line.separator}${missingspace}">
      <condition>
	<not>
	  <equals arg1="${missingspace}" arg2=""/>
	</not>
      </condition>
    </fail>
  </target>

  <fileset id="formatted.java.files" dir="." includes="**/*.java" excludes="**/asmx/"/>

  <condition property="isMac">
    <os family="mac" />
  </condition>

  <!-- Avoids "Argument list too long" message.  You can also set
       this property in file local.properties. -->
  <condition property="maxparallel" value="1000" else="-1">
    <isset property="isMac"/>
  </condition>

  <target name="-run-google-java-format.check">
    <condition property="run-google-java-format.exists">
      <available file=".run-google-java-format" type="dir"/>
    </condition>
  </target>

  <target name="-get-run-google-java-format"
          description="Obtain the run-google-java-format project"
          depends="-run-google-java-format.check"
          unless="run-google-java-format.exists">
    <exec executable="git"
          dir=".">
      <arg value="clone"/>
      <arg value="-q"/>
      <arg value="https://github.com/plume-lib/run-google-java-format.git"/>
      <arg value=".run-google-java-format"/>
    </exec>
  </target>

  <target name="-update-run-google-java-format"
          description="Update the run-google-java-format project"
          depends="-get-run-google-java-format">
    <exec executable="git"
          dir=".run-google-java-format">
      <arg value="pull"/>
      <arg value="-q"/>
    </exec>
  </target>

<!-- TEMPORARY: Do not run this until branches have been merged. -->
  <target name="reformat" depends="-update-run-google-java-format"
          description="Reformat Java code">
    <apply executable="python" parallel="true" maxparallel="${maxparallel}" failonerror="true">
      <arg value="./.run-google-java-format/run-google-java-format.py"/>
      <fileset refid="formatted.java.files"/>
    </apply>
  </target>

  <target name="check-format" depends="-update-run-google-java-format"
          description="Check Java code formatting">
    <apply executable="python" parallel="true" maxparallel="${maxparallel}"
       failonerror="false" resultproperty="check.format.result"
       outputproperty="check.format.stdout" errorproperty="check.format.stderr">
      <arg value="./.run-google-java-format/check-google-java-format.py"/>
      <fileset refid="formatted.java.files"/>
    </apply>
    <echo unless:blank="${check.format.stdout}">${check.format.stdout}</echo>
    <echo unless:blank="${check.format.stderr}">${check.format.stderr}</echo>
    <echo unless:blank="${check.format.stderr}">Fix syntax errors, then re-run:  ant check-format</echo>
    <echo unless:blank="${check.format.stdout}" if:blank="${check.format.stderr}">Try running:  ant reformat</echo>
    <fail>
      <condition>
        <not>
          <equals arg1="0" arg2="${check.format.result}"/>
        </not>
      </condition>
    </fail>
  </target>

</project>