/
lifecycle.xml
526 lines (476 loc) · 21.3 KB
/
lifecycle.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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<?xml version="1.0" encoding="utf-8"?>
<project name="lifecycle" default="help" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<!--
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# $Id$
#
# Copyright 2006-2013 University of Dundee. All rights reserved.
# Use is subject to license terms supplied in LICENSE.txt
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Written by: Josh Moore <josh.moore@gmx.de>
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DOCUMENTATION:
==============================================================================
Provides lifecycle targets similar to those found in maven. See
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
Each target stair-steps down to prepare:
dist->install->package->compile->generate->prepare->retrieve
-->
<echo>Entering ${basedir}...</echo>
<target name="help">
<echo>
This build file is intended for import only.
</echo>
</target>
<target name="quick" description="Turn off tests">
<echo>
Deprecated: tests are disabled by default
</echo>
<property name="config.skip" value="true"/>
<property name="test.skip" value="true"/>
<property name="generate.skip" value="true"/>
</target>
<target name="nochecks" description="Turn off checks">
<property name="checks.skip" value="true"/>
</target>
<target name="fail-on-error" description="Fail if tests do not pass">
<property name="test.with.fail" value="true"/>
</target>
<target name="eclipse" depends="prepare">
<tryEclipse settingsRef="ivy.${ant.project.name}"/>
</target>
<target name="retrieve" unless="retrieve.done"
description="Copy resolves JAR dependencies">
<property name="retrieve.done" value="true"/>
<installIvy/>
<ivy:retrieve settingsRef="ivy.${ant.project.name}"
type="jar,bundle"
pattern="${deps.lib.dir}/[artifact](-[classifier]).[ext]"
log="quiet" sync="false" symlink="true"
haltonfailure="${package-extra}"/>
</target>
<target name="report" depends="prepare">
<mkdir dir="${target.dir}/build.deps"/>
<ivy:report todir="${target.dir}/build.deps" graph="false"
settingsRef="ivy.${ant.project.name}"/>
</target>
<target name="dependencytree"
description="Generate a tree of dependencies">
<installIvy/>
<ivy:dependencytree settingsRef="ivy.${ant.project.name}"
haltonfailure="${package-extra}"/>
</target>
<target name="prepare" depends="retrieve" description="Prepare resources">
<echo>Preparing: ${deps.lib.dir}</echo>
<mkdir dir="${deps.lib.dir}"/>
<defineClasspath/>
<defineVariables/>
<makeDirectories/>
<copyResource file="${root.dir}/etc/local.properties"/>
<copyResource file="${root.dir}/etc/hibernate.properties"/>
<copyResource file="${root.dir}/etc/omero.properties"/>
<!-- Handling logback*xml separately -->
<copy file="${root.dir}/lib/logback-build.xml" tofile="${resrc.dest}/logback.xml" failonerror="true" />
<copy file="${root.dir}/lib/logback-build.xml" tofile="${classes.dir}/logback.xml" failonerror="true" />
<!-- See #2187 for more information-->
<echo file="${classes.dir}/omero.properties" append="true">
omero.version=${omero.version}
</echo>
<echo file="${resrc.dest}/omero.properties" append="true">
omero.version=${omero.version}
</echo>
<for list="${classes.dir},${resrc.dest}" param="dir">
<sequential>
<if><not><isfileselected file="@{dir}/hibernate.properties">
<contains text="omero.db.port"/>
</isfileselected></not>
<then>
<concat destfile="@{dir}/hibernate.properties" append="true">
<filelist dir="${omero.home}/etc/profiles" files="${omero.db.profile}"/>
</concat>
</then></if>
</sequential>
</for>
<!-- Used (at least) by server.xml and omero.xml -->
<property name="omero.db.url" value="jdbc:postgresql://${omero.db.host}/${omero.db.name}"/>
<presetdef name="sql_run">
<sql
driver="${omero.db.driver}"
url="${omero.db.url}"
userid="${omero.db.user}"
password="${omero.db.pass}"
print="false"
delimiter=";;"
classpathref="omero.classpath">
</sql>
</presetdef>
</target>
<target name="generate" depends="prepare">
<pathconvert property="omero.path" refid="omero.classpath"/>
<echo file="${resrc.dest}/Classpath.sh">
export CLASSPATH=${omero.path}
</echo>
<copyResources/>
</target>
<presetdef name="nomemoryjava">
<javac
fork="yes"
sourcepath=""
source="${javac.source}"
target="${javac.target}"
encoding="UTF-8"
debug="${javac.debug}"
debuglevel="${javac.debuglevel}"
deprecation="on">
</javac>
</presetdef>
<!-- javac macro which can contain any number of path
elements for compilation. Usually src.dir and src.dest
will need to be compiled together because of inter-
dependencies -->
<macrodef name="myjavac">
<attribute name="destdir" default="${classes.dir}"/>
<attribute name="classpathref" default="omero.classpath"/>
<element name="srcelements" implicit="yes"/>
<sequential>
<tempfile property="temp.file" deleteonexit="true" prefix="_omero_build_" suffix=".tmp"/>
<concat destfile="${temp.file}">-classpath ${toString:@{classpathref}}</concat>
<if>
<isset property="javac.maxmem"/>
<then>
<nomemoryjava
destdir="@{destdir}"
memoryMaximumSize="${javac.maxmem}"
includeantruntime="false"
>
<compilerarg value="@${temp.file}"/>
<srcelements/>
</nomemoryjava>
</then>
<else>
<nomemoryjava
destdir="@{destdir}"
>
<compilerarg value="@${temp.file}"/>
<srcelements/>
</nomemoryjava>
</else>
</if>
<delete file="${temp.file}" quiet="true" failonerror="false"/>
</sequential>
</macrodef>
<target name="compile" depends="generate" unless="skip.compile"
description="Compile classes">
<myjavac>
<src path="${src.dir}"/>
<src path="${src.dest}"/>
</myjavac>
</target>
<target name="testng-init" unless="testng.init.done">
<property name="testng.init.done" value="true"/>
<installIvy/>
<defineClasspath/>
<ivy:settings id="ivy.${ant.project.name}.test" file="${etc.dir}/ivysettings.xml"/>
<ivy:resolve settingsRef="ivy.${ant.project.name}.test" file="${basedir}/test.xml" type="jar" log="quiet"/>
<ivy:retrieve settingsRef="ivy.${ant.project.name}.test" pattern="${deps.lib.dir}/test/[artifact].[ext]" log="quiet" sync="false" symlink="true"/>
<taskdef name="testng" classname="org.testng.TestNGAntTask" classpathref="omero.test.classpath"/>
<presetdef name="nomemorytestng">
<testng outputDir="${testreports.dir}"
haltonfailure="${test.with.fail}"
haltonskipped="${test.with.fail}"
verbose="${testng.verbose}"
groups="@{groups}"
methods="@{methods}"
testnames="@{testnames}"
useDefaultListeners="${testng.useDefaultListeners}"
listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter"
>
<classpath>
<path refid="omero.test.classpath"/>
<pathelement location="${testclasses.dir}"/>
<pathelement location="${classes.dir}"/>
<pathelement location="${test.dir}"/>
</classpath>
<jvmarg value="-XX:MaxPermSize=256m"/>
<jvmarg value="-XX:+IgnoreUnrecognizedVMOptions"/>
<jvmarg value="-Dlogback.configuration=logback-build.xml"/>
<jvmarg value="-Domero.db.name=${omero.db.name}"/>
<jvmarg value="-Domero.db.host=${omero.db.host}"/>
<jvmarg value="-Domero.db.port=${omero.db.port}"/>
<jvmarg value="-Domero.db.user=${omero.db.user}"/>
<jvmarg value="-Domero.db.pass=${omero.db.pass}"/>
<jvmarg value="-Domero.data.dir=${omero.data.dir}"/>
<jvmarg value="-Domero.testing=true"/>
<jvmarg value="-Domero.test.timeout=${omero.test.timeout}"/>
<jvmarg value="-Domero.db.poolsize=${omero.db.poolsize}"/>
</testng>
</presetdef>
</target>
<macrodef name="suite">
<attribute name="groups" default=""/>
<attribute name="methods" default=""/>
<attribute name="testnames" default=""/>
<element name="files" implicit="yes"/>
<sequential>
<if>
<isset property="javac.maxmem"/>
<then>
<nomemorytestng
groups="@{groups}"
methods="@{methods}"
testnames="@{testnames}"
>
<files/>
<jvmarg value="-Xmx${javac.maxmem}"/>
</nomemorytestng>
</then>
<else>
<nomemorytestng
groups="@{groups}"
methods="@{methods}"
testnames="@{testnames}"
>
<files/>
</nomemorytestng>
</else>
</if>
</sequential>
</macrodef>
<target name="test-compile" depends="testng-init" unless="test.skip"
description="Compile test classes">
<!-- may be overridden by fail-on-error -->
<property name="test.with.fail" value="false"/>
<property name="unit.suite" value="unit.testng.xml"/>
<copyTestResources/>
<myjavac
destdir="${testclasses.dir}"
classpathref="omero.test.classpath" >
<src path="${test.dir}"/>
</myjavac>
<jar destfile="${target.dir}/${ivy.module}.jar">
<fileset dir="${testclasses.dir}" includes="**/*.class,**/*.xml,**/*.txt,**/*.properties,**/*.dv,**/*.bmp,**/*.jpg,**/*.png"/>
</jar>
<delete file="${target.dir}/${ivy.module}.xml"/> <!-- delete last produced ivy file to be sure a new one will be generated -->
<ivy:publish artifactspattern="${target.dir}/[module].[ext]" resolver="test-resolver" settingsRef="ivy.${ant.project.name}"
pubrevision="${omero.version}" pubdate="${now}" status="integration" overwrite="true"/>
</target>
<target name="test-single" if="TEST">
<suite>
<classfileset dir="${testclasses.dir}">
<include name="**/${TEST}.class"/>
</classfileset>
</suite>
</target>
<target name="test-suite" unless="TEST" depends="testng-init">
<suite>
<xmlfileset dir="${test.dir}">
<include name="${unit.suite}"/>
</xmlfileset>
</suite>
</target>
<target name="test-groups" unless="TEST">
<!-- may be overridden by fail-on-error -->
<property name="test.with.fail" value="false"/>
<property name="integration.suite" value="integration.testng.xml"/>
<suite groups="${GROUPS}">
<classfileset dir="${testclasses.dir}">
<include name="**/*.class"/>
</classfileset>
</suite>
</target>
<target name="test-methods" unless="TEST">
<!-- may be overridden by fail-on-error -->
<property name="test.with.fail" value="false"/>
<property name="integration.suite" value="integration.testng.xml"/>
<suite methods="${METHODS}">
<classfileset dir="${testclasses.dir}">
<include name="**/*.class"/>
</classfileset>
</suite>
</target>
<target name="test" depends="test-compile" unless="test.skip">
<if><isset property="TEST"/><then>
<antcall target="test-single" inheritRefs="true" inheritAll="true"/></then>
<elseif><isset property="GROUPS"/><then>
<antcall target="test-groups" inheritRefs="true" inheritAll="true"/></then>
</elseif>
<elseif><isset property="METHODS"/><then>
<antcall target="test-methods" inheritRefs="true" inheritAll="true"/></then>
</elseif>
<else>
<antcall target="test-suite" inheritRefs="true" inheritAll="true"/>
</else>
</if>
</target>
<target name="integration" depends="test-compile" unless="test.skip">
<!-- may be overridden by fail-on-error -->
<property name="test.with.fail" value="false"/>
<property name="integration.suite" value="integration.testng.xml"/>
<if>
<available file="${test.dir}/${integration.suite}" />
<then>
<suite>
<xmlfileset dir="${test.dir}">
<include name="${integration.suite}"/>
</xmlfileset>
</suite>
</then>
</if>
</target>
<target name="package" depends="compile,package-extra">
<pathconvert property="mf.classpath"
refid="omero.compile.classpath"
pathsep=" " dirsep="/">
<flattenmapper/>
</pathconvert>
<property name="mf.classpath.and.jars" value="../../etc ${mf.classpath} services.jar extensions.jar"/>
<jar destfile="${target.dir}/${ivy.module}.jar" update="true">
<manifest>
<attribute name="Class-Path" value="${mf.classpath.and.jars}"/>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
<fileset dir="${classes.dir}">
<exclude name="local.properties"/>
<exclude name="logback.xml"/>
<exclude name="logback-build.xml"/>
</fileset>
</jar>
</target>
<target name="package-extra" description="Package sources and Javadocs">
<if><equals arg1="true" arg2="${package-extra}"/>
<then>
<jar destfile="${target.dir}/${ivy.module}-sources.jar">
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${src.dest}" includes="**/*.java"/>
</jar>
<mkdir dir="${target.dir}/javadocs"/>
<javadoc
classpathref="omero.classpath"
failonerror="true"
Verbose="false"
maxmemory="${javadoc.maxmem}"
destdir="${target.dir}/javadocs"
author="true"
version="true"
use="true"
encoding="UTF-8"
docencoding="UTF-8"
breakiterator="true"
useexternalfile="true"
additionalparam="${javadoc.doclint}">
<fileset dir="${src.dir}" includes="**/*.java"/>
<fileset dir="${src.dest}" includes="**/*.java"/>
</javadoc>
<jar destfile="${target.dir}/${ivy.module}-javadoc.jar">
<fileset dir="${target.dir}/javadocs"/>
</jar>
</then></if>
</target>
<target name="load-findbugs" depends="prepare">
<property name="findbugs.path" value="omero.classpath"/>
<property name="findbugs.type" value="jar"/>
<property name="findbugs.target" value="${target.dir}/${ivy.module}.${findbugs.type}"/>
<property name="findbugs.home" value="${omero.home}/lib/findbugs-${versions.findbugs}"/>
<taskdef name="find-bugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="omero.classpath"/>
<taskdef resource="checkstyletask.properties" classpathref="omero.classpath"/>
<condition property="no.findbugs"><not><available file="${findbugs.target}"/></not></condition>
<macrodef name="do-find-bugs">
<sequential>
<find-bugs home="${findbugs.home}" output="xml:withMessages" outputFile="${target.dir}/findbugs.xml"
excludeFilter="${import.dir}/excludebugs.xml">
<class location="${findbugs.target}" />
<auxClasspath>
<path refid="${findbugs.path}"/>
</auxClasspath>
<sourcePath>
<path>
<pathelement location="${src.dir}"/>
<pathelement location="${src.dest}"/>
</path>
</sourcePath>
</find-bugs>
</sequential>
</macrodef>
<macrodef name="do-checkstyle">
<attribute name="config" default="${omero.home}/docs/styles/checkstyle.xml"/>
<attribute name="failOnViolation" default="false"/>
<attribute name="toFile" default="${target.dir}/checkstyle.xml"/>
<element name="srcelements" implicit="yes"/>
<sequential>
<checkstyle config="@{config}" failOnViolation="@{failOnViolation}">
<formatter type="xml" toFile="@{toFile}"/>
<srcelements/>
</checkstyle>
</sequential>
</macrodef>
</target>
<target name="headers" description="Run checkstyle header check" depends="load-findbugs">
<do-checkstyle config="${omero.home}/docs/styles/headers.xml" toFile="${target.dir}/headers.xml" failOnViolation="true">
<fileset dir="${basedir}" includes="**/*"/>
</do-checkstyle>
</target>
<target name="findbugs" description="Run findbugs on components' jar" depends="load-findbugs" unless="no.findbugs">
<do-find-bugs/>
<do-checkstyle>
<fileset dir="${basedir}" includes="**/*.java"/>
</do-checkstyle>
</target>
<target name="install" depends="package" description="Publish artifacts">
<property name="ivy.pom.version" value="${omero.version}"/>
<ivy:makepom ivyfile="${basedir}/ivy.xml"
settingsRef="ivy.${ant.project.name}"
pomfile="${target.dir}/${ivy.module}.pom">
<mapping conf="build" scope="compile"/>
<mapping conf="runtime" scope="compile"/>
<mapping conf="client" scope="compile"/>
<mapping conf="server" scope="compile"/>
<mapping conf="default" scope="compile"/>
<mapping conf="*" scope="compile"/>
<dependency group="ome" artifact="bio-formats" version="${omero.version}" optional="true"/>
</ivy:makepom>
<publishArtifact haltonmissing="${package-extra}"/>
</target>
<!-- Previously depend on integration, but that may need special controls.
For the time being, depending solely on "install" -->
<target name="dist" depends="install">
<!-- empty by default -->
</target>
<target name="artifactory" depends="prepare">
<ivy:settings id="ivy.${ant.project.name}.artifactory" file="${etc.dir}/ivysettings.xml"/>
<ivy:resolve file="ivy.xml" type="jar,egg" conf="client" settingsRef="ivy.${ant.project.name}.artifactory" log="quiet"/>
<publishArtifact
resolver="artifactory-publish"
settingsRef="ivy.${ant.project.name}.artifactory"
haltonmissing="false"
publishivy="false"
conf="client"/>
</target>
<target name="clean">
<delete dir="${target.dir}"/>
</target>
<!-- NON-LIFECYCLE HELPER TARGETS -->
<target name="strict-test" depends="fail-on-error,clean-tests,test"/>
<target name="clean-tests">
<delete dir="${testclasses.dir}"/>
<delete dir="${testreports.dir}"/>
</target>
<target name="refresh" if="eclipse.running">
<eclipse.refreshLocal resource="omero-dsl" depth="infinite"/>
<eclipse.refreshLocal resource="omero-common" depth="infinite"/>
<eclipse.refreshLocal resource="omero-server" depth="infinite"/>
<eclipse.refreshLocal resource="omero-client" depth="infinite"/>
<eclipse.refreshLocal resource="omero-shoola-adapter" depth="infinite"/>
<eclipse.refreshLocal resource="missing" depth="infinite"/>
</target>
<macrodef name="copyResource">
<attribute name="file"/>
<sequential>
<basename property="props.file.prop" file="@{file}"/>
<copy file="@{file}" todir="${resrc.dest}" failonerror="true" />
<copy file="@{file}" todir="${classes.dir}" failonerror="true" />
</sequential>
</macrodef>
</project>