-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.xml
376 lines (339 loc) · 14.1 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
373
374
375
376
<project name="SigmaNLP" default="all" basedir=".">
<description>
This build file is meant to be invoked only from the command line. It's
purpose is for building/testing in a CI/CD environment
</description>
<!--
====
INIT
====
-->
<property name="impl.title" value="${ant.project.name}"/>
<property name="product.Name" value="Sigma Natural Language Processor (${impl.title})"/>
<property name="product.version.major" value="1"/>
<property name="product.version.minor" value="0"/>
<property name="product.version.patch" value="0"/>
<property name="product.Version" value="${product.version.major}.${product.version.minor}.${product.version.patch}"/>
<property name="spec.vendor" value="Adam Pease"/>
<property name="nps" value="Naval Postgraduate School (NPS), Monterey, CA"/>
<property name="cs.dept" value="Computer Science (CS) DEPT"/>
<property name="sumo.url" value="http://www.ontologyportal.org"/>
<property name="manifest.mf" value="MANIFEST.MF"/>
<property name="main.class" value="com.articulate.nlp.semRewrite.Interpreter"/>
<property name="impl.vendor.id" value="edu.nps.cs"/>
<property name="app.name" value="sigmanlp"/>
<property name="build.home" value="build"/>
<property name="build.classes.dir" value="${build.home}/classes"/>
<property name="build.lib" value="${build.home}/lib"/>
<property name="build.test.classes.dir" value="${build.home}/test/classes"/>
<property name="dist.dir" value="dist"/>
<property name="dist.jar" value="${dist.dir}/${app.name}.jar"/>
<property name="dist.javadoc.dir" value="doc"/>
<property name="web.dir" value="web"/>
<property name="reports.dir" value="${build.home}/test/results"/>
<property name="unit.test.suite" value="com.articulate.nlp.UnitTestSuite"/>
<property name="integration.test.suite" value="com.articulate.nlp.IntegrationTestSuite"/>
<property name="report.html" value="file:${basedir}/${reports.dir}/html/index.html"/>
<property environment="env"/>
<property name="tomcat.home" value="${env.CATALINA_HOME}"/>
<property name="dist.home" value="${tomcat.home}/webapps"/>
<property name="dist.war" value="${dist.home}/${app.name}.war"/>
<property name="deploy.home" value="${dist.home}/${app.name}"/>
<property name="sigmakee.home" value="${env.SIGMA_SRC}" />
<property name="deploy.classes" value="${build.home}/WEB-INF/classes"/>
<property name="deploy.lib" value="${build.home}/WEB-INF/lib"/>
<property name="compiler.debug" value="on"/>
<property name="javac.release" value="11"/>
<property name="run.jvmargs" value="-Xmx10g -Xss1m"/>
<condition property="isUnixNotMac">
<and>
<os family="unix"/>
<not>
<os family="mac"/>
</not>
</and>
</condition>
<path id="compile.classpath">
<fileset dir="${basedir}/lib">
<include name="*.jar"/>
<exclude name="junit*.jar"/>
<exclude name="hamcrest*.jar"/>
</fileset>
<fileset dir="${sigmakee.home}/lib">
<include name="*.jar"/>
<exclude name="junit*.jar"/>
<exclude name="hamcrest*.jar"/>
</fileset>
</path>
<path id="compile.test.classpath">
<path refid="compile.classpath"/>
<pathelement location="${build.classes.dir}"/>
<pathelement location="${build.test.classes.dir}"/>
<pathelement path="${basedir}/lib/hamcrest-core-1.3.jar:${basedir}/lib/junit-4.13.2.jar"/>
</path>
<path id="run.classpath">
<pathelement location="${build.classes.dir}"/>
<fileset dir="${build.lib}">
<include name="*.jar"/>
</fileset>
</path>
<path id="run.test.classpath">
<path refid="compile.test.classpath"/>
<pathelement location="${build.test.classes.dir}"/>
</path>
<path id="sourcepath">
<dirset dir="${basedir}">
<include name="src/main/java"/>
</dirset>
</path>
<path id="test.sourcepath">
<dirset dir="${basedir}">
<include name="src/test"/>
</dirset>
</path>
<target name="init">
<condition property="jdk21+">
<javaversion atleast="21"/>
</condition>
<fail message="Unsupported JDK version: ${ant.java.version}. Please use JDK version 21 or greater."
unless="jdk21+">
</fail>
<echo message="Welcome to the ${product.Name} v${product.Version}"/>
<echo message="Specification Vendor: ${spec.vendor}"/>
<echo message=""/>
<echo message="CATALINA_HOME is set to: ${tomcat.home}"/>
<echo message="SIGMA_HOME is set to: ${env.SIGMA_HOME}"/>
<echo message="sigmakee is set to: ${env.SIGMA_SRC}"/>
<ant antfile="../sigmakee/build.xml" inheritAll="false" target="all" />
<copy todir="${basedir}/lib" file="${sigmakee.home}/build/sigmakee.jar" />
<copy todir="${basedir}/lib" file="../SigmaUtils/sigmaUtils.jar" />
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${build.lib}"/>
<tstamp>
<format property="TODAY_US" pattern="EEE, d MMM yyyy HHmm Z" locale="en,US"/>
</tstamp>
</target>
<target name="deploy.prepare" depends="init" description="deploy code to sigma.war">
<!-- Copy all the *.jsp, *.xsl, *.html, pixmaps, etc. -->
<copy todir="${build.home}/jsp">
<fileset dir="${web.dir}/jsp"/>
</copy>
<copy todir="${build.home}/brat">
<fileset dir="${web.dir}/brat">
<exclude name="static/example-READMEs/**"/>
</fileset>
</copy>
<copy todir="${build.home}/js">
<fileset dir="${web.dir}/js"/>
</copy>
<copy todir="${build.home}/pixmaps">
<fileset dir="${web.dir}/pixmaps"/>
</copy>
<copy todir="${build.home}/WEB-INF">
<fileset file="${web.dir}/web.xml"/>
</copy>
</target>
<!--
============
BUILD / DIST
============
-->
<target name="compile" depends="deploy.prepare" description="Compile sigmanlp">
<javac destdir="${build.classes.dir}"
debug="on"
optimize="on"
deprecation="on"
classpathref="compile.classpath"
release="${javac.release}"
includeantruntime="false"
fork="true">
<src refid="sourcepath"/>
</javac>
<copy todir="${build.lib}">
<path refid="compile.classpath"/>
</copy>
<mkdir dir="${deploy.lib}"/>
<copy todir="${deploy.lib}">
<fileset file="${build.lib}/*.jar" />
</copy>
<!-- Create WEB-INF/classes/ and copy all the loose classes to it. -->
<mkdir dir="${deploy.classes}"/>
<copy todir="${deploy.classes}">
<fileset dir="${build.classes.dir}"/>
</copy>
</target>
<target name="compile.test" depends="compile" description="Compile the project's test classes.">
<mkdir dir="${build.test.classes.dir}"/>
<javac destdir="${build.test.classes.dir}"
debug="on"
optimize="on"
deprecation="on"
includeantruntime="false"
classpathref="compile.test.classpath"
release="${javac.release}">
<src refid="test.sourcepath"/>
</javac>
<mkdir dir="${build.test.classes.dir}/resources"/>
<copy todir="${build.test.classes.dir}/resources">
<fileset dir="src/test/integration/java/resources">
<include name="interpreter_wsd_batch.json"/>
</fileset>
</copy>
<mkdir dir="${reports.dir}"/>
</target>
<target name="dist" depends="compile" description="Create the *.war file and place in ${build.home}.">
<manifest file="${manifest.mf}">
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Specification-Title"
value="${product.Name}"/>
<attribute name="Specification-Version"
value="${product.version.major}.${product.version.minor}"/>
<attribute name="Specification-Vendor"
value="${spec.vendor}"/>
<attribute name="Implementation-Title"
value="${impl.title}"/>
<attribute name="Implementation-Version"
value="${product.Version} built on ${TODAY_US}"/>
<attribute name="Implementation-Vendor"
value="${nps}, ${cs.dept}"/>
<attribute name="Implementation-URL"
value="${sumo.url}"/>
<attribute name="Implementation-Vendor-Id"
value="${impl.vendor.id}"/>
<attribute name="Main-Class"
value="${main.class}"/>
</manifest>
<war destfile="${dist.war}"
webxml="${web.dir}/web.xml"
manifest="${manifest.mf}">
<metainf file="LICENSE"/>
<zipfileset dir="${build.home}/jsp"/>
<zipfileset dir="${build.home}/brat"/>
<zipfileset dir="${build.home}/js"/>
<zipfileset dir="${build.home}/pixmaps" prefix="pixmaps"/>
<lib dir="${build.lib}">
<exclude name="junit*"/>
<exclude name="hamcrest*"/>
<exclude name="tomcat-servlet-api*"/>
</lib>
<classes dir="${build.classes.dir}"/>
</war>
<jar destfile="${build.home}/${app.name}.jar"
manifest="${manifest.mf}">
<metainf file="LICENSE"/>
<fileset dir="${build.classes.dir}"/>
</jar>
</target>
<!--
=====
ADMIN
=====
-->
<target name="update.sigmanlp">
<git command="pull" dir="${user.dir}">
<args>
<arg value="--progress"/>
<arg value="--verbose"/>
</args>
</git>
</target>
<!-- git macro utils setup from: https://tonyyan.wordpress.com/2017/03/10/integrate-git-into-ant-targets/-->
<macrodef name="git">
<attribute name="command"/>
<attribute name="dir" default="${workspace.dir}"/>
<element name="args" optional="true"/>
<sequential>
<echo message="git @{command}"/>
<exec executable="git" dir="@{dir}">
<arg value="@{command}"/>
<args/>
</exec>
</sequential>
</macrodef>
<!-- Works only from the CLI -->
<target name="clean" description="Delete old build, lib, dist and deployed web aritifacts">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${build.home}"/> <!-- avoid problems with package name changes by deleting everything -->
<fileset dir="${dist.dir}"/>
<!-- Delete the old web code -->
<fileset dir="${deploy.home}"/>
<fileset dir="${tomcat.home}/work/Catalina/localhost/${app.name}"/>
</delete>
<delete file="${dist.war}"/>
</target>
<target name="all" depends="clean,dist" description="build all">
<echo>System date/time is ${TODAY_US}</echo>
</target>
<target name="api_doc" depends="init" description="Build the JavaDocs and place in ${dist.javadoc.dir}.">
<javadoc sourcepath="src/java" destdir="${dist.javadoc.dir}" author="true" version="true" use="true"
windowtitle="Sigma API Specification" splitindex="true" packagenames="com.articulate.nlp.*">
<classpath refed="compile.classpath"/>
<doctitle>SigmaNLP API Specification</doctitle>
<header><![CDATA[<b>SigmaNLP API Specification</b>]]></header>
<group title="Sigma" packages="com.articulate.nlp.*"/>
</javadoc>
</target>
<!--
==========
UNIT TESTS <- These are only meant to be run within the CI environment
==========
-->
<target name="test.unit" depends="compile.test" description="Runs the UnitTestSuite">
<junit printsummary="yes"
showoutput="yes"
fork="yes">
<jvmarg line="${run.jvmargs}"/>
<formatter type="plain" usefile="false"/>
<classpath>
<path refid="run.test.classpath"/>
</classpath>
<test name="${unit.test.suite}" haltonfailure="no" todir="${reports.dir}">
<formatter type="xml"/>
</test>
</junit>
<antcall target="junit.report"/>
</target>
<target name="test.integration" depends="compile.test" description="Runs the IntegrationTestSuite">
<junit printsummary="yes"
showoutput="yes"
fork="yes">
<jvmarg line="${run.jvmargs}"/>
<formatter type="plain" usefile="false"/>
<classpath>
<path refid="run.test.classpath"/>
</classpath>
<test name="${integration.test.suite}" haltonfailure="no" todir="${reports.dir}">
<formatter type="xml"/>
</test>
</junit>
<antcall target="junit.report"/>
<!-- Prune KB after integration tests -->
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${sigma.home}/KBs">
<include name="*.tptp"/>
<include name="*.ser"/>
</fileset>
</delete>
</target>
<target name="junit.report" >
<junitreport todir="${reports.dir}">
<fileset dir="${reports.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${reports.dir}/html"/>
</junitreport>
<antcall target="open.junit.report"/>
</target>
<target name="open.junit.report" depends="report.mac,report.unix"/>
<target name="report.mac">
<exec executable="sh" osfamily="mac">
<arg value="-c"/>
<arg value="open -u ${report.html}"/>
</exec>
</target>
<target name="report.unix" if="isUnixNotMac">
<exec executable="sh" osfamily="unix">
<arg value="xdg-open ${report.html}"/>
</exec>
</target>
</project>