-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.xml
340 lines (283 loc) · 12.8 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
<?xml version="1.0"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="JettyDesktop" default="jar">
<property file="build.properties" />
<property file="build.dev.properties" />
<property name="root" location="."/>
<!-- Src directories -->
<property name="src" location="src"/>
<!-- Build directories -->
<property name="build" location="./bin"/>
<property name="app" value="_app"/>
<property name="data" value="data"/>
<!-- Output directories -->
<property name="rootdist" location="dist"/>
<property name="dist" location="dist/VoyantServer${major}_${minor}_${patch}"/>
<property name="jarpath" location="lib"/>
<!-- Ivy-related settings -->
<property name="ivy.install.version" value="2.5.0" />
<property name="ivy.home" value="${root}/.ant" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<condition property="isWindows">
<os family="windows" />
</condition>
<condition property="isUnix">
<os family="unix" />
</condition>
<path id="project.jars">
<fileset dir="${jarpath}" includes="*.jar" />
</path>
<path id="project.class.path">
<pathelement location="${build}"/>
</path>
<target name="init">
<mkdir dir="${build}"/>
<mkdir dir="${root}/${app}"/>
<mkdir dir="${jarpath}"/>
</target>
<target name="clean">
<delete dir="${rootdist}"/>
<delete dir="${build}"/>
<delete dir="${jarpath}"/>
</target>
<target name="clean-all" depends="clean" description="clean ivy cache">
<ivy:cleancache />
</target>
<target name="compile" depends="init,get-dependencies">
<javac srcdir="${src}" destdir="${build}" source="1.8" target="1.8" includeantruntime="false" debug="on" >
<classpath>
<path refid="project.class.path"/>
<path refid="project.jars"/>
</classpath>
</javac>
<copy file="${src}/org/aw20/logo/aw20.jpg" todir="${build}/org/aw20/logo/"/>
<copy file="${src}/org/voyanttools/resources/voyant_small.png" todir="${build}/org/voyanttools/resources/"/>
<copy file="${src}/org/aw20/jettydesktop/rte/webdefault.xml" todir="${build}/org/aw20/jettydesktop/rte"/>
<jar jarfile="${dist}/VoyantServer.jar" filesonly="true" compress="true">
<fileset dir="${build}" />
<zipgroupfileset dir="${jarpath}" includes="*.jar" />
<manifest>
<attribute name="Main-Class" value="org.voyanttools.server.ui.VoyantServerStart"/>
</manifest>
</jar>
</target>
<target name="populate-dist" depends="build-voyant,copy-voyant-dependencies">
<!-- copy voyant/trombone libs -->
<mkdir dir="${dist}/${app}/WEB-INF/lib"/>
<copy todir="${dist}/${app}/WEB-INF/lib">
<fileset dir="${jarpath}/Voyant/target/dependency"/>
</copy>
<!-- copy Voyant app -->
<copy todir="${dist}/${app}">
<fileset dir="${jarpath}/Voyant/src/main/webapp">
<exclude name="**/node_modules/**"/>
<exclude name="**/resources/docs/**"/>
</fileset>
</copy>
<mkdir dir="${dist}/${data}/trombone5_2"/>
<unzip src="data.zip" dest="${dist}/${data}/trombone5_2"/>
<copy file="./server-settings.txt" todir="${dist}/"/>
<copy file="./license-GPL3.txt" todir="${dist}/"/>
<copy file="./README.md" todir="${dist}/"/>
</target>
<!-- Create a jar to run a local version of Voyant -->
<target name="jar" depends="clean,compile,populate-dist,copy-tool-limits-config,copy-spyral-oauth-properties,copy-nssi-config,set-voyant-version,set-entities-enabled-false">
<!-- delete the nlp models file -->
<delete>
<fileset dir="${rootdist}">
<include name="**/stanford*models.jar"/>
</fileset>
</delete>
<zip destfile="${rootdist}/VoyantServer.zip"
compress="true">
<fileset dir="${rootdist}" />
</zip>
</target>
<!-- Create a jar to run a local version of Voyant, including nlp -->
<target name="jar-nlp" depends="clean,compile,populate-dist,copy-tool-limits-config,copy-spyral-oauth-properties,copy-nssi-config,set-voyant-version,set-entities-enabled-true">
<zip destfile="${rootdist}/VoyantServerWithModels.zip"
compress="true">
<fileset dir="${rootdist}" />
</zip>
</target>
<!-- specialized for uploading to main server, only difference between this and "jar" is that entities are enabled -->
<target name="main-server" depends="clean,compile,populate-dist,copy-tool-limits-config,copy-spyral-oauth-properties,copy-nssi-config,set-voyant-version,set-entities-enabled-true">
<!-- delete the nlp models file, they are already on the server -->
<delete>
<fileset dir="${rootdist}">
<include name="**/stanford*models.jar"/>
</fileset>
</delete>
<zip destfile="${rootdist}/VoyantServer.zip"
compress="true">
<fileset dir="${rootdist}" />
</zip>
</target>
<!--
Voyant related tasks
-->
<target name="download-voyant" depends="init">
<exec executable="git" dir="${jarpath}" failifexecutionfails="true" >
<arg line="clone https://github.com/voyanttools/Voyant.git"/>
</exec>
</target>
<!-- run the voyant maven build -->
<target name="build-voyant" depends="download-voyant,build-voyant-win,build-voyant-unix" />
<target name="build-voyant-win" if="isWindows">
<exec dir="${jarpath}/Voyant" executable="cmd">
<arg line="/c mvn clean compile" />
</exec>
</target>
<target name="build-voyant-unix" if="isUnix">
<exec dir="${jarpath}/Voyant" executable="sh">
<arg line="-c 'mvn clean compile'" />
</exec>
</target>
<target name="set-voyant-version">
<xslt style="set-version.xsl" in="${dist}/${app}/WEB-INF/web.xml" out="${dist}/${app}/WEB-INF/web-version.xml">
<param name="version" expression="${major}.${minor}.${patch}"/>
</xslt>
<delete file="${dist}/${app}/WEB-INF/web.xml"/>
<move file="${dist}/${app}/WEB-INF/web-version.xml" tofile="${dist}/${app}/WEB-INF/web.xml"/>
</target>
<target name="set-voyant-version-dev">
<tstamp>
<format property="timestamp" pattern="yyyy/MM/dd"/>
</tstamp>
<xslt style="set-version.xsl" in="${dev_build_location}/${app}/WEB-INF/web.xml" out="${dev_build_location}/${app}/WEB-INF/web-version.xml">
<param name="version" expression="${major}.${minor}.${patch} [${timestamp}]"/>
</xslt>
<delete file="${dev_build_location}/${app}/WEB-INF/web.xml"/>
<move file="${dev_build_location}/${app}/WEB-INF/web-version.xml" tofile="${dev_build_location}/${app}/WEB-INF/web.xml"/>
</target>
<target name="set-entities-enabled-true">
<xslt style="set-entities.xsl" in="${dist}/${app}/WEB-INF/web.xml" out="${dist}/${app}/WEB-INF/web-entities.xml">
<param name="entitiesenabled" expression="true"/>
</xslt>
<delete file="${dist}/${app}/WEB-INF/web.xml"/>
<move file="${dist}/${app}/WEB-INF/web-entities.xml" tofile="${dist}/${app}/WEB-INF/web.xml"/>
</target>
<target name="set-entities-enabled-false">
<xslt style="set-entities.xsl" in="${dist}/${app}/WEB-INF/web.xml" out="${dist}/${app}/WEB-INF/web-entities.xml">
<param name="entitiesenabled" expression="false"/>
</xslt>
<delete file="${dist}/${app}/WEB-INF/web.xml"/>
<move file="${dist}/${app}/WEB-INF/web-entities.xml" tofile="${dist}/${app}/WEB-INF/web.xml"/>
</target>
<target name="set-entities-enabled-true-dev">
<xslt style="set-entities.xsl" in="${dev_build_location}/${app}/WEB-INF/web.xml" out="${dev_build_location}/${app}/WEB-INF/web-entities.xml">
<param name="entitiesenabled" expression="true"/>
</xslt>
<delete file="${dev_build_location}/${app}/WEB-INF/web.xml"/>
<move file="${dev_build_location}/${app}/WEB-INF/web-entities.xml" tofile="${dev_build_location}/${app}/WEB-INF/web.xml"/>
</target>
<target name="set-entities-enabled-false-dev">
<xslt style="set-entities.xsl" in="${dev_build_location}/${app}/WEB-INF/web.xml" out="${dev_build_location}/${app}/WEB-INF/web-entities.xml">
<param name="entitiesenabled" expression="false"/>
</xslt>
<delete file="${dev_build_location}/${app}/WEB-INF/web.xml"/>
<move file="${dev_build_location}/${app}/WEB-INF/web-entities.xml" tofile="${dev_build_location}/${app}/WEB-INF/web.xml"/>
</target>
<target name="check-for-oauth-properties">
<available file="oauth.properties" property="has-oauth"/>
</target>
<target name="copy-spyral-oauth-properties" depends="check-for-oauth-properties" if="has-oauth">
<copy file="oauth.properties" tofile="${dist}/${app}/WEB-INF/classes/oauth.properties" overwrite="true" />
</target>
<target name="check-for-oauth-properties-dev">
<available file="oauth.beta.properties" property="has-oauth-dev"/>
</target>
<target name="copy-spyral-oauth-properties-dev" depends="check-for-oauth-properties-dev" if="has-oauth-dev">
<copy file="oauth.beta.properties" tofile="${dev_build_location}/${app}/WEB-INF/classes/oauth.properties" overwrite="true" />
</target>
<target name="copy-nssi-config">
<copy file="nssiconfig.properties" tofile="${dist}/${app}/WEB-INF/classes/ca/lincsproject/nssi/config.properties" overwrite="true" />
</target>
<target name="copy-nssi-config-dev">
<copy file="nssiconfig.properties" tofile="${dev_build_location}/${app}/WEB-INF/classes/ca/lincsproject/nssi/config.properties" overwrite="true" />
</target>
<target name="copy-tool-limits-config">
<copy file="tool-limits-config.properties" tofile="${dist}/${app}/WEB-INF/classes/org/voyanttools/trombone/limits/config.properties" overwrite="true" />
</target>
<target name="copy-tool-limits-config-dev">
<copy file="tool-limits-config.dev.properties" tofile="${dev_build_location}/${app}/WEB-INF/classes/org/voyanttools/trombone/limits/config.properties" overwrite="true" />
</target>
<!-- dev versions that use local voyant and trombone -->
<target name="dev-compile">
<exec dir="${dev_trombone_location}" executable="cmd">
<arg line="/c mvn clean compile" />
</exec>
<exec dir="${dev_voyant_location}" executable="cmd">
<arg line="/c mvn clean compile" />
</exec>
<copy todir="${dev_voyant_location}/src/main/webapp/WEB-INF/classes">
<fileset dir="${dev_trombone_location}/target/classes"/>
</copy>
</target>
<target name="dev-copy-dependencies">
<exec dir="${dev_voyant_location}" executable="cmd">
<arg line="/c mvn org.apache.maven.plugins:maven-dependency-plugin:copy-dependencies -DincludeScope=runtime -DexcludeArtifactIds=trombone" />
</exec>
</target>
<target name="dev-populate">
<delete dir="${dev_build_location}"/>
<mkdir dir="${dev_build_location}/${app}/WEB-INF/lib"/>
<copy todir="${dev_build_location}/${app}/WEB-INF/lib">
<fileset dir="${dev_voyant_location}/target/dependency"/>
</copy>
<copy todir="${dev_build_location}/${app}">
<fileset dir="${dev_voyant_location}/src/main/webapp">
<exclude name="**/node_modules/**"/>
<exclude name="**/resources/docs/**"/>
</fileset>
</copy>
<copy todir="${dev_build_location}/${app}/resources/voyant/current" overwrite="true">
<fileset dir="${dev_voyant_server_location}/resources/voyant/current">
<include name="voyant.js"/>
<include name="voyant.min.js"/>
<include name="voyant.min.map.js"/>
</fileset>
</copy>
</target>
<target name="dev-server" depends="dev-compile,dev-copy-dependencies,dev-populate,copy-tool-limits-config-dev,copy-spyral-oauth-properties-dev,copy-nssi-config-dev,set-voyant-version-dev,set-entities-enabled-true-dev">
<!-- delete the nlp models file, they are already on the server -->
<delete>
<fileset dir="${dev_build_location}">
<include name="**/stanford*models.jar"/>
</fileset>
</delete>
<zip destfile="${dev_build_location}/VoyantServer_dev.zip"
compress="true">
<fileset dir="${dev_build_location}" />
</zip>
</target>
<!-- run the custom maven goal to copy voyant/trombone deps to voyant/target/dependency -->
<target name="copy-voyant-dependencies" depends="copy-voyant-dependencies-win,copy-voyant-dependencies-unix" />
<target name="copy-voyant-dependencies-win" if="isWindows">
<exec dir="${jarpath}/Voyant" executable="cmd">
<arg line="/c mvn org.apache.maven.plugins:maven-dependency-plugin:copy-dependencies -DincludeScope=runtime" />
</exec>
</target>
<target name="copy-voyant-dependencies-unix" if="isUnix">
<exec dir="${jarpath}/Voyant" executable="sh">
<arg line="-c 'mvn org.apache.maven.plugins:maven-dependency-plugin:copy-dependencies -DincludeScope=runtime'" />
</exec>
</target>
<!--
Ivy related tasks
-->
<target name="get-dependencies" depends="init-ivy">
<ivy:retrieve conf="default" pattern="lib/[artifact](-[classifier])-[revision].[ext]" />
</target>
<target name="init-ivy" depends="download-ivy">
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path" />
</target>
<target name="download-ivy" unless="offline">
<mkdir dir="${ivy.jar.dir}" />
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true" />
</target>
</project>