-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.xml
334 lines (298 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
<project name="reviki" default="war" basedir=".">
<description>
reviki build - see http://reviki.org for more information
</description>
<presetdef name="rjavac">
<!-- http://stackoverflow.com/a/8114557 -->
<javac includeantruntime="false">
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:deprecation" />
</javac>
</presetdef>
<property name="buildNumber" value="dev" />
<property name="version" value="0.7.0" />
<property name="build-details" value="${version} r${buildNumber}" />
<property name="generated-source" value="src-gen" />
<property name="wiki-source" value="wiki-src" />
<property name="renderer-source" value="renderer-src" />
<property name="web" value="WebContent" />
<property name="build-wiki" value="ant-build/wiki" />
<property name="build-renderer" value="ant-build/renderer" />
<property name="build-web" value="ant-build/web" />
<property name="reports" value="reports" />
<property name="release" value="release" />
<property name="jar" value="${build-web}/WEB-INF/lib/reviki.jar"/>
<property name="rendererJar" value="${build-web}/WEB-INF/lib/reviki-renderer.jar"/>
<property name="testJar" value="ant-build/reviki-test.jar"/>
<property name="war" value="${release}/${ant.project.name}.war" />
<property name="prepopulated-pages" value="net/hillsdon/reviki/web/vcintegration/prepopulated/**"/>
<property name="source-webtests" value="webtests" />
<property name="build-webtests" value="ant-build/webtests" />
<property name="tomcat" value="tomcat"/>
<property name="tomcat.version" value="7.0.77"/>
<property name="tomcat-url" value="http://mirror.ox.ac.uk/sites/rsync.apache.org/tomcat/tomcat-7/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip"/>
<!-- The VNU jar at this URL is repackaged with jarjar to avoid contributing conflicting versions of embedded libraries to other parts of the build. -->
<property name="vnu-url" value="https://github.com/paulcadman/build/releases/download/20140424/vnu-20140424-jarjar.jar"/>
<!-- For now, to run the functional tests you need to set up SVN and reviki.properties manually.
The wiki should be called 'test' (with no base URL set).
Note the wiki data will be stored in ./reviki-test-data, not the usual ~/reviki-data
directory.
An external properties file is used to retrieve the username and password to use.
See the file "build.properties.example".
-->
<property file="build.properties" />
<path id="classpath">
<fileset dir="lib">
<include name="*.jar" />
</fileset>
<fileset dir="${web}/WEB-INF/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<tstamp/>
<get src="${vnu-url}" dest="lib/vnu.jar" usetimestamp="true" />
<mkdir dir="${build-wiki}" />
<mkdir dir="${build-renderer}" />
<mkdir dir="${build-web}" />
<mkdir dir="${build-webtests}" />
<mkdir dir="${reports}" />
<mkdir dir="${release}" />
<mkdir dir="${generated-source}" />
</target>
<target name="clean" description="Clean-up build artifacts">
<delete dir="${build-wiki}" />
<delete dir="${build-renderer}" />
<delete dir="${build-web}" />
<delete dir="${build-webtests}" />
<delete dir="${reports}" />
<delete dir="${release}" />
<delete file="${war}"/>
<delete dir="${generated-source}" />
<delete dir="${tomcat}" />
<!-- We leave the tomcat zip as it is a large download. -->
</target>
<target name="generate-sources" depends="init">
<java jar="lib/antlr4.jar" dir="renderer-src/net/hillsdon/reviki/wiki/renderer/creole" fork="true">
<arg value="-o"/>
<arg value="${basedir}/${generated-source}/net/hillsdon/reviki/wiki/renderer/creole"/>
<arg value="-package"/>
<arg value="net.hillsdon.reviki.wiki.renderer.creole"/>
<arg value="-visitor"/>
<arg value="Creole.g4"/>
<arg value="CreoleTokens.g4"/>
</java>
</target>
<target name="compile-wiki" depends="init, renderer-jar">
<rjavac srcdir="${wiki-source}" destdir="${build-wiki}" fork="yes" target="1.6" source="1.6" debug="true">
<classpath>
<pathelement path="${rendererJar}"/>
<path refid="classpath" />
</classpath>
</rjavac>
<copy todir="${build-web}">
<fileset dir="${web}">
<include name="*/**"/>
</fileset>
</copy>
<replace file="${build-web}/WEB-INF/templates/SiteTemplate.jsp" token="$Version$" value="${build-details}"/>
<copy todir="${build-wiki}">
<fileset dir="${wiki-source}">
<include name="**/*.json"/>
<include name="**/*.jar"/>
<include name="**/*.xml"/>
<include name="${prepopulated-pages}"/>
<include name="net/hillsdon/reviki/web/taglib/reviki.tld"/>
</fileset>
</copy>
</target>
<target name="compile-renderer" depends="generate-sources">
<rjavac destdir="${build-renderer}" fork="yes" target="1.6" source="1.6" debug="true">
<src path="${renderer-source}"/>
<src path="${generated-source}"/>
<classpath refid="classpath" />
</rjavac>
<copy todir="${build-renderer}">
<fileset dir="${renderer-source}">
<include name="**/*.json"/>
<include name="**/*.jar"/>
<include name="**/*.xml"/>
</fileset>
</copy>
</target>
<target name="compile" depends="compile-wiki, compile-renderer"/>
<target name="jar" depends="compile-wiki">
<jar destfile="${jar}">
<fileset dir="${build-wiki}">
<include name="**/*.class"/>
<include name="${prepopulated-pages}"/>
</fileset>
</jar>
</target>
<target name="test-jar" depends="functional-tests-compile">
<jar destfile="${testJar}">
<fileset dir="${build-webtests}">
<include name="**/*.class"/>
</fileset>
</jar>
</target>
<target name="renderer-jar" depends="compile-renderer">
<!-- Create the manifest -->
<manifest file="MANIFEST.MF">
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Implementation-Version" value="${version}.${buildNumber} ${TODAY}"/>
</manifest>
<jar destfile="${rendererJar}" manifest="MANIFEST.MF">
<fileset dir="${build-renderer}">
<include name="**/*.class"/>
</fileset>
</jar>
<delete file="MANIFEST.MF"/>
</target>
<target name="functional-tests-compile" depends="compile">
<rjavac srcdir="${source-webtests}" destdir="${build-webtests}" source="1.7" target="1.7" debug="true">
<classpath>
<path refid="classpath" />
<pathelement location="${build-wiki}"/>
<pathelement location="${build-renderer}"/>
</classpath>
</rjavac>
</target>
<target name="taglib-jar" depends="compile" description="Rebuild the JSP taglib JAR file">
<mkdir dir="${build-wiki}/META-INF"/>
<move file="${build-wiki}/net/hillsdon/reviki/web/taglib/reviki.tld" tofile="${build-wiki}/META-INF/reviki.tld"/>
<jar destfile="WebContent/WEB-INF/lib/reviki-tlds.jar" >
<fileset dir="${build-wiki}">
<include name="net/hillsdon/reviki/web/taglib/**/*.class"/>
</fileset>
<metainf dir="${build-wiki}/META-INF">
<include name="**/*"/>
</metainf>
</jar>
</target>
<target name="unit-tests" depends="compile" description="Run the unit tests">
<junit printsummary="yes" fork="true" forkmode="once" haltonfailure="yes">
<jvmarg value="-Xss1m" />
<jvmarg value="-XX:ThreadStackSize=2048" />
<formatter type="plain" usefile="false"/>
<classpath>
<path refid="classpath"/>
<pathelement location="${build-wiki}"/>
<pathelement location="${build-renderer}"/>
</classpath>
<formatter type="xml"/>
<batchtest todir="${reports}">
<fileset dir="${wiki-source}">
<include name="**/Test*.java"/>
</fileset>
<fileset dir="${renderer-source}">
<include name="**/Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="war" depends="jar, renderer-jar" description="Build the WAR file">
<war warfile="${war}"
webxml="${build-web}/WEB-INF/web.xml">
<fileset dir="${build-web}">
<include name="**/*"/>
<exclude name="WEB-INF/**/*"/>
</fileset>
<webinf dir="${build-web}/WEB-INF" includes="**" excludes="web.xml" />
</war>
<!-- Output version information file for the build system. -->
<echo message="${version}" file="${release}/product.version"/>
</target>
<target name="prepare-tomcat">
<mkdir dir="${tomcat}"/>
<get src="${tomcat-url}" dest="tomcat.zip" usetimestamp="true" />
<!-- Use regexpmapper directly with unzip when we can depend on Ant 1.7. -->
<mkdir dir="${tomcat}-unziphelper"/>
<unzip src="tomcat.zip" dest="${tomcat}-unziphelper"/>
<copy todir="${tomcat}">
<fileset dir="${tomcat}-unziphelper" includes="**/*"/>
<regexpmapper handledirsep="true" from="apache-tomcat-.*?/(.*)" to="\1"/>
</copy>
<delete dir="${tomcat}-unziphelper"/>
<!-- Full of JSPs that the Eclipse validation objects to. -->
<delete dir="${tomcat}/webapps"/>
<mkdir dir="${tomcat}/webapps"/>
<!-- Would be really useful to munge the port numbers to something unusual here,
8080 will often conflict with something else. Perhaps some XSLT? -->
<chmod dir="${tomcat}/bin" includes="**/*.sh" perm="u+x" />
</target>
<target name="deploy" depends="war, prepare-tomcat" description="Build and deploy the WAR to tomcat, ready to be started">
<property name="deploy-dir" value="${tomcat}/conf/Catalina/localhost"/>
<mkdir dir="${deploy-dir}"/>
<copy file="context.xml" tofile="${deploy-dir}/reviki.xml"/>
</target>
<target name="start-tomcat" description="Start tomcat at localhost:8080">
<!-- XXX: Is there a platform independent way to start/stop tomcat? -->
<exec executable="${tomcat}/bin/startup.sh"/>
<waitfor maxwait="15" maxwaitunit="second" checkevery="500" timeoutproperty="start-tomcat-failed">
<http url="http://localhost:8080/reviki/"/>
</waitfor>
<fail if="start-tomcat-failed" />
</target>
<target name="stop-tomcat" description="Stop tomcat launched by start-tomcat">
<exec executable="${tomcat}/bin/shutdown.sh"/>
</target>
<target name="functional-tests-junit" depends="functional-tests-compile">
<junit printsummary="yes" fork="yes" forkmode="once" failureproperty="functional-tests-failed">
<jvmarg value="-Dwiki.url=${wiki.url}" />
<jvmarg value="-Dwiki.username=${wiki.username}" />
<jvmarg value="-Dwiki.password=${wiki.password}" />
<jvmarg value="-Dwiki.altusername=${wiki.altusername}" />
<jvmarg value="-Dwiki.altpassword=${wiki.altpassword}" />
<jvmarg value="-Dwiki.svn=${wiki.svn}" />
<jvmarg value="-Xss1m" />
<jvmarg value="-XX:ThreadStackSize=2048" />
<formatter type="plain" usefile="false"/>
<classpath>
<path refid="classpath"/>
<pathelement location="${build-wiki}"/>
<pathelement location="${build-renderer}"/>
<pathelement location="${build-webtests}"/>
</classpath>
<formatter type="xml"/>
<batchtest todir="${reports}">
<fileset dir="${source-webtests}">
<include name="**/Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="functional-tests" depends="deploy" description="Run the functional tests against a tomcat started/stopped by ant">
<antcall>
<target name="start-tomcat" />
<target name="functional-tests-junit"/>
<target name="stop-tomcat" />
<target name="fail-iff-functional-tests-failed"/>
</antcall>
</target>
<target name="functional-tests-external" description="Run the functional tests against a tomcat outside of ant's control">
<antcall>
<target name="functional-tests-junit"/>
<target name="fail-iff-functional-tests-failed"/>
</antcall>
</target>
<target name="fail-iff-functional-tests-failed">
<fail if="functional-tests-failed" />
</target>
<target name="all-tests" depends="unit-tests, functional-tests" description="Run all the tests (starts/stops tomcat)"/>
<target name="release" depends="war, test-jar">
<property name="release-dirname" value="reviki-${version}-${buildNumber}"/>
<zip file="${release}/${release-dirname}.zip">
<zipfileset prefix="${release-dirname}" dir=".">
<include name="${war}"/>
</zipfileset>
<zipfileset prefix="${release-dirname}" dir="docs">
<include name="*.TXT"/>
</zipfileset>
</zip>
<!-- Take a copy of the reviki JARs for building plugins against. -->
<copy file="${jar}" todir="${release}"/>
<copy file="${rendererJar}" todir="${release}"/>
<copy file="${testJar}" todir="${release}"/>
</target>
</project>