-
Notifications
You must be signed in to change notification settings - Fork 93
/
build-common.xml
620 lines (559 loc) · 29.5 KB
/
build-common.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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
<project name="build-common" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:antcontrib="antlib:net.sf.antcontrib">
<!-- Set properties that can be used in all projects. -->
<dirname property="zimbra.root.dir" file="${ant.file.build-common}/../"/>
<dirname property="zm-mailbox.basedir" file="${ant.file.build-common}"/>
<!-- Java -->
<property name="javac.target" value="1.8"/>
<!-- base path for ivy cache, local repository, ant libraries, etc -->
<property name="dev.home" value="${user.home}"/>
<!-- Add "init-ivy" depends to your "resolve" target and the following will
automatically download and install ivy if necessary. -->
<property name="ivy.jar.dir" location="${dev.home}/.ant/lib" />
<property name="ivy.install.version" value="2.3.0" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy-2.3.0.jar" />
<property name="ivy.status" value="integration" />
<property name="ivy.organisation" value="zimbra" />
<property name="ivy.publish.src.artifacts.pattern" value="build/[artifact]-[revision].[ext]" />
<property name="ivy.deliver.ivy.pattern" value="${dev.home}/.zcs-deps/[organisation]/[module]/[module]-[revision].[ext]" />
<property name="ivy.module" value="${ant.project.name}" />
<target name="test.if.ivy.available">
<condition property="ivy.installed">
<available file="${ivy.jar.file}" type="file"/>
</condition>
</target>
<target name="download-ivy" description="Install ivy" unless="ivy.installed" depends="test.if.ivy.available">
<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>
<target name="init-ivy" depends="download-ivy">
<!-- If ivy is not downloaded yet, try to load ivy here from ivy home. -->
<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>
<!-- common resolve target that should work to resolve dependencies based on ivy.xml for most projects -->
<target name="resolve" depends="init-ivy" description="resolve dependencies">
<ivy:settings id="dev.settings" file="../build-ivysettings.xml"/>
<ivy:resolve settingsRef="dev.settings" />
<ivy:cachepath pathid="class.path" />
</target>
<target name="3rd-party-defines" description="Declare 3rd party ANT tasks" depends="resolve">
<taskdef uri="antlib:net.sf.antcontrib" classpathref="class.path"/>
</target>
<!-- Ignore the classpath from the shell running ant. This avoids dependency
on the user's environment and suppresses the warning about includeAntRuntime. -->
<property name="build.sysclasspath" value="ignore"/>
<!-- Standard directory paths -->
<property name="src.dir" location="src" />
<property name="src.java.dir" location="src/java" />
<property name="src.bin.dir" location="src/bin" />
<property name="src.libexec.dir" location="src/libexec" />
<property name="src.zimlet.dir" location="src/zimlet" />
<property name="jars.dir" location="jars" />
<property name="build.dir" location="build" />
<property name="build.tmp.dir" location="${build.dir}/tmp" />
<property name="dist.dir" location="${build.dir}/dist" />
<property name="dist.lib.dir" location="${dist.dir}/lib"/>
<property name="dist.lib.ext.dir" location="${dist.lib.dir}/ext"/>
<property name="build.classes.dir" location="${build.dir}/classes" />
<property name="build.instrumented.dir" location="${build.dir}/classes-inst" />
<property name="build.coverage.dir" location="${build.dir}/coverage" />
<property name="build.zimlet.dir" location="${build.dir}/zimlet" />
<property name="test.dir" location="${build.dir}/test"/>
<property name="itest.dir" location="${build.dir}/itest"/>
<property name="test.pattern" value="**/*Test.java"/>
<property name="test.src.dir" location="src/java-test"/>
<property name="test.classes.dir" location="${build.dir}/test-classes"/>
<path id="all.java.path">
<pathelement location="${src.java.dir}" />
</path>
<!-- Standard build dependencies path -->
<property name="build.deps.dir" location="${dev.home}/.zcs-deps"/>
<!-- Standard install paths -->
<property name="zimbra.home.dir" location="/opt/zimbra" />
<property name="jetty.home.dir" location="${zimbra.home.dir}/jetty"/>
<property name="jetty.webapps.dir" location="${jetty.home.dir}/webapps"/>
<property name="common.jars.dir" location="${zimbra.home.dir}/lib/jars"/>
<property name="jetty.endorsed.jars.dir" location="${jetty.home.dir}/common/endorsed"/>
<property name="jetty.common.jars.dir" location="${jetty.home.dir}/common/lib"/>
<property name="ext-common.jars.dir" location="${zimbra.home.dir}/lib/ext-common"/>
<property name="common.sourcejars.dir" location="${zimbra.home.dir}/jars-src"/>
<!-- ZimbraCommon -->
<property name="common.dir" location="${zm-mailbox.basedir}/common"/>
<property name="common.src.java.dir" location="${common.dir}/src/java"/>
<property name="common.classes.dir" location="${common.dir}/build/classes"/>
<property name="common.jarfile" location="${common.dir}/build/zimbracommon.jar"/>
<property name="common.internal.jars.dir" location="../jars-internal/jars"/>
<!-- ZimbraNative -->
<property name="native.dir" location="${zm-mailbox.basedir}/native" />
<property name="native.classes.dir" location="${native.dir}/build/classes" />
<!-- ZimbraServer -->
<property name="server.dir" location="${zm-mailbox.basedir}/store"/>
<property name="server.classes.dir" location="${server.dir}/build/classes"/>
<property name="server.test.classes.dir" location="${server.dir}/build/test-classes"/>
<property name="server.jarfile" location="${server.dir}/build/zimbrastore.jar"/>
<property name="server.jars.dir" location="${zimbra.home.dir}/jars"/>
<property name="server.conf.dir" location="${server.dir}/conf"/>
<!-- ZimbraSoap -->
<property name="soap.dir" location="${zm-mailbox.basedir}/soap"/>
<property name="soap.classes.dir" location="${soap.dir}/build/classes"/>
<property name="soap.jarfile" location="${soap.dir}/build/zimbrasoap.jar"/>
<!-- ZimbraClient -->
<property name="client.dir" location="${zm-mailbox.basedir}/client"/>
<property name="client.classes.dir" location="${client.dir}/build/classes"/>
<property name="client.jarfile" location="${client.dir}/build/zimbraclient.jar"/>
<property name="msgs.dir" location="${zm-mailbox.basedir}/store-conf/conf/msgs"/>
<!-- Emma -->
<property name="emma.dir" value="/usr/share/java" />
<path id="emma.lib" >
<pathelement location="${emma.dir}/emma.jar" />
<pathelement location="${emma.dir}/emma_ant.jar" />
</path>
<path id="emma.run.classpath" >
<pathelement location="${build.classes.dir}" />
</path>
<!-- Classpath for running unit test, it needs classes from build dir -->
<path id="test.class.path">
<path refid="class.path"/>
<pathelement location="${build.classes.dir}" />
<pathelement location="${test.classes.dir}" />
<pathelement location="${msgs.dir}" />
</path>
<!-- Platform -->
<condition property="native.os" value="MacOSX">
<os name="Mac OS X"/>
</condition>
<condition property="native.os" value="Linux">
<os name="Linux"/>
</condition>
<condition property="native.so" value="jnilib">
<os name="Mac OS X"/>
</condition>
<condition property="native.so" value="so">
<not><os name="Mac OS X"/></not>
</condition>
<condition property="native.arch" value="">
<os name="Mac OS X"/>
</condition>
<condition property="native.arch" value=".${os.arch}">
<not>
<os name="Mac OS X"/>
</not>
</condition>
<condition property="is-windows">
<os family="windows"/>
</condition>
<condition property="is-unix">
<not><os family="windows"/></not>
</condition>
<target name="require-version">
<fail message="Missing build version. use ant proper ZCS version like -Dzimbra.buildinfo.version=8.7.6_GA_1001">
<condition>
<not>
<isset property="zimbra.buildinfo.version"/>
</not>
</condition>
</fail>
<echo message="Using version ${zimbra.buildinfo.version}"/>
</target>
<target name="set-dev-version" depends="require-version,3rd-party-defines">
<antcontrib:if>
<not>
<isset property="jar.file"/>
</not>
<then>
<exec executable="git" outputproperty="git.timestamp">
<arg value="log"/>
<arg value="-1"/>
<arg value="--pretty=format:%at"/>
</exec>
<!-- Build version -->
<tstamp/>
<antcontrib:propertyregex property="zimbra.buildinfo.majorversion"
input="${zimbra.buildinfo.version}"
regexp="([0-9]+)\.([0-9]+)\.([0-9]+)"
select="\1"
casesensitive="false" />
<antcontrib:propertyregex property="zimbra.buildinfo.minorversion"
input="${zimbra.buildinfo.version}"
regexp="([0-9]+)\.([0-9]+)\.([0-9]+)"
select="\2"
casesensitive="false" />
<antcontrib:propertyregex property="zimbra.buildinfo.microversion"
input="${zimbra.buildinfo.version}"
regexp="([0-9]+)\.([0-9]+)\.([0-9]+)"
select="\3"
casesensitive="false" />
<antcontrib:propertyregex property="zimbra.buildinfo.relclass"
defaultValue="GA"
input="${zimbra.buildinfo.version}"
regexp="([0-9]+)\.([0-9]+)\.([0-9]+)_([A-Z]+)"
select="\4"
casesensitive="false" />
<antcontrib:propertyregex property="zimbra.buildinfo.buildnum"
input="${zimbra.buildinfo.version}"
regexp="([0-9]+)\.([0-9]+)\.([0-9]+)_([A-Z]+)_([0-9]+)"
select="\5"
casesensitive="false" />
<condition property="zimbra.buildinfo.relnum" value="0">
<not><isset property="${zimbra.buildinfo.relnum}"/></not>
</condition>
<condition property="zimbra.buildinfo.type" value="">
<not><isset property="${zimbra.buildinfo.type}"/></not>
</condition>
<condition property="zimbra.buildinfo.release" value="${user.name}">
<not><isset property="${zimbra.buildinfo.release}"/></not>
</condition>
<condition property="zimbra.buildinfo.date" value="${DSTAMP}-${TSTAMP}">
<not><isset property="${zimbra.buildinfo.date}"/></not>
</condition>
<condition property="zimbra.buildinfo.host" value="${zimbra.server.hostname}">
<not><isset property="${zimbra.buildinfo.host}"/></not>
</condition>
<property name="zimbra.buildinfo.microtag" value="${zimbra.buildinfo.microversion}_${zimbra.buildinfo.relclass}"/>
<property name="zimbra.buildinfo.all"
value="Version: ${zimbra.buildinfo.version}; Type: ${zimbra.buildinfo.type}; Release: ${zimbra.buildinfo.release}; Built: ${zimbra.buildinfo.date}; Host: ${zimbra.buildinfo.host}"/>
<property name="dev.version" value="${zimbra.buildinfo.majorversion}.${zimbra.buildinfo.minorversion}.${zimbra.buildinfo.microversion}.${git.timestamp}"/>
<property name="jar.file" value="${ant.project.name}-${dev.version}.jar"/>
</then>
</antcontrib:if>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="build-init" depends="require-version">
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="compile" depends="build-init,resolve,3rd-party-defines" description="Compiles from src/java into build/classes.">
<mkdir dir="${build.classes.dir}" />
<javac destdir="${build.classes.dir}" debug="true" classpathref="class.path" target="${javac.target}" encoding="utf-8">
<src refid="all.java.path" />
</javac>
</target>
<target name="test-compile" depends="compile,3rd-party-defines">
<antcontrib:if>
<available file="${test.src.dir}" type="dir"/>
<antcontrib:then>
<mkdir dir="${test.classes.dir}"/>
<javac destdir="${test.classes.dir}" srcdir="${test.src.dir}" classpathref="test.class.path"
debug="true" target="${javac.target}" encoding="utf-8" />
<copy todir="${test.classes.dir}">
<fileset dir="${test.src.dir}" excludes="**/*.java"/>
</copy>
</antcontrib:then>
</antcontrib:if>
</target>
<target name="test" depends="test-compile" description="Run unit tests">
<property name="test-results-file" value="${zm-mailbox.basedir}/build/test-results.txt"/>
<antcontrib:if>
<available file="${test.src.dir}" type="dir"/>
<then>
<property name="test.path" refid="test.class.path"/>
<delete dir="${test.dir}" quiet="true"/>
<mkdir dir="${test.dir}/output"/>
<mkdir dir="${test.dir}/report"/>
<mkdir dir="${test.dir}/extensions"/>
<move todir="${test.dir}/extensions/com/zimbra/extensions" failonerror="false">
<fileset dir="${test.classes.dir}/com/zimbra/extensions" />
</move>
<copy file="${test.src.dir}/log4j-test.properties" tofile="${test.classes.dir}/log4j.properties" failonerror="false"/>
<junit haltonfailure="${halt-on-failure}" printsummary="on" showoutput="true" failureproperty="junit.failure" tempdir="${test.dir}" fork="true">
<classpath refid="test.class.path"/>
<assertions><enable/></assertions>
<formatter type="xml"/>
<jvmarg value="-Xverify:none"/>
<jvmarg value="-Dserver.dir=${server.dir}"/>
<jvmarg value="-Dzimbra.config=${server.dir}/src/java-test/localconfig-test.xml"/>
<jvmarg value="-Dfile.encoding=UTF-8"/>
<batchtest todir="${test.dir}/output">
<fileset dir="${test.src.dir}">
<include name="${test.pattern}"/>
<exclude name="**/Abstract*Test.java"/>
<exclude name="**/mailbox/ContactTest.java"/>
<exclude name="**/filter/FileIntoCopyTest.java"/>
<exclude name="**/cs/redolog/op/CreateMessageTest.java"/>
<exclude name="**/cs/service/mail/SearchActionTest.java"/>
<exclude name="**/cs/filter/RuleManagerWithCustomActionFilterTest.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${test.dir}/report">
<fileset dir="${test.dir}/output"/>
<report todir="${test.dir}/report"/>
</junitreport>
<echo>Test Report: ${test.dir}/report/index.html</echo>
<antcontrib:if>
<isset property="junit.failure"/>
<then><echo append="true" file="${test-results-file}" message="${test.dir} - FAILED
"/></then>
<else><echo append="true" file="${test-results-file}" message="${test.dir} - PASSED
"/></else>
</antcontrib:if>
</then>
<else>
<echo>${test.src.dir} not found. Will not run unit tests</echo>
</else>
</antcontrib:if>
</target>
<target name="test-hudson" depends="test-compile" description="Run hudson unit tests">
<property name="test.path" refid="test.class.path"/>
<delete dir="${test.dir}" quiet="true"/>
<mkdir dir="${test.dir}/output"/>
<mkdir dir="${test.dir}/report"/>
<mkdir dir="${test.dir}/extensions"/>
<move todir="${test.dir}/extensions/com/zimbra/extensions" failonerror="false">
<fileset dir="${test.classes.dir}/com/zimbra/extensions" />
</move>
<copy file="${test.src.dir}/log4j-test.properties" tofile="${test.classes.dir}/log4j.properties" failonerror="false"/>
<junit printsummary="on" showoutput="true" failureproperty="junit.failure" tempdir="${test.dir}">
<classpath refid="test.class.path"/>
<assertions><enable/></assertions>
<formatter type="xml"/>
<jvmarg value="-Xverify:none"/>
<batchtest todir="${test.dir}/output">
<fileset dir="${test.src.dir}">
<include name="**/*Test.java"/>
<exclude name="**/*ITest.java"/>
<exclude name="**/Abstract*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${test.dir}/report">
<fileset dir="${test.dir}/output"/>
<report todir="${test.dir}/report"/>
</junitreport>
<echo>Test Report: ${test.dir}/report/index.html</echo>
<fail if="junit.failure" message="Unit test failed"/>
</target>
<!-- e.g. ant -Dtest.name=com.zimbra.cs.mailbox.ContactTest single-test -->
<target name="single-test" depends="test-compile" description="Run single unit test">
<fail message="test.name must be set - Need e.g. ant -Dtest.name=com.zimbra.cs.mailbox.ContactTest single-test"
unless="test.name"/>
<property name="single.test.dir" value="${test.dir}-${test.name}"/>
<delete dir="${single.test.dir}" quiet="true"/>
<mkdir dir="${single.test.dir}/output"/>
<mkdir dir="${single.test.dir}/report"/>
<mkdir dir="${test.dir}/extensions"/>
<move todir="${test.dir}/extensions/com/zimbra/extensions" failonerror="false">
<fileset dir="${test.classes.dir}/com/zimbra/extensions" />
</move>
<copy file="${test.src.dir}/log4j-test.properties" tofile="${test.classes.dir}/log4j.properties" failonerror="false"/>
<junit fork="yes" printsummary="on" showoutput="true" failureproperty="junit.failure" tempdir="${single.test.dir}">
<classpath refid="test.class.path"/>
<assertions><enable/></assertions>
<formatter type="xml"/>
<jvmarg value="-Xverify:none"/>
<jvmarg value="-Dserver.dir=${server.dir}"/>
<jvmarg value="-Dzimbra.config=${server.dir}/src/java-test/localconfig-test.xml"/>
<jvmarg value="-Dfile.encoding=UTF-8"/>
<test name="${test.name}" todir="${single.test.dir}/output" />
</junit>
<junitreport todir="${single.test.dir}/report">
<fileset dir="${single.test.dir}/output"/>
<report todir="${single.test.dir}/report"/>
</junitreport>
<echo>Test Report: ${single.test.dir}/report/index.html</echo>
<fail if="junit.failure" message="Single Unit test failed"/>
</target>
<target name="emma" description="Emma Instrumentation">
<taskdef resource="emma_ant.properties" classpathref="emma.lib"/>
<delete dir="${build.instrumented.dir}" quiet="true" />
<mkdir dir="${build.instrumented.dir}" />
<delete dir="${build.coverage.dir}" quiet="true"/>
<mkdir dir="${build.coverage.dir}" />
<emma>
<instr instrpathref="emma.run.classpath"
destdir="${build.instrumented.dir}"
metadatafile="${build.coverage.dir}/metadata.emma"
merge="true"
/>
</emma>
</target>
<target name="test-coverage" depends="test-compile,emma" description="Run unit tests">
<property name="test.path" refid="class.path"/>
<delete dir="${test.dir}" quiet="true"/>
<mkdir dir="${test.dir}/output"/>
<mkdir dir="${test.dir}/report"/>
<copy file="${test.src.dir}/log4j-test.properties" tofile="${test.classes.dir}/log4j.properties" failonerror="false"/>
<taskdef resource="emma_ant.properties" classpathref="emma.lib"/>
<junit fork="yes" printsummary="on" failureproperty="junit.failure" tempdir="${test.dir}">
<classpath refid="emma.lib" />
<classpath location="${build.instrumented.dir}" />
<classpath refid="class.path"/>
<classpath path="${test.classes.dir}"/>
<jvmarg value="-Demma.coverage.out.file=${build.coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<formatter type="xml"/>
<batchtest todir="${test.dir}/output">
<fileset dir="${test.src.dir}">
<include name="**/*Test.java"/>
<exclude name="**/*ITest.java"/>
<exclude name="**/Abstract*Test.java"/>
<exclude name="**/RemoteMailboxContactOpsTest.java"/>
<exclude name="**/yc/**/*.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${test.dir}/report">
<fileset dir="${test.dir}/output"/>
<report todir="${test.dir}/report"/>
</junitreport>
<emma>
<report sourcepath="${src.java.dir}">
<fileset dir="${build.coverage.dir}">
<include name="*.emma" />
</fileset>
<xml outfile="${build.coverage.dir}/coverage.xml" />
</report>
</emma>
<echo>Test Report: ${test.dir}/report/index.html</echo>
<fail if="junit.failure" message="Unit test failed"/>
</target>
<target name="integration-test" depends="test-compile" description="Run integration tests">
<property name="test.path" refid="class.path"/>
<delete dir="${itest.dir}" quiet="true"/>
<mkdir dir="${itest.dir}/output"/>
<mkdir dir="${itest.dir}/report"/>
<junit printsummary="on" failureproperty="junit.failure" tempdir="${itest.dir}">
<classpath refid="class.path"/>
<classpath path="${test.classes.dir}"/>
<assertions><enable/></assertions>
<formatter type="xml"/>
<batchtest todir="${itest.dir}/output">
<fileset dir="${test.src.dir}">
<include name="**/*ITest.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${itest.dir}/report">
<fileset dir="${itest.dir}/output"/>
<report todir="${itest.dir}/report"/>
</junitreport>
<echo>Test Report: ${itest.dir}/report/index.html</echo>
<fail if="junit.failure" message="Integration test failed"/>
</target>
<target name="generate-jar-version" description="Creates the Version class that prints the version of the jarfile. This class is the Main-Class in the jarfile's manifest." depends="3rd-party-defines">
<fail unless="build.dir" />
<fail unless="build.classes.dir" />
<antcontrib:if>
<not><available file="${build.dir}/buildinfo/com/zimbra/buildinfo/Version.java"/></not>
<then>
<mkdir dir="${build.dir}/buildinfo/com/zimbra/buildinfo"/>
<echo file="${build.dir}/buildinfo/com/zimbra/buildinfo/Version.java">
package com.zimbra.buildinfo;
public class Version {
public static void main(String[] args) {
Package p = Version.class.getPackage();
System.out.println("Implementation-Title: " + p.getImplementationTitle() +
"\nImplementation-Version: " + p.getImplementationVersion() +
"\nImplementation-Vendor: " + p.getImplementationVendor() + "\n");
}
}
</echo>
</then>
</antcontrib:if>
<javac destdir="${build.classes.dir}" debug="true" target="${javac.target}" srcdir="${build.dir}/buildinfo" />
</target>
<target name="zimbra-jar" depends="generate-jar-version,set-dev-version,3rd-party-defines" description="Builds a standard jar file that prints its version info when executed. Optionally sets the Zimbra-Extension-Class attribute in the manifest if the zimbra.extension.class property is set.">
<condition property="jar.file" value="${ant.project.name}-${dev.version}.jar">
<not><isset property="jar.file"/></not>
</condition>
<fail unless="implementation.title"/>
<antcontrib:if>
<not>
<isset property="jar.build.dir"/>
</not>
<then>
<property name="jar.build.dir" value="${build.classes.dir}"/>
</then>
</antcontrib:if>
<antcontrib:if>
<not>
<isset property="excludes"/>
</not>
<then>
<property name="excludes" value=""/>
</then>
</antcontrib:if>
<antcontrib:if>
<not>
<isset property="includes"/>
</not>
<then>
<property name="includes" value=""/>
</then>
</antcontrib:if>
<echo>building jar from ${jar.build.dir}</echo>
<antcontrib:if>
<isset property="zimbra.extension.class"/>
<then>
<jar destfile="${build.dir}/${jar.file}" basedir="${jar.build.dir}" includes="${includes}" excludes="${excludes}">
<manifest>
<attribute name="Main-Class" value="com.zimbra.buildinfo.Version" />
<attribute name="Implementation-Vendor" value="Zimbra Software, LLC"/>
<attribute name="Implementation-Title" value="${implementation.title}"/>
<attribute name="Implementation-Version" value="${zimbra.buildinfo.version}"/>
<attribute name="Specification-Vendor" value="Zimbra Software, LLC"/>
<attribute name="Specification-Title" value="Zimbra Collaboration Suite"/>
<attribute name="Specification-Version" value="${zimbra.buildinfo.majorversion}.${zimbra.buildinfo.minorversion}.${zimbra.buildinfo.microversion}"/>
<attribute name="Zimbra-Extension-Class" value="${zimbra.extension.class}"/>
</manifest>
</jar>
</then>
<else>
<jar destfile="${build.dir}/${jar.file}" basedir="${jar.build.dir}" includes="${includes}" excludes="${excludes}">
<manifest>
<attribute name="Main-Class" value="com.zimbra.buildinfo.Version" />
<attribute name="Implementation-Vendor" value="Zimbra Software, LLC"/>
<attribute name="Implementation-Title" value="${implementation.title}"/>
<attribute name="Implementation-Version" value="${zimbra.buildinfo.version}"/>
<attribute name="Specification-Vendor" value="Zimbra Software, LLC"/>
<attribute name="Specification-Title" value="Zimbra Collaboration Suite"/>
<attribute name="Specification-Version" value="${zimbra.buildinfo.majorversion}.${zimbra.buildinfo.minorversion}.${zimbra.buildinfo.microversion}"/>
</manifest>
</jar>
</else>
</antcontrib:if>
</target>
<target name="clean-cache" description="Delete ivy cache">
<delete dir="${dev.home}/.ivy2/cache/zimbra/${ant.project.name}"/>
<delete dir="${dev.home}/.zcs-deps/zimbra/${ant.project.name}"/>
<delete>
<fileset dir="${dev.home}/.ivy2/cache" includes="*${ant.project.name}*"/>
</delete>
</target>
<target name="publish-local" depends="clean-cache,jar,set-dev-version,init-ivy">
<ivy:publish settingsRef="dev.settings" pubrevision="${dev.version}" resolver="local" overwrite="true" />
</target>
<target name="zmlocalconfig">
<echo>Running localconfig with with argument: ${localconfig-args}</echo>
<java classname="com.zimbra.cs.localconfig.LocalConfigCLI" fork="true" classpathref="class.path" failonerror="true">
<arg line="${localconfig-args}"/>
</java>
</target>
<target name="dist.dependencies">
<antcall target="depend.${ant.project.name}"/>
</target>
<target name="publish-foss-local">
<ant dir="${native.dir}" target="publish-local" inheritAll="false"/>
<ant dir="${common.dir}" target="publish-local" inheritAll="false"/>
<ant dir="${soap.dir}" target="publish-local" inheritAll="false"/>
<ant dir="${client.dir}" target="publish-local" inheritAll="false"/>
<ant dir="${server.dir}" target="publish-local" inheritAll="false"/>
</target>
<target name="deploy-foss">
<ant dir="${native.dir}" target="deploy-no-start" inheritAll="false"/>
<ant dir="${common.dir}" target="deploy-no-start" inheritAll="false"/>
<ant dir="${soap.dir}" target="deploy-no-start" inheritAll="false"/>
<ant dir="${client.dir}" target="deploy-no-start" inheritAll="false"/>
<ant dir="${server.dir}" target="deploy" inheritAll="false"/>
</target>
<target name="stop-webserver">
<ant dir="${server.dir}" target="stop-webserver" inheritAll="false"/>
</target>
<target name="start-webserver">
<ant dir="${server.dir}" target="start-webserver" inheritAll="false"/>
</target>
</project>