forked from ohmage/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
372 lines (342 loc) · 15.5 KB
/
build.xml
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<?xml version="1.0"?>
<project name="webapp-ohmage" basedir="." default="dist-all">
<property file="build.properties"/>
<property name="library" location="lib"/>
<property name="app_name" value="ohmage"/>
<property name="app_version" value="2.18.1"/>
<property name="src" location="src"/>
<property name="test" location="test"/>
<property name="view" location="view"/>
<property name="resources" location="web"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="condition" location="condition"/>
<fileset id="compile-dependencies" dir="${library}">
<include name="log4j-1.2.16.jar"/>
<include name="servlet-api-3.0.jar"/>
<include name="org.springframework.beans-3.1.1.RELEASE.jar" />
<include name="org.springframework.context-3.1.1.RELEASE.jar" />
<include name="org.springframework.core-3.1.1.RELEASE.jar" />
<include name="org.springframework.jdbc-3.1.1.RELEASE.jar" />
<include name="org.springframework.transaction-3.1.1.RELEASE.jar" />
<include name="org.springframework.web-3.1.1.RELEASE.jar" />
<include name="commons-logging-1.1.1.jar"/>
<include name="commons-io-1.3.2.jar"/>
<include name="commons-fileupload-1.2.2.jar"/>
<include name="commons-pool-1.5.4.jar"/>
<include name="cors-filter-1.3.1-ohmage.jar"/>
<include name="json.org-2013-05-22.jar"/>
<include name="jbcrypt-0.3.jar"/>
<include name="xom-1.2.6.jar"/>
<include name="mobility-classifier-1.3.7.jar"/>
<include name="httpcore-4.1.2.jar"/>
<include name="httpclient-4.1.2.jar"/>
<include name="httpmime-4.1.2.jar"/>
<include name="junit-4.10.jar"/>
<include name="recaptcha4j-0.0.7.jar"/>
<include name="mail.jar"/>
<include name="joda-time-2.1.jar"/>
<include name="jackson-all-1.9.7.jar"/>
<include name="js.jar"/>
<include name="catalina-2012-09-10.jar"/>
<include name="RunKeeperOmhLayer.jar"/>
<include name="jose4j-0.4.4.jar"/>
</fileset>
<fileset id="run-dependencies" dir="${library}">
<include name="log4j-1.2.16.jar"/>
<include name="org.springframework.asm-3.1.1.RELEASE.jar" />
<include name="org.springframework.beans-3.1.1.RELEASE.jar" />
<include name="org.springframework.context-3.1.1.RELEASE.jar" />
<include name="org.springframework.core-3.1.1.RELEASE.jar" />
<include name="org.springframework.expression-3.1.1.RELEASE.jar" />
<include name="org.springframework.jdbc-3.1.1.RELEASE.jar" />
<include name="org.springframework.transaction-3.1.1.RELEASE.jar" />
<include name="org.springframework.web-3.1.1.RELEASE.jar" />
<include name="mysql-connector-java-5.1.25-bin.jar"/>
<include name="commons-logging-1.1.1.jar"/>
<include name="commons-io-1.3.2.jar"/>
<include name="commons-fileupload-1.2.2.jar"/>
<include name="commons-pool-1.5.4.jar"/>
<include name="cors-filter-1.3.1-ohmage.jar"/>
<include name="json.org-2013-05-22.jar"/>
<include name="jbcrypt-0.3.jar"/>
<include name="xom-1.2.6.jar"/>
<include name="mobility-classifier-1.3.7.jar"/>
<include name="httpcore-4.1.2.jar"/>
<include name="httpclient-4.1.2.jar"/>
<include name="httpmime-4.1.2.jar"/>
<include name="recaptcha4j-0.0.7.jar"/>
<include name="mail.jar"/>
<include name="joda-time-2.1.jar"/>
<include name="jackson-all-1.9.7.jar"/>
<include name="js.jar"/>
<include name="RunKeeperOmhLayer.jar"/>
<include name="slf4j-api-1.7.5.jar"/>
<include name="slf4j-log4j12-1.7.5.jar"/>
<include name="tomcat-dbcp-7.0.42.jar" />
<include name="tomcat-jdbc-7.0.42.jar" />
<include name="tomcat-juli.jar" />
<include name="jose4j-0.4.4.jar"/>
</fileset>
<path id="compile-classpath">
<fileset refid="compile-dependencies"/>
</path>
<path id="run-classpath">
<fileset refid="run-dependencies"/>
</path>
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath path="${library}/sonar-ant-task-1.1.jar" />
</taskdef>
<target name="clean" description="Removes output directories (e.g. build and dist).">
<delete dir="${build}"/>
<delete dir="${dist}"/>
<delete dir="condition/gen"/>
<delete file="web/WEB-INF/properties/system.properties"/>
</target>
<target name="javac" description="Compiles Java files.">
<mkdir dir="${build}/classes"/>
<javac destdir="${build}/classes" source="1.7" target="1.7"
debug="true" deprecation="true" optimize="true" failonerror="true"
encoding="UTF-8">
<compilerarg value="-Xlint:unchecked"/>
<src path="${src}"/>
<src path="${test}"/>
<exclude name="org/ohmage/test"/>
<classpath refid="compile-classpath"/>
</javac>
</target>
<target name="javac-validator" description="Compiles Java files to create the campaign validator.">
<mkdir dir="${build}/classes"/>
<javac destdir="${build}/classes" source="1.7" target="1.7"
debug="true" deprecation="true" optimize="true" failonerror="true"
encoding="UTF-8">
<compilerarg value="-Xlint:unchecked"/>
<src path="${src}"/>
<include name="org/ohmage/config/**" />
<include name="org/ohmage/util/StringUtils.java" />
<classpath refid="compile-classpath"/>
</javac>
</target>
<target name="javac-library" description="Compiles Java files to create the ohmage library.">
<mkdir dir="${build}/classes"/>
<javac destdir="${build}/classes" source="1.7" target="1.7"
debug="true" deprecation="true" optimize="true" failonerror="true"
encoding="UTF-8" includeantruntime="false">
<compilerarg value="-Xlint:unchecked"/>
<src path="${src}"/>
<include name="org/ohmage/domain/**" />
<include name="org/ohmage/lib/**" />
<include name="org/ohmage/util/**" />
<include name="org/ohmage/exception/WorkflowException.java" />
<include name="org/ohmage/exception/DomainException.java" />
<exclude name="org/ohmage/domain/Audit.java" />
<classpath refid="compile-classpath"/>
</javac>
</target>
<target name="javadoc" description="Compiles Javadocs.">
<mkdir dir="${build}/docs"/>
<javadoc destdir="${build}/docs" private="true" link="http://java.sun.com/javase/6/docs/api/"
encoding="UTF-8" additionalparam="-quiet">
<fileset dir="${src}">
<include name="**/*.java"/>
</fileset>
<classpath refid="compile-classpath"/>
</javadoc>
</target>
<target name="javadoc-library" description="Compiles Javadocs for the library only.">
<mkdir dir="${build}/docs"/>
<javadoc destdir="${build}/docs" private="true" link="http://java.sun.com/javase/6/docs/api/"
encoding="UTF-8" additionalparam="-quiet">
<fileset dir="${src}">
<include name="org/ohmage/domain/**" />
<include name="org/ohmage/lib/**" />
<include name="org/ohmage/util/**" />
<include name="org/ohmage/annotator/**" />
<include name="org/ohmage/exception/WorkflowException.java" />
<include name="org/ohmage/exception/DomainException.java" />
<exclude name="org/ohmage/domain/Audit.java" />
</fileset>
<classpath refid="compile-classpath"/>
</javadoc>
</target>
<path id="classpath.test">
<fileset refid="compile-dependencies"/>
<pathelement location="${build}/classes"/>
</path>
<target name="test" depends="javac" description="Executes the JUnit tests.">
<junit printsummary="yes" haltonfailure="yes">
<classpath refid="classpath.test"/>
<formatter type="plain" usefile="false" />
<test name="org.ohmage.validator.ValidatorTests"/>
</junit>
</target>
<target
name="condition-grammar"
description="Recompiles the condition grammar.">
<!-- Make the directory to house the files as generate them. -->
<property name="gen" location="${condition}/gen" />
<mkdir dir="${gen}" />
<!-- Annotate the condition grammar. -->
<java fork="true" jar="${library}/jtb132.jar" failonerror="true">
<arg value="-p" />
<arg value="org.ohmage.config.grammar" />
<arg value="-o" />
<arg value="${gen}/condition-grammar.jtb" />
<arg value="${condition}/condition-grammar.jj" />
</java>
<!-- Compile the annotated grammar into Java source code. -->
<java
classpath="${library}/javacc-5.0.jar" classname="javacc"
failonerror="true">
<arg value="-LOOKAHEAD=2" />
<arg value="-OUTPUT_DIRECTORY=${gen}" />
<arg value="${gen}/condition-grammar.jtb" />
</java>
<!-- Move the generated files into the 'gen' folder to keep them out of the
way but persist them in case they need to be reviewed. -->
<move file="syntaxtree" todir="${gen}" />
<move file="visitor" todir="${gen}" />
<!-- Tell the user what they must do now. -->
<property name="grammar" location="${src}/org/ohmage/config/grammar" />
<property name="parser" location="${grammar}/parser" />
<property name="syntaxtree" location="${grammar}/syntaxtree" />
<property name="visitor" location="${grammar}/grammar" />
<echo>
TODO:
The Java source files have been generated and placed in condition/gen. To have
them build with the rest of the project, you must move the following objects to
the following places:
- ${gen}/*.java -> ${parser}
- ${gen}/syntaxtree/* -> ${syntaxtree}
- ${gen}/visitor/* -> ${visitor}
The reason this wasn't done automatically is because it would overwrite any
non-generated, custom code. While we highly discourage editing generated code,
we want to be safe just in case.
That said, JavaCC creates very ugly code. It is common for us to edit the code
by opening it in Eclipse and using Eclipse's aut-correct functionality to clean
it up and remove the warnings.</echo>
</target>
<!-- dist-ssl compilation process is deprecated. please use SSL via a reverse proxy -->
<target name="dist-ssl" depends="test, javac" description="Compiles Java files and creates WAR.">
<mkdir dir="${dist}"/>
<exec executable="git" outputproperty="git.revision" failifexecutionfails="true">
<arg value="log"/>
<arg value="--pretty=format:%h"/>
<arg value="-1"/>
</exec>
<propertyfile file="system.properties" comment="This file is automatically generated - DO NOT EDIT!">
<entry key="application.name" default="${app_name}"/>
<entry key="application.version" default="${app_version}"/>
<entry key="application.build" default="${git.revision}"/>
</propertyfile>
<move file="system.properties" todir="web/WEB-INF/properties"/>
<war webxml="${resources}/WEB-INF/web-ssl.xml" destfile="${dist}/${ant.project.name}-${app_version}-ssl.war">
<classes dir="${build}/classes"/>
<exclude name="**/*Test.java"/>
<lib refid="run-dependencies"/>
<webinf dir="${resources}/WEB-INF">
<exclude name="web-no_ssl.xml"/>
<exclude name="web-ssl.xml"/>
</webinf>
<metainf dir="${resources}/META-INF">
<exclude name="MANIFEST.MF"/>
</metainf>
<zipfileset dir="${resources}">
<exclude name="META-INF/**"/>
<exclude name="WEB-INF/**"/>
</zipfileset>
</war>
</target>
<target name="dist-no_ssl" depends="test, javac" description="Compiles Java files and creates WAR.">
<mkdir dir="${dist}"/>
<exec executable="git" outputproperty="git.revision" failifexecutionfails="true">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<propertyfile file="system.properties" comment="This file is automatically generated - DO NOT EDIT!">
<entry key="application.name" default="${app_name}"/>
<entry key="application.version" default="${app_version}"/>
<entry key="application.build" default="${git.revision}"/>
</propertyfile>
<move file="system.properties" todir="web/WEB-INF/properties"/>
<war webxml="${resources}/WEB-INF/web-no_ssl.xml" destfile="${dist}/${ant.project.name}-${app_version}-no_ssl.war">
<classes dir="${build}/classes"/>
<exclude name="**/*Test.java"/>
<lib refid="run-dependencies"/>
<webinf dir="${resources}/WEB-INF">
<exclude name="web-no_ssl.xml"/>
<exclude name="web-ssl.xml"/>
</webinf>
<metainf dir="${resources}/META-INF">
<exclude name="MANIFEST.MF"/>
</metainf>
<zipfileset dir="${resources}">
<exclude name="META-INF/**"/>
<exclude name="WEB-INF/**"/>
</zipfileset>
</war>
</target>
<target
name="dist"
depends="dist-no_ssl"
description="The 'default' 'dist' target builds the WAR without SSL enabled."/>
<target name="dist-validator" depends="javac-validator"
description="Compiles Java files and creates an executable jar file with the dependencies embedded.">
<mkdir dir="${dist}"/>
<jar destfile="${dist}/${app_name}-${app_version}-validator.jar">
<fileset dir="${build}/classes">
<include name="org/ohmage/config/**" />
<include name="org/ohmage/util/StringUtils.class" />
</fileset>
<zipfileset src="${library}/json.org-2013-05-22.jar" excludes="META-INF/*" />
<zipfileset src="${library}/log4j-1.2.16.jar" excludes="META-INF/*" />
<zipfileset src="${library}/xom-1.2.6.jar" excludes="META-INF/*" />
<zipfileset src="${library}/xercesImpl-2.11.0.jar" excludes="META-INF/*" />
<manifest>
<attribute name="Main-Class" value="org.ohmage.config.xml.CampaignValidator" />
</manifest>
</jar>
</target>
<target name="dist-library" depends="javac-library, javadoc-library"
description="Compiles java files to create the library JAR.">
<mkdir dir="${dist}"/>
<jar destfile="${dist}/ohmage-${app_version}-api.jar">
<fileset dir="${build}/classes">
<include name="org/ohmage/domain/**" />
<include name="org/ohmage/lib/**" />
<include name="org/ohmage/util/**" />
<include name="org/ohmage/exception/WorkflowException.java" />
<include name="org/ohmage/exception/DomainException.java" />
<exclude name="org/ohmage/domain/Audit.java" />
</fileset>
<fileset dir="${build}">
<include name="docs/**" />
</fileset>
<zipfileset src="${library}/xom-1.2.6.jar" excludes="META-INF/*" />
<zipfileset src="${library}/json.org-2013-05-22.jar" excludes="META-INF/*" />
<zipfileset src="${library}/httpcore-4.1.2.jar" excludes="META-INF/*" />
<zipfileset src="${library}/httpclient-4.1.2.jar" excludes="META-INF/*" />
<zipfileset src="${library}/httpmime-4.1.2.jar" excludes="META-INF/*" />
<zipfileset src="${library}/commons-logging-1.1.1.jar" excludes="META-INF/*" />
</jar>
</target>
<target name="dist-docs" depends="javadoc" description="Compiles Javadocs and creates gzipped tarball.">
<mkdir dir="${dist}"/>
<tar basedir="${build}/docs" destfile="${dist}/${ant.project.name}-docs-${app_version}.tar.gz" longfile="gnu" compression="gzip"/>
<zip basedir="${build}/docs" destfile="${dist}/${ant.project.name}-docs-${app_version}.zip" encoding="UTF-8" compress="true"/>
</target>
<target
name="dist-all"
depends="clean,dist-ssl,dist-no_ssl,dist-docs"
description="Creates full distribution (WAR and docs)."/>
<target name="sonar">
<sonar:sonar workDir="${user.home}/tmp" key="org.ohmage:example" version="${app_version}" xmlns:sonar="antlib:org.sonar.ant">
<sources>
<path location="${src}" />
</sources>
<property key="sonar.java.source" value="1.7" />
<property key="sonar.java.target" value="1.7" />
</sonar:sonar>
</target>
</project>