blob: 6566935345c6019976d6bc5af3e700f3ecf93b49 [file] [log] [blame]
Michael Ernst133928f2017-06-14 18:05:29 -07001<project name="annotation-tools" default="all"
2 xmlns:if="ant:if" xmlns:unless="ant:unless">
Mahmood Ali932021b2009-10-03 02:05:56 -04003
Michael Ernst762a40e2017-05-06 10:39:19 -07004 <property file="${user.home}/.annotations-tools.properties" />
5 <property file="build.properties" />
Mahmood Ali932021b2009-10-03 02:05:56 -04006
Michael Ernst762a40e2017-05-06 10:39:19 -07007 <!-- 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"/>
Mahmood Ali932021b2009-10-03 02:05:56 -040011
Michael Ernst762a40e2017-05-06 10:39:19 -070012 <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>
Mahmood Ali932021b2009-10-03 02:05:56 -040025
Michael Ernst762a40e2017-05-06 10:39:19 -070026 <target name="all" description="Compile, run Javadoc, and run tests"
27 depends="prep,compile,javadoc,test"/>
Mahmood Ali932021b2009-10-03 02:05:56 -040028
Michael Ernst762a40e2017-05-06 10:39:19 -070029 <target name="compile" description="Compile all annotation tools"
30 depends="compile-all"/>
Mahmood Ali932021b2009-10-03 02:05:56 -040031
Michael Ernst762a40e2017-05-06 10:39:19 -070032 <target name="test" description="Test all the tools"
33 depends="test-all"/>
Mahmood Ali932021b2009-10-03 02:05:56 -040034
Michael Ernst762a40e2017-05-06 10:39:19 -070035 <target name="clean" depends="clean-all"/>
Dan Browne0a33f52016-03-31 10:38:58 -070036
Michael Ernst762a40e2017-05-06 10:39:19 -070037 <target name="compile-asmx">
38 <ant dir="${asmx}" target="compile">
39 <property name="product.noshrink" value="true"/>
40 </ant>
41 </target>
Dan Browne0a33f52016-03-31 10:38:58 -070042
Michael Ernst762a40e2017-05-06 10:39:19 -070043 <!-- TODO: Get this working -->
44 <!-- Known to fail -->
45 <target name="test-asmx">
46 <ant dir="${asmx}" target="test"/>
47 </target>
Mahmood Ali932021b2009-10-03 02:05:56 -040048
Michael Ernst762a40e2017-05-06 10:39:19 -070049 <target name="compile-scene-lib">
50 <ant dir="${scene-lib}" target="bin"/>
51 </target>
Michael Ernst9f959042015-07-23 20:25:46 -050052
Michael Ernst762a40e2017-05-06 10:39:19 -070053 <target name="javadoc-scene-lib">
54 <ant dir="${scene-lib}" target="javadoc"/>
55 </target>
Mahmood Ali932021b2009-10-03 02:05:56 -040056
Michael Ernst762a40e2017-05-06 10:39:19 -070057 <target name="test-scene-lib">
58 <ant dir="${scene-lib}" target="test"/>
59 </target>
Mahmood Ali932021b2009-10-03 02:05:56 -040060
Michael Ernst762a40e2017-05-06 10:39:19 -070061 <target name="compile-afu">
62 <ant dir="${afu}" target="jarfile"/>
63 </target>
Javier Thainef6f27782014-09-29 17:03:43 -070064
Michael Ernst762a40e2017-05-06 10:39:19 -070065 <target name="javadoc-afu">
66 <ant dir="${afu}" target="javadoc"/>
67 </target>
Mahmood Ali932021b2009-10-03 02:05:56 -040068
Michael Ernst762a40e2017-05-06 10:39:19 -070069 <target name="test-afu">
70 <ant dir="${afu}" target="run-tests"/>
71 </target>
Mahmood Ali932021b2009-10-03 02:05:56 -040072
Michael Ernst762a40e2017-05-06 10:39:19 -070073 <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>
Michael Ernst9f959042015-07-23 20:25:46 -050083
Michael Ernst762a40e2017-05-06 10:39:19 -070084 <target name="javadoc" depends="javadoc-scene-lib,javadoc-afu">
85 </target>
Michael Ernstf7eed842015-08-28 06:27:10 -070086
Michael Ernst762a40e2017-05-06 10:39:19 -070087 <target name="tags-scene-lib">
88 <ant dir="${scene-lib}" target="tags"/>
89 </target>
Michael Ernstf7eed842015-08-28 06:27:10 -070090
Michael Ernst762a40e2017-05-06 10:39:19 -070091 <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>
Michael Ernst9f959042015-07-23 20:25:46 -0500103
Michael Ernst460c9fb2016-04-02 16:36:38 -0700104 <target name="html-validate"
Michael Ernst762a40e2017-05-06 10:39:19 -0700105 description="Validate that HTML files are well-formed; only works with JDK 8"
106 depends="prep">
Michael Ernst460c9fb2016-04-02 16:36:38 -0700107 <exec executable="html5validator">
108 <arg value="--ignore"/>
109 <arg value="/api/"/>
110 <arg value="/build/"/>
Michael Ernstb4a53332016-04-02 16:46:54 -0700111 <arg value="/javadoc/"/>
112 <arg value="/annotation-file-utilities/annotation-file-format.html"/>
113 <arg value="/scene-lib/javadoc/"/>
Michael Ernst460c9fb2016-04-02 16:36:38 -0700114 </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"
Michael Ernst762a40e2017-05-06 10:39:19 -0700121 description="Check basic style guidelines"
122 depends="prep">
Michael Ernst460c9fb2016-04-02 16:36:38 -0700123 <!-- 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
Michael Ernst762a40e2017-05-06 10:39:19 -0700151 <fileset id="formatted.java.files" dir="." includes="**/*.java" excludes="**/asmx/"/>
152
Michael Ernst133928f2017-06-14 18:05:29 -0700153 <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
Michael Ernst762a40e2017-05-06 10:39:19 -0700163 <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
Michael Ernst133928f2017-06-14 18:05:29 -0700192<!-- TEMPORARY: Do not run this until branches have been merged. -->
Michael Ernst762a40e2017-05-06 10:39:19 -0700193 <target name="reformat" depends="-update-run-google-java-format"
194 description="Reformat Java code">
Michael Ernst133928f2017-06-14 18:05:29 -0700195 <apply executable="python" parallel="true" maxparallel="${maxparallel}" failonerror="true">
Michael Ernst762a40e2017-05-06 10:39:19 -0700196 <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">
Michael Ernst133928f2017-06-14 18:05:29 -0700203 <apply executable="python" parallel="true" maxparallel="${maxparallel}"
204 failonerror="false" resultproperty="check.format.result"
205 outputproperty="check.format.stdout" errorproperty="check.format.stderr">
Michael Ernst762a40e2017-05-06 10:39:19 -0700206 <arg value="./.run-google-java-format/check-google-java-format.py"/>
207 <fileset refid="formatted.java.files"/>
208 </apply>
Michael Ernst133928f2017-06-14 18:05:29 -0700209 <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>
Michael Ernst762a40e2017-05-06 10:39:19 -0700220 </target>
221
Mahmood Ali932021b2009-10-03 02:05:56 -0400222</project>