aboutsummaryrefslogtreecommitdiffstats
path: root/build/build.xml
blob: 67fe7875741433e36f866e57f68f2b0d08d0296d (plain)
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
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
<?xml version="1.0"?>

<project
         xmlns:antcontrib="antlib:net.sf.antcontrib"
         name="IT Mill Toolkit"
         basedir="../" default="package-all">

	<!-- Package creation - - - - - - - - - - - - - - - - - - - - - - - - -

	When creating release use only "package-*" targets:
	package-all
	 * creates four release packages for three three platforms (below)
	 
	package-windows
     * itmill-toolkit-windows-<version>.zip
	
	package-linux
	 * itmill-toolkit-linux-<version>.tar.bz2
	 
	package-mac
	 * itmill-toolkit-mac-<version>.tar.gz
	 * itmill-toolkit-mac-<version>.dmg

	NOTE: This build script requires directories named ${gwt-dir}/(linux|windows|mac) .
	See build.properties to define path where your gwt installation is located.
	You must unpack platform specific binaries under linux, windows and mac directories.
	${gwt-dir}/${platform} (linux|windows|mac) are used for
  	a) compile WebContent/VAADIN/widgetsets
	b) creating platform specific release ZIP/TGZ packages.
	
	NOTE FOR USING OOPHM:
	 * To build with oophm define the property platform=oophm
	   * In Eclipse this is done in External Tools Configurations -> properties
	 * If you are using windows you must use JDK 1.6 and not 1.5
	   * To enable building with JDK 1.6, define ignoreversion=1
	-->

	<!-- 
	Call one of package-* targets unless you understand what you are doing 
	-->
	<target name="package-all" depends="clean-all, package-init, init, build, docs, internal-package-mac, internal-package-windows, internal-package-linux, internal-package-war" description="Build public packages for Windows, Linux and Mac platforms.">
	</target>

	<target name="package-mac" depends="clean-result, package-init, init, build, docs, internal-package-mac" description="Create public tar.gz package for Mac.">
	</target>

	<target name="package-windows" depends="clean-result, package-init, init, build, docs, internal-package-windows" description="Create public ZIP package for Windows.">
	</target>

	<target name="package-linux" depends="clean-result, package-init, init, build, docs, internal-package-linux" description="Create public tar.bz2 package for Linux.">
	</target>

	<target name="package-oophm" depends="clean-result, package-init, init-oophm, build, docs, internal-package-oophm" description="Create public tar.gz package for OOPHM.">
	</target>

	<target name="package-jar" depends="clean-result, package-init, init, libs" description="Create itmill-toolkit-x.y.z.jar file.">
	</target>

	<target name="package-war" depends="clean-result, package-init, init, build, docs, internal-package-mac, internal-package-war">
	</target>

    <target name="package-test" depends="clean-result, nightly-init, package-init, init, build, docs, internal-package-linux, nightly-publish">
    </target>

    <!-- ant contrib required for flow control (for loop, if, property override)   -->
    <!-- Note that we have to use a namespace to avoid clash when running sub-ant. -->
    <taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml">
        <classpath>
            <pathelement location="build/lib/ant-contrib-1.0b3.jar" />
        </classpath>
    </taskdef>

	<!-- internal tests for packaging -->

	<target name="test-build" depends="clean-result, init, build" description="used for testing build.xml">
	</target>

	<target name="test-package" depends="init" description="used for testing build.xml">
		<echo>Creating package for Mac platform.</echo>
		<antcontrib:var name="package-platform" value="mac" />
		<antcontrib:var name="eclipse-launch-vmargs" value="-XstartOnFirstThread -Xms128M -Xmx512M" />
		<antcall target="add-platform-specific-files" inheritAll="true" inheritRefs="true" />
		<delete file="${result-path}/eclipse-test" followsymlinks="false" />
		<exec executable="ln" failonerror="false">
			<arg line="-s" />
			<arg line="${output-dir}" />
			<arg line="${result-path}/eclipse-test" />
		</exec>
		<!--
		<exec executable="ln" failonerror="false">
			<arg line="-s" />
			<arg line="${gwt-dir}/${package-platform}" />
			<arg line="${output-dir}/gwt" />
		</exec>
		-->
		<!--
		<antcall target="create-mac-diskimage" inheritAll="true" inheritRefs="true" />
		-->
	</target>

	<!-- Clean results - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<target name="clean-result" depends="">
		<property file="build/build.properties" />

        <!-- Clean build result directory. -->
		<delete dir="${result-path}" includes="**/*" followsymlinks="false" defaultexcludes="false" includeemptydirs="true" failonerror="false"/>
    </target>

    <!-- Clean checkout directory. -->
	<target name="clean-checkout" depends="">
		<property file="build/build.properties" />

        <delete dir="${checkout-path}" includes="**/*" followsymlinks="false" defaultexcludes="false" includeemptydirs="true" failonerror="false"/>
	</target>

	<target name="clean-all" depends="clean-result, clean-checkout">
    </target>

	<!-- Find out which platform we are in -->
	<target name="init-platform">
		<antcontrib:if>
			<contains string="${os.name}" substring="Windows" />
			<then>
				<property name="platform" value="windows" />
			</then>
		</antcontrib:if>
		<antcontrib:if>
			<equals arg1="${os.name}" arg2="Linux" />
			<then>
				<property name="platform" value="linux" />
			</then>
		</antcontrib:if>
		<antcontrib:if>
			<equals arg1="${os.name}" arg2="Mac OS X" />
			<then>
				<property name="platform" value="mac" />
			</then>
		</antcontrib:if>
	</target>

	<target name="init-oophm-platform"><property name="platform" value="oophm" /></target>
	<target name="init-oophm" depends="init-oophm-platform,init"></target>

    <!-- ================================================================== -->
    <!-- Check versions.                                                    -->
    <!-- ================================================================== -->

    <!-- Java compiler version. -->
    <target name="check-java-version">
      <condition property="java.version.matches">
        <or>
          <equals arg1="${ant.java.version}" arg2="1.5"/>
          <isset property="ignoreversion"/>
        </or>
      </condition>
      <fail unless="java.version.matches" message="Java version is ${ant.java.version}, but IT Mill Toolkit must be compiled with genuine Java 1.5 compiler. Use -Dignoreversion=1 for ant to ignore the version check."/>
      <echo>Java version is ${ant.java.version} as required.</echo>
    </target>

    <!-- Check Servlet API version. -->
    <!-- We must use Servlet API 2.3 to catch incompatibilities.. -->
    <target name="check-servlet-version">
      <available classpathref="compile.classpath" classname="javax.servlet.Servlet" property="servlet.available"/>
      <fail unless="servlet.available" message="Java Servlet API library is not available."/>
      <echo>Java Servlet API is available.</echo>

      <available classpathref="compile.classpath" classname="javax.servlet.ServletRequestListener" property="servlet.version.is-2.4"/>
      <fail if="servlet.version.is-2.4" message="Java Servlet API 2.4 or later detected. IT Mill Toolkit must be compiled exactly with Servlet API 2.3."/>
      <echo>Java Servlet API specification 2.3 used.</echo>
    </target>

    <!-- ================================================================== -->
	<!-- Initialization - - - - - - - - - - - - - - - - - - - - - - - - - - -->
    <!-- ================================================================== -->

    <!-- Called only when building installation packages. -->
	<target name="package-init">
      <!-- <property name="build.sampler.disabled" value="false"/> -->
    </target>

	<target name="init" depends="check-java-version, init-platform">

		<property file="build/build.properties" />
		<property file="build/VERSION.properties" />
		<property file="build/GWT-VERSION.properties" />
		<property file="build/html-style.properties" />

        <echo>Toolkit package is: ${toolkit-package}</echo>

		<!-- Create result dir unless already exists -->
		<mkdir dir="${result-path}" />

		<!-- required when compiling WebContent/VAADIN/widgetsets (and also Java server-side classes) -->
		<property name="lib-gwt-dev" value="gwt-dev-${platform}.jar" />

		<echo>We are on ${platform} platform (${os.name} ${os.version}), using ${gwt-dir}/${platform}/${lib-gwt-dev} (${gwt-version}).</echo>

		<!-- Destination files -->
		<property name="lib-jar-name" value="${product-file}-${version}.jar" />

		<echo message="Prepared to build ${product-file} version ${version} packages" />

		<!-- Output directory -->
		<property name="output-dir" value="${result-path}/${product-file}-${version}" />
		<mkdir dir="${output-dir}" />

		<!-- Create Output Directory Hierarchy -->
		<mkdir dir="${output-dir}/WebContent" />
		<mkdir dir="${output-dir}/WebContent/demo" />
		<mkdir dir="${output-dir}/WebContent/doc" />
		<mkdir dir="${output-dir}/WebContent/doc/manual" />
		<mkdir dir="${output-dir}/WebContent/doc/api" />
		<mkdir dir="${output-dir}/WebContent/doc/example-source" />
		<mkdir dir="${output-dir}/WebContent/WEB-INF" />
		<mkdir dir="${output-dir}/WebContent/WEB-INF/lib" />
		<mkdir dir="${output-dir}/WebContent/WEB-INF/classes" />

		<!-- Construct classpath used by java and javadoc compilation -->
		<path id="compile.classpath">
			<pathelement path="build/lib/servlet.jar" />
			<pathelement path="build/external/fileupload/classes" />
			<pathelement path="lib/reservr/gwt-maps.jar" />
			<pathelement path="lib/jetty/jetty-6.1.7.jar" />
			<pathelement path="lib/jetty/jetty-util-6.1.7.jar" />
			<pathelement path="lib/portlet/portal-kernel.jar" />
			<pathelement path="lib/portlet/portal-service.jar" />
			<pathelement path="lib/portlet/portlet.jar" />
		</path>
		<path id="compile.classpath.server-side">
            <path refid="compile.classpath"/>
			<pathelement path="${result-path}/gwt" />
		</path>
		<path id="compile.classpath.client-side">
            <path refid="compile.classpath"/>
            <pathelement path="${gwt-dir}/${platform}/gwt-user.jar" />
            <pathelement path="${gwt-dir}/${platform}/${lib-gwt-dev}" />
		</path>

	</target>

	<target name="internal-package-windows">
		<antcontrib:var name="package-platform" value="windows" />
		<echo>Creating package for ${package-platform} platform.</echo>
		<antcontrib:var name="eclipse-launch-vmargs" value="-Xms256M -Xmx512M" />
		<antcall target="add-platform-specific-files" inheritAll="true" inheritRefs="true" />
		<zip zipfile="${result-path}/${product-file}-${package-platform}-${version}.zip">
			<zipfileset prefix="${product-file}-${package-platform}-${version}" dir="${result-path}/${product-file}-${version}">
				<patternset>
					<include name="**/*" />
				</patternset>
			</zipfileset>
			<zipfileset prefix="${product-file}-${package-platform}-${version}/gwt" dir="${gwt-dir}/${package-platform}">
				<patternset>
					<include name="**/*" />
				</patternset>
			</zipfileset>
		</zip>
	</target>

	<target name="internal-package-linux">
		<antcontrib:var name="package-platform" value="linux" />
		<echo>Creating package for ${package-platform} platform.</echo>
		<antcontrib:var name="eclipse-launch-vmargs" value="-Xms256M -Xmx512M" />
		<antcall target="add-platform-specific-files" inheritAll="true" inheritRefs="true" />
		<tar destfile="${result-path}/${product-file}-${package-platform}-${version}.tar.gz" compression="gzip" longfile="gnu">
			<!-- TODO use very slow but effective bzip2
			<tar destfile="${result-path}/${product-file}-${package-platform}-${version}.tar.bz2" compression="bzip2" longfile="gnu">
		-->
			<tarfileset prefix="${product-file}-${package-platform}-${version}" dir="${result-path}/${product-file}-${version}">
				<patternset>
					<include name="**/*" />
				</patternset>
			</tarfileset>
			<tarfileset prefix="${product-file}-${package-platform}-${version}/gwt" dir="${gwt-dir}/${package-platform}">
				<patternset>
					<include name="**/*" />
				</patternset>
			</tarfileset>
		</tar>
	</target>

	<target name="internal-package-oophm">
		<antcontrib:var name="package-platform" value="oophm" />
		<echo>Creating package for ${package-platform} platform.</echo>
		<antcontrib:var name="eclipse-launch-vmargs" value="-Xms256M -Xmx512M" />
		<antcall target="add-platform-specific-files" inheritAll="true" inheritRefs="true" />
		<tar destfile="${result-path}/${product-file}-${package-platform}-${version}.tar.gz" compression="gzip" longfile="gnu">
			<tarfileset prefix="${product-file}-${package-platform}-${version}" dir="${result-path}/${product-file}-${version}">
				<patternset>
					<include name="**/*" />
				</patternset>
			</tarfileset>
			<tarfileset prefix="${product-file}-${package-platform}-${version}/gwt" dir="${gwt-dir}/${package-platform}">
				<patternset>
					<include name="**/*" />
				</patternset>
			</tarfileset>
		</tar>
	</target>

	<target name="internal-package-mac">
		<antcontrib:var name="package-platform" value="mac" />
		<echo>Creating package for ${package-platform} platform.</echo>
		<antcontrib:var name="eclipse-launch-vmargs" value="-XstartOnFirstThread -Xms256M -Xmx512M" />
		<antcall target="add-platform-specific-files" inheritAll="true" inheritRefs="true" />
		<tar destfile="${result-path}/${product-file}-${package-platform}-${version}.tar.gz" compression="gzip" longfile="gnu">
			<tarfileset prefix="${product-file}-${package-platform}-${version}" dir="${result-path}/${product-file}-${version}">
				<patternset>
					<include name="**/*" />
				</patternset>
			</tarfileset>
			<tarfileset prefix="${product-file}-${package-platform}-${version}/gwt" dir="${gwt-dir}/${package-platform}">
				<patternset>
					<include name="**/*" />
				</patternset>
			</tarfileset>
		</tar>
		<!-- TODO: remove me: DISABLE for speed -->
		<!-- <antcall target="create-mac-diskimage" inheritAll="true" inheritRefs="true" /> -->
	</target>

	<target name="internal-package-war">
		<echo>Building WAR</echo>
		<war warfile="${output-dir}/${product-file}.war">
			<fileset dir="${output-dir}/WebContent">
				<include name="**/*" />
			</fileset>
		</war>
	</target>


	<target name="create-mac-diskimage">
		<!-- create Mac disk image (dmg) also -->
		<property name="mount.dir" value="${result-path}/mac-mounted-image" />
		<mkdir dir="${mount.dir}" />
		<delete file="${result-path}/*.dmg" />
		<antcontrib:if>
			<equals arg1="${platform}" arg2="mac" />
			<then>
				<untar src="${result-path}/${product-file}-${package-platform}-${version}.tar.gz" dest="${result-path}/" compression="gzip" />
				<echo>Creating Mac disk image (dmg)</echo>
				<!-- create image -->
				<echo>hdiutil create -format UDRW -volname ${product-file}-${version} -srcfolder ${result-path}/${product-file}-${package-platform}-${version} ${result-path}/disk-image.dmg</echo>
				<exec executable="hdiutil" failonerror="true">
					<arg line="create -format UDRW -volname ${product-file}-${version} -srcfolder ${result-path}/${product-file}-${package-platform}-${version} ${result-path}/disk-image.dmg" />
				</exec>
				<!-- open image -->
				<exec executable="hdiutil" failonerror="true">
					<arg line='attach' />
					<arg line='-readwrite' />
					<arg line='-noverify' />
					<arg line='-noautoopen' />
					<arg line='-mountpoint ${mount.dir}' />
					<arg line='${result-path}/disk-image.dmg' />
				</exec>
				<!-- make sure root folder is opened when image is -->
				<exec executable="bless" failonerror="true">
					<arg line='--folder ${mount.dir}' />
					<arg line='--openfolder ${mount.dir}' />
				</exec>
				<!-- hack: wait for completion -->
				<exec executable="sleep" failonerror="true">
					<arg line='2' />
				</exec>
				<!-- here we could position items -->
				<!--
				<exec executable="osascript" failonerror="true">
					<arg line='package/positionItems.scpt ${mount.dir}' />
				</exec>
				-->
				<!-- turn on volume icon -->
				<exec executable="/Developer/Tools/SetFile" failonerror="true">
					<arg line='-a C' />
					<arg line='${mount.dir}' />
				</exec>
				<!-- set executable bit -->
				<chmod file="${mount.dir}/start.sh" perm="ugo+x" />
				<!-- close image -->
				<exec executable="hdiutil" failonerror="true">
					<arg line='detach ${mount.dir}/' />
				</exec>
				<!-- make read-only -->
				<exec executable="hdiutil" failonerror="true">
					<arg line='convert ${result-path}/disk-image.dmg' />
					<arg line='-format UDZO' />
					<arg line='-imagekey zlib-level=9' />
					<arg line='-o ${result-path}/${product-file}-${package-platform}-${version}.dmg' />
				</exec>
				<delete file="${result-path}/disk-image.dmg" />
				<!-- internet-enable -->
				<exec executable="hdiutil" failonerror="true">
					<arg line='internet-enable ${result-path}/${product-file}-${package-platform}-${version}.dmg' />
				</exec>
			</then>
		</antcontrib:if>
	</target>

	<target name="add-platform-specific-files">
		<echo>Adding platform specific files for ${package-platform}</echo>
		<delete includeemptydirs="true" defaultexcludes="false">
			<fileset dir="${output-dir}">
				<include name=".*" />
				<include name="*.launch" />
				<include name="*.txt" />
				<include name="*.bat" />
				<include name="*.sh" />
				<include name="*.app" />
				<include name="build-widgetset.xml" />
			</fileset>
		</delete>
		<copy todir="${output-dir}">
			<filterchain>
				<expandproperties />
				<replacetokens begintoken="@" endtoken="@">
					<token key="version" value="${version}" />
				</replacetokens>
				<replacetokens begintoken="@" endtoken="@">
					<token key="platform" value="${package-platform}" />
				</replacetokens>
			</filterchain>
			<fileset dir="WebContent/license">
				<include name="COPYING" />
			</fileset>
		</copy>
		<copy todir="${output-dir}/WebContent">
			<filterchain>
				<expandproperties />
				<replacetokens begintoken="@" endtoken="@">
					<token key="version" value="${version}" />
					<token key="/version" value="" />
				</replacetokens>
				<replacetokens begintoken="@" endtoken="@">
					<token key="platform" value="${package-platform}" />
					<token key="/platform" value="" />
				</replacetokens>
			</filterchain>
			<fileset dir="WebContent">
				<exclude name="**/.svn" />
				<exclude name="windoweddemos.html" />
				<include name="release-notes.html" />
				<include name="*.html" />
				<include name="license/*.html" />
				<include name="license/*.txt" />
			</fileset>
		</copy>
		<copy file="build/package/${package-platform}-readme.txt" tofile="${output-dir}/readme.txt">
			<filterchain>
				<expandproperties />
				<replacetokens begintoken="&lt;" endtoken=">">
					<token key="version" value="${version}" />
					<token key="/version" value="" />
				</replacetokens>
			</filterchain>
		</copy>
		<copy todir="${output-dir}">
			<filterchain>
				<expandproperties />
				<!-- .classpath, *.launch, build-widgetset.xml -->
				<replacetokens begintoken="&lt;" endtoken=">">
					<token key="version" value="${version}" />
					<token key="/version" value="" />
				</replacetokens>
				<!-- .classpath -->
				<replacetokens begintoken="&lt;" endtoken=">">
					<token key="platform-specific-entries" value="&lt;classpathentry kind=&quot;lib&quot; path=&quot;gwt/gwt-dev-${package-platform}.jar&quot; /&gt;" />
					<token key="/platform-specific-entries" value="" />
				</replacetokens>
				<!-- .classpath, HostedMode.launch, build-widgetset.xml -->
				<!-- We can't use XML notation for this, because it can be inside an attribute definition. -->
				<replacetokens begintoken="@" endtoken="@">
					<token key="platform" value="${package-platform}" />
				</replacetokens>
				<!-- .project, *.launch -->
				<replacetokens begintoken="&lt;" endtoken=">">
					<token key="eclipse-workspace-name" value="${eclipse-workspace-name}" />
					<token key="/eclipse-workspace-name" value="" />
				</replacetokens>
				<!-- HostedMode.launch -->
				<replacetokens begintoken="&lt;" endtoken=">">
					<token key="eclipse-launch-vmargs" value="${eclipse-launch-vmargs}" />
					<token key="/eclipse-launch-vmargs" value="" />
				</replacetokens>
			</filterchain>
			<fileset dir="build/package">
				<include name="eclipse-classpath" />
				<include name="eclipse-project" />
				<include name="eclipse*launch" />
				<include name="build-widgetset.xml" />
				<include name="eclipse-org.eclipse.core.resources.prefs" />
				<include name="eclipse-org.eclipse.jdt.core.prefs" />
			</fileset>
		</copy>
		<move file="${output-dir}/build-widgetset.xml" tofile="${output-dir}/WebContent/doc/example-source/build-widgetset.xml" />
		<move file="${output-dir}/eclipse-classpath" tofile="${output-dir}/.classpath" />
		<move file="${output-dir}/eclipse-project" tofile="${output-dir}/.project" />
		<move file="${output-dir}/eclipse-IT Mill Toolkit Hosted Mode-launch" tofile="${output-dir}/IT Mill Toolkit Hosted Mode.launch" />
		<move file="${output-dir}/eclipse-IT Mill Toolkit Web Mode-launch" tofile="${output-dir}/IT Mill Toolkit Web Mode.launch" />
		<mkdir dir="${output-dir}/.settings" />
		<move file="${output-dir}/eclipse-org.eclipse.core.resources.prefs" tofile="${output-dir}/.settings/org.eclipse.core.resources.prefs" />
		<move file="${output-dir}/eclipse-org.eclipse.jdt.core.prefs" tofile="${output-dir}/.settings/org.eclipse.jdt.core.prefs" />
		<antcontrib:if>
			<equals arg1="${package-platform}" arg2="windows" />
			<then>
				<copy todir="${output-dir}">
					<fileset dir="build/package">
						<include name="start.bat" />
					</fileset>
				</copy>
			</then>
		</antcontrib:if>
		<antcontrib:if>
			<equals arg1="${package-platform}" arg2="linux" />
			<then>
				<copy todir="${output-dir}">
					<fileset dir="build/package">
						<include name="start.sh" />
					</fileset>
				</copy>
				<chmod file="${output-dir}/start.sh" perm="ugo+x" />
				<exec executable="chmod" failonerror="false">
					<arg line="ugo+x" />
					<arg line="${output-dir}/start.sh" />
				</exec>
			</then>
		</antcontrib:if>
		<antcontrib:if>
			<equals arg1="${package-platform}" arg2="oophm" />
			<then>
				<copy todir="${output-dir}">
					<fileset dir="build/package">
						<include name="start.sh" />
					</fileset>
				</copy>
				<chmod file="${output-dir}/start.sh" perm="ugo+x" />
				<exec executable="chmod" failonerror="false">
					<arg line="ugo+x" />
					<arg line="${output-dir}/start.sh" />
				</exec>
			</then>
		</antcontrib:if>
		<antcontrib:if>
			<equals arg1="${package-platform}" arg2="mac" />
			<then>
				<copy todir="${output-dir}">
					<fileset dir="build/package">
						<include name="start.sh" />
					</fileset>
				</copy>
				<!-- must be done manually -->
				<!-- <exec executable="cp" failonerror="true">
					<arg line="-r" />
					<arg line="build/package/Start.app" />
					<arg line="${output-dir}" />
				</exec> -->
				<!-- but again, ant just fails with any * or other special characters -->
				<!-- package icon or folder background image / icon placements not in use -->
				<!--
				<exec executable="cp" failonerror="true">
					<arg line="build/package/Icon*" />
					<arg line="${output-dir}" />
				</exec>
				<exec executable="cp" failonerror="true">
					<arg line="build/package/mac-DS_Store" />
					<arg line="${output-dir}/.DS_Store" />
				</exec>
				<copy file="build/package/mac-VolumeIcon.icns" tofile="${output-dir}/.VolumeIcon.icns" />
				-->
				<chmod file="${output-dir}/start.sh" perm="ugo+x" />
				<exec executable="chmod" failonerror="false">
					<arg line="ugo+x" />
					<arg line="${output-dir}/start.sh" />
				</exec>
			</then>
		</antcontrib:if>
	</target>

	<target name="build" depends="libs, compile-client-side, demo" description="Build package required files, without packing them.">
	</target>

	<!-- Copy and preprocess sources for packaging 
	NOTE: Replaces <version></version> tags with build version tag for some "textual" files
	-->
	<target name="preprocess-src">
		<loadfile property="ITMillApache2LicenseForJavaFiles" srcFile="build/ITMillApache2LicenseForJavaFiles.txt" />
		<mkdir dir="${result-path}/src" />
		<echo>Copying src directory and processing copied files.</echo>
		<echo>Replacing &lt;version&gt; tag with build version for java/html/css/xml files.</echo>
		<copy todir="${result-path}/src">
			<filterset>
				<filter token="ITMillApache2LicenseForJavaFiles" value="${ITMillApache2LicenseForJavaFiles}" />
				<filter token="VERSION" value="${version}" />
			</filterset>
			<fileset dir="src">
				<patternset>
					<include name="**/*.java" />
					<include name="**/*.html" />
					<include name="**/*.css" />
					<include name="**/*.xml" />
					<exclude name="**/tests/**"/>
					<exclude name="**/demo/sampler/**" if="build.sampler.disabled" />
				</patternset>
			</fileset>
		</copy>

		<!-- Unify mix usage of mac/Linux/Win characters -->
		<echo>Unifying mix usage of Mac/Linux/Win linefeeds for java/html/css/xml files.</echo>
		<fixcrlf srcdir="${result-path}/src" eol="crlf" tablength="4" tab="asis" includes="**/*.java **/*.html **/*.css **/*.xml" />

		<!-- Add other files such as images, these are not filtered or processed by fixcrlf task -->
		<echo>Copying non java/html/css/xml files such as images.</echo>
		<copy todir="${result-path}/src">
			<fileset dir="src">
				<patternset>
					<exclude name="**/.svn" />
					<exclude name="**/*.java" />
					<exclude name="**/*.html" />
					<exclude name="**/*.css" />
					<exclude name="**/*.xml" />
					<exclude name="**/tests/**"/>
					<exclude name="**/demo/sampler/**" if="build.sampler.disabled" />
				</patternset>
			</fileset>
		</copy>

	</target>

	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  WebContent
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<target name="webcontent" depends="preprocess-src,defaulttheme">

		<!-- copy 3rd part libraries used by demo -->
		<copy todir="${output-dir}/WebContent/demo/lib">
			<fileset dir="lib">
				<include name="reservr/**/*" />
			</fileset>
		</copy>
		<copy todir="${output-dir}/WebContent/demo/lib">
			<fileset dir="lib">
				<include name="jetty/**/*" />
			</fileset>
		</copy>
		<copy todir="${output-dir}/WebContent/demo/lib">
			<fileset dir="lib">
				<include name="portlet/**/*" />
			</fileset>
		</copy>

		<!-- Add demo sources -->
		<echo>Adding demo sources to WebContent/WEB-INF/src</echo>
		<copy todir="${output-dir}/WebContent/WEB-INF/src">
			<fileset dir="${result-path}/src">
				<include name="${toolkit-package}/demo/**/*" />
				<exclude name="${toolkit-package}/demo/sampler/**" if="build.sampler.disabled" />
			</fileset>
		</copy>

		<echo>Creating demo source html files</echo>
		<java2html srcdir="${output-dir}/WebContent/WEB-INF/src/${toolkit-package}/demo" destdir="${output-dir}/WebContent/doc/example-source/${toolkit-package}/demo" includes="**/*.java" style="eclipse" showLineNumbers="false" showFileName="true" showTableBorder="false" />

		<!-- Add WebContent -->
		<echo>Adding VAADIN/themes, demo and hsqldb.jar files.</echo>
		<copy todir="${output-dir}/WebContent">
			<fileset dir="WebContent">
				<exclude name="**/.svn" />
				<!-- TODO check what is neccessary -->
				<exclude name="VAADIN/themes/tests*" />
				<exclude name="VAADIN/themes/tests-magi/**/*" />
				<exclude name="VAADIN/themes/tests-featurebrowser/**/*" />
				<exclude name="VAADIN/themes/tests*/**/*" />
				<exclude name="VAADIN/themes/sampler/**" if="build.sampler.disabled" />
				<include name="demo/**/*" />
				<include name="WEB-INF/lib/hsqldb.jar" />
				<include name="VAADIN/themes/**/*" />
				<include name="META-INF/**/*" />
			</fileset>
		</copy>

		<!-- Add package specific WebContent files from build/package/WebContent -->
		<copy todir="${output-dir}/WebContent">
			<fileset dir="build/package/WebContent">
				<exclude name="**/.*" />
				<include name="**/*" />
			</fileset>
		</copy>
		<java classname="com.vaadin.buildhelpers.PortletConfigurationGenerator" failonerror="yes" fork="yes" maxmemory="512m">
			<arg value="${output-dir}/WebContent/WEB-INF" />
			<arg value="com.vaadin.demo.sampler.gwt.SamplerWidgetSet" />
			<classpath>
				<pathelement location="build/buildhelpers/" />
			</classpath>
		</java>
	</target>

	<target name="compile-fileupload">
		<echo>Compiling custom fileupload classes.</echo>
		<ant dir="build/external/fileupload" antfile="build.xml" target="compile" />
	</target>

	<target name="unpack-gwt" depends="init">
        <!-- Unpack GWT from JARs. This is needed for excluding Servlet API 2.4. -->
		<delete dir="${result-path}/gwt"/>
        <unjar src="${gwt-dir}/${platform}/gwt-user.jar" dest="${result-path}/gwt/"/>
        <unjar src="${gwt-dir}/${platform}/${lib-gwt-dev}" dest="${result-path}/gwt/"/>
		<delete dir="${result-path}/gwt/javax/servlet"/>
    </target>

	<target name="compile-java" depends="init, unpack-gwt, check-servlet-version, compile-fileupload, webcontent">
		<echo>Compiling src (server-side)</echo>
		<!-- Compile -->
		<mkdir dir="${result-path}/classes" />
		<javac source="1.5" target="1.5" classpathref="compile.classpath.server-side" destdir="${result-path}/classes" debug="true" encoding="UTF-8">
             <src path="${result-path}/src"/>
             <!-- This seems to be included by default: include name="${toolkit-package}/**"/ -->
             <exclude name="${toolkit-package}/demo/sampler/**" if="build.sampler.disabled" />
             <exclude name="${toolkit-package}/tests/**"/>
		</javac>
	</target>

	<target name="defaulttheme">
		<echo>Combining default themes css files</echo>
		<!-- ensure buildhelpers are compiled -->
		<javac source="1.5" target="1.5" srcdir="build/buildhelpers" />
		<java classname="com.vaadin.buildhelpers.CompileDefaultTheme" failonerror="yes" fork="yes">
			<classpath>
				<pathelement location="build/buildhelpers" />
			</classpath>
		</java>
	</target>

	<target name="testtarget">
		<echo>TEST TARGET CALLED</echo>
	</target>

	<target name="remove-widgetset-gwt-tmp">
		<echo>Removing widgetset temp files</echo>
		<delete dir="${output-dir}/WebContent/VAADIN/widgetsets/.gwt-tmp" includeemptydirs="true"/>
	</target>

	<target name="compile-widgetset-default">
		<echo>Compiling src (client-side)</echo>
		<echo>com.vaadin.terminal.gwt.DefaultWidgetSet</echo>
		<java classname="com.google.gwt.dev.GWTCompiler" failonerror="yes" fork="yes" maxmemory="512m">
			<arg value="-out" />
			<arg value="${output-dir}/WebContent/VAADIN/widgetsets" />
			<arg value="com.vaadin.terminal.gwt.DefaultWidgetSet" />
			<arg value="-style" />
			<arg value="OBF" />
            <jvmarg value="-Xss8M"/>
            <jvmarg value="-Djava.awt.headless=true"/>
			<classpath>
				<pathelement location="${gwt-dir}/${platform}/gwt-user.jar" />
				<pathelement location="${gwt-dir}/${platform}/${lib-gwt-dev}" />
				<pathelement location="${result-path}/src" />
			</classpath>
		</java>
		<antcall target="remove-widgetset-gwt-tmp"/>
		<echo>Compiled DefaultWidgetSet</echo>
	</target>

	<target name="compile-widgetset-reserver">
		<condition property="googlemaps-jar" value="${output-dir}/WebContent/demo/lib/reservr/gwt-maps.jar">
			<available file="${output-dir}/WebContent/demo/lib/reservr/gwt-maps.jar" />
		</condition>
		<condition property="googlemaps-jar" value="lib/reservr/gwt-maps.jar">
			<available file="lib/reservr/gwt-maps.jar" />
		</condition>
		<echo>com.vaadin.demo.reservation.gwt.ReservationWidgetSet</echo>
		<java classname="com.google.gwt.dev.GWTCompiler" failonerror="yes" fork="yes" maxmemory="512m">
			<arg value="-out" />
			<arg value="${output-dir}/WebContent/VAADIN/widgetsets" />
			<arg value="com.vaadin.demo.reservation.gwt.ReservationWidgetSet" />
			<arg value="-style" />
			<arg value="OBF" />
            <jvmarg value="-Xss8M"/>
            <jvmarg value="-Djava.awt.headless=true"/>
			<classpath>
				<pathelement location="${gwt-dir}/${platform}/gwt-user.jar" />
				<pathelement location="${gwt-dir}/${platform}/${lib-gwt-dev}" />
				<pathelement location="${result-path}/src" />
				<!-- demo jars -->
				<pathelement location="${googlemaps-jar}" />
				<!-- demo widgetset sources -->
				<pathelement path="${output-dir}/WebContent/WEB-INF/src" />
			</classpath>
		</java>
		<antcall target="remove-widgetset-gwt-tmp"/>
		<echo>Compiled ReservationWidgetSet</echo>
	</target>

    <!-- Building Sampler for installation package is disabled. -->
	<target name="compile-widgetset-sampler" unless="build.sampler.disabled">
		<echo>com.vaadin.demo.sampler.gwt.SamplerWidgetSet</echo>
		<java classname="com.google.gwt.dev.GWTCompiler" failonerror="yes" fork="yes" maxmemory="512m">
			<arg value="-out" />
			<arg value="${output-dir}/WebContent/VAADIN/widgetsets" />
			<arg value="com.vaadin.demo.sampler.gwt.SamplerWidgetSet" />
			<arg value="-style" />
			<arg value="OBF" />
            <jvmarg value="-Xss8M"/>
            <jvmarg value="-Djava.awt.headless=true"/>
			<classpath>
				<pathelement location="${gwt-dir}/${platform}/gwt-user.jar" />
				<pathelement location="${gwt-dir}/${platform}/${lib-gwt-dev}" />
				<pathelement location="${result-path}/src" />
				<!-- demo widgetset sources -->
				<pathelement path="${output-dir}/WebContent/WEB-INF/src" />
			</classpath>
		</java>
		<antcall target="remove-widgetset-gwt-tmp"/>
		<echo>Compiled SamplerWidgetSet</echo>
	</target>
	
	<target name="compile-widgetset-coverflow">
		<echo>com.vaadin.demo.coverflow.gwt.CoverflowWidgetSet</echo>
		<java classname="com.google.gwt.dev.GWTCompiler" failonerror="yes" fork="yes" maxmemory="512m">
			<arg value="-out" />
			<arg value="${output-dir}/WebContent/VAADIN/widgetsets" />
			<arg value="com.vaadin.demo.coverflow.gwt.CoverflowWidgetSet" />
			<arg value="-style" />
			<arg value="OBF" />
            <jvmarg value="-Xss8M"/>
            <jvmarg value="-Djava.awt.headless=true"/>
			<classpath>
				<pathelement location="${gwt-dir}/${platform}/gwt-user.jar" />
				<pathelement location="${gwt-dir}/${platform}/${lib-gwt-dev}" />
				<pathelement location="${result-path}/src" />
				<!-- demo widgetset sources -->
				<pathelement path="${output-dir}/WebContent/WEB-INF/src" />
			</classpath>
		</java>
		<antcall target="remove-widgetset-gwt-tmp"/>
		<echo>Compiled CoverflowWidgetSet</echo>
	</target>
	
	<target name="compile-widgetset-colorpicker">
		<echo>com.vaadin.demo.colorpicker.gwt.ColorPickerWidgetSet</echo>
		<java classname="com.google.gwt.dev.GWTCompiler" failonerror="yes" fork="yes" maxmemory="512m">
			<arg value="-out" />
			<arg value="${output-dir}/WebContent/VAADIN/widgetsets" />
			<arg value="com.vaadin.demo.colorpicker.gwt.ColorPickerWidgetSet" />
			<arg value="-style" />
			<arg value="OBF" />
            <jvmarg value="-Xss8M"/>
            <jvmarg value="-Djava.awt.headless=true"/>
			<classpath>
				<pathelement location="${gwt-dir}/${platform}/gwt-user.jar" />
				<pathelement location="${gwt-dir}/${platform}/${lib-gwt-dev}" />
				<pathelement location="${result-path}/src" />
				<!-- demo widgetset sources -->
				<pathelement path="${output-dir}/WebContent/WEB-INF/src" />
			</classpath>
		</java>
		<antcall target="remove-widgetset-gwt-tmp"/>
		<echo>Compiled ColorPickerWidgetSet</echo>
	</target>

	<!-- Builds the client-side engine, i.e., the widgetsets. -->
	<target name="compile-client-side" depends="compile-widgetset-default, compile-widgetset-reserver, compile-widgetset-sampler, compile-widgetset-colorpicker, compile-widgetset-coverflow">
        <!-- Building the widgetsets is currently done sequentially, because
            parallel compilation takes too much memory for most machines. -->
	</target>

	<!-- Definitions for building local components, i.e., not for an installation package. -->
	<target name="init-nonpackage" depends="init-platform">
		<property file="build/VERSION.properties" />
		<property file="build/GWT-VERSION.properties" />

		<!-- Definitions for building the client-side. -->
		<property name="output-dir" value="." />

		<!-- The "result-path" simply contains the sources. -->
		<property name="result-path" value="." />

		<!-- Path to GWT directory. TODO: This should be read from build.properties file. -->
		<property name="gwt-dir" value="build/gwt" />

		<!-- required when compiling WebContent/VAADIN/widgetsets (and also Java server-side classes) -->
		<property name="lib-gwt-dev" value="gwt-dev-${platform}.jar" />

		<echo>We are on ${platform} platform, using ${gwt-dir}/${platform}/${lib-gwt-dev}.</echo>
		<echo>GWT dir:    ${gwt-dir}</echo>
		<echo>Output dir: ${output-dir}</echo>
	</target>

	<!-- Builds all widgetsets locally, i.e., not for an installation package. -->
	<target name="widgetsets" depends="init-nonpackage, compile-client-side">
	</target>

	<!-- Builds the default widgetset locally, i.e., not for an installation package. -->
	<target name="widgetset-default" depends="init-nonpackage, compile-widgetset-default">
	</target>

	<!-- Builds the sampler widgetset locally, i.e., not for an installation package. -->
	<target name="widgetset-sampler" depends="init-nonpackage, compile-widgetset-sampler">
	</target>
	
	<!-- Builds the coverflow widgetset locally, i.e., not for an installation package. -->
	<target name="widgetset-coverflow" depends="init-nonpackage, compile-widgetset-coverflow">
	</target>
	
	<!-- Builds the reservation widgetset locally, i.e., not for an installation package. -->
	<target name="widgetset-reserver" depends="init-nonpackage, compile-widgetset-reserver">
	</target>

	<!-- Builds the colorpicker widgetset locally, i.e., not for an installation package. -->
	<target name="widgetset-colorpicker" depends="init-nonpackage, compile-widgetset-colorpicker">
	</target>

    <!-- Compile the Toolkit library JAR.          -->
    <!-- Only need the default widgetset for this. -->
	<target name="libs" depends="compile-java, webcontent, compile-widgetset-default">
		<echo>Creating libs (server-side) ${lib-jar-name}</echo>
		<!-- Create Toolkit JAR -->
		<mkdir dir="${output-dir}/META-INF"/>
		<echo file="${output-dir}/META-INF/VERSION">${version}</echo> 
		<echo file="${output-dir}/META-INF/GWT-VERSION">${gwt-version}</echo> 
		
		<jar jarfile="${output-dir}/WebContent/WEB-INF/lib/${lib-jar-name}" compress="true">
			<metainf dir="${output-dir}/META-INF"/>
			
			<fileset dir="${result-path}/classes">
				<patternset>
					<exclude name="${toolkit-package}/demo/**" />
					<exclude name="${toolkit-package}/tests/**" />
					<exclude name="${toolkit-package}/launcher/**" />
				</patternset>
			</fileset>
			<!-- fileupload, see build/external/fileupload/build.xml -->
			<fileset dir="build/external/fileupload/classes">
				<include name="**/*" />
			</fileset>
			<!-- add sources -->
			<fileset dir="${result-path}/src">
				<patternset>
					<exclude name="${toolkit-package}/demo/**" />
					<exclude name="${toolkit-package}/tests/**" />
					<exclude name="${toolkit-package}/launcher/**" />
				</patternset>
			</fileset>
			<fileset dir="${output-dir}/WebContent">
				<patternset>
					<include name="VAADIN/widgetsets/com.vaadin.terminal.gwt.DefaultWidgetSet/**/*" />
					<include name="VAADIN/themes/default/**/*" />
				</patternset>
			</fileset>
		</jar>
		<copy file="${output-dir}/WebContent/WEB-INF/lib/${lib-jar-name}" tofile="${output-dir}/WebContent/${lib-jar-name}" />
	</target>

	<!-- Demo  - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<target name="demo" depends="libs, docs">
		<echo>Building demo</echo>
		<echo>Adding demo class files.</echo>
		<copy todir="${output-dir}/WebContent/WEB-INF/classes">
			<fileset dir="${result-path}/classes">
				<include name="${toolkit-package}/demo/**/*" />
				<!-- user might want to tweak launcher classes -->
				<include name="${toolkit-package}/launcher/**" />
			</fileset>
		</copy>

		<echo>Adding source for demo</echo>
		<copy todir="${output-dir}/WebContent/WEB-INF/src">
			<fileset dir="${result-path}/src">
				<include name="${toolkit-package}/demo/**/*" />
				<!-- user might want to tweak launcher classes -->
				<include name="${toolkit-package}/launcher/**" />
			</fileset>
		</copy>
	</target>

    <!-- ================================================================== -->
    <!-- Documentation                                                      -->
    <!-- ================================================================== -->
	<target name="docs" depends="init, manual">
	</target>

	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
    <!-- Manual: Build from external repository.                            -->
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->

    <target name="manual-init">
		<!-- Can run XEP only if license is available. -->
		<available file="build/lib/XEP/license.xml" property="xep.license.available" />

        <!-- Path to installed XEP license. -->
        <property name="xep.license.path.installed" value="/opt/RenderX/XEP/license.xml"/>
        <echo>XEP license expected to be installed as ${xep.license.path.installed}</echo>

		<!-- Can copy XEP license only if it is available. -->
		<available file="${xep.license.path.installed}" property="xep.license.installed"/>
    </target>

    <!-- Checkout doc repository. -->
    <target name="manual-checkout" unless="docdir">
        <mkdir dir="${checkout-path}"/>

        <exec executable="svn" dir="${checkout-path}">
            <arg value="checkout"/>
            <arg value="http://dev.itmill.com/svn/doc/trunk"/>
            <arg value="doc"/>
        </exec>

        <property name="docdir" value="${checkout-path}/doc"/>
    </target>

    <!-- If the XEP is installed, copy it to proper place. -->
    <target name="xep-license-copy" if="xep.license.installed">
        <copy file="${xep.license.path.installed}" todir="${docdir}/build/lib/XEP"/>
    </target>

    <!-- Build manual. -->
    <target name="manual-build" depends="xep-license-copy">
      <ant dir="${docdir}" antfile="build/build.xml" inheritAll="false">
          <property name="version" value="${version}"/>
      </ant>
    </target>

    <!-- Copy the manual from sub Ant results to our output directory. -->
    <target name="manual-copy" depends="init, manual-checkout">
		<copy todir="${output-dir}/WebContent/doc">
            <fileset dir="${docdir}/build/result/package/WebContent/doc">
				<exclude name="**/.svn" />
				<include name="manual/**" />
				<include name="manual.pdf" />
            </fileset>
        </copy>
    </target>

	<target name="manual" depends="init, manual-init, manual-checkout, manual-build, manual-copy">
    </target>        

	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
    <!-- Documentation: Add documentation including style files             -->
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
	<target name="package-docs">
		<copy todir="${output-dir}/WebContent/doc/manual/html-style">
			<fileset dir="doc/manual/html-style">
				<exclude name="**/.svn" />
				<exclude name="**/test.html" />
			</fileset>
		</copy>
		<copy todir="${output-dir}/WebContent/doc">
			<fileset dir="doc">
				<exclude name="**/.svn" />
				<include name="dtd/**/*.dtd" />
			</fileset>
		</copy>
	</target>

	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
    <!-- Documentation: Add Javadoc to doc                                  -->
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  -->
	<target name="javadoc" depends="preprocess-src">
		<javadoc destdir="${output-dir}/WebContent/doc/api" author="true" version="true" use="true" windowtitle="${product-name}" classpathref="compile.classpath.client-side">
			<packageset dir="${result-path}/src">
				<include name="${toolkit-package}/**" />
				<exclude name="${toolkit-package}/demo/**" />
				<exclude name="${toolkit-package}/tests/**" />
				<exclude name="${toolkit-package}/automatedtests/**" />
			</packageset>
			<doctitle>${javadoc.doctitle}</doctitle>
			<!-- <header><![CDATA[<script type="text/javascript" src=".html-style/style.js"></script>]]></header> -->
			<bottom>${javadoc.bottom}</bottom>
			<link offline="true" href="http://java.sun.com/j2se/1.5.0/docs/api/" packagelistLoc="build/javadoc/j2se-1.5.0" />
			<link offline="true" href="http://java.sun.com/j2ee/1.4/docs/api/" packagelistLoc="build/javadoc/j2ee-1.4" />
		</javadoc>
	</target>

	<!-- java2html converter -->
	<taskdef name="java2html" classname="de.java2html.anttasks.Java2HtmlTask" classpath="build/lib/java2html.jar" />

    <!-- ================================================================== -->
    <!-- Nightly build.                                                     -->
    <!-- ================================================================== -->

    <!-- Main target for the nightly build. -->
    <target name="nightly" depends="clean-result, nightly-init, package-init, init, build, internal-package-linux">
    </target>

    <!-- Create symlink to GWT installation directory. -->
    <target name="gwt-symlink">

        <!-- Optional property. -->
        <property name="gwt.link.target" value="../../gwt-1.5"/>

        <!-- Remove the old link, as the link target may have changed. -->
        <exec executable="rm" dir="build" searchpath="true" failonerror="false">
            <arg value="gwt"/>
        </exec>

        <echo>Creating symlink to GWT installation directory.</echo>
        <exec executable="ln" dir="build" searchpath="true" failonerror="true">
            <arg value="-s"/> <!-- Symlink.   -->
            <arg value="-f"/> <!-- Overwrite. -->
            <arg value="${gwt.link.target}"/>
            <arg value="gwt"/>
        </exec>
    </target>

    <!-- Initialize a nightly build. -->
    <target name="nightly-init" depends="gwt-symlink">

        <!-- Mandatory parameters. -->
        <fail unless="version.minor" message="The version.minor property must be defined."/>
        <fail unless="build.number" message="The build.number property must be defined."/>
        <fail unless="nightly.publish" message="The nightly.publish property must be defined."/>

        <!-- Optional parameters. -->
        <property name="build.tag" value="dev"/>

        <echo>Minor version: ${version.minor}</echo>
        <echo>Build number: ${build.number}</echo>
        <echo>Build tag: ${build.tag}</echo>
        <echo>Publish target: ${nightly.publish}</echo>

        <!-- Set build number. -->
        <tstamp>
            <format property="nightly.date" pattern="yyyyMMdd"/>
        </tstamp>
        <property name="version" value="${version.minor}.${build.tag}-${nightly.date}-c${build.number}"/>
        <echo>Version will be: ${version}</echo>

        <!-- Tell TeamCity the build name. Have to do it this way, because   -->
        <!-- this script needs to get the plain build number as a parameter. -->
        <echo>##teamcity[buildNumber '${version.minor}-c${build.number}']</echo>

    </target>

    <target name="nightly-teamcity-publish">
        <!-- Publish as a TeamCity artifact. -->
        <echo>##teamcity[publishArtifacts '${output-dir}/WebContent/WEB-INF/lib/${lib-jar-name}']</echo>
    </target>

    <!-- Copies the nightly build artifacts to the download server. -->
    <target name="nightly-download-publish" if="nightly.publish">
        <!-- Publish to the download server. -->
        <echo>Installing ${output-dir}/WebContent/${lib-jar-name} to ${nightly.publish}</echo>
        <echo>Hopefully you have permissions for the copy operation with SSH.</echo>

        <!-- Only Linux tests allowed. TODO: Generalize this. -->
        <property name="package.linux.filename" value="${result-path}/${product-file}-${package-platform}-${version}.tar.gz"/>

        <!-- Copy the linux installation package and the JAR. -->
        <exec executable="scp" searchpath="true" resultproperty="nightly.install.scp.result">
            <arg value="-B"/>
            <arg value="${output-dir}/WebContent/${lib-jar-name}"/>
            <arg value="${package.linux.filename}"/>
            <arg value="${nightly.publish}"/>
        </exec>

        <echo>Result: ${nightly.install.scp.result}</echo>
    </target>

    <target name="nightly-publish" depends="nightly-teamcity-publish, nightly-download-publish">
    </target>

    <!-- ================================================================== -->
    <!-- Automated tests.                                                   -->
    <!-- ================================================================== -->

    <target name="tests" depends="ant-tests, testingtools-tests">
    </target>

    <target name="testingtools-tests" depends="init">
      <fail unless="product-file" message="The 'product-file' property must be defined."/>
      <fail unless="package-platform" message="The 'package-platform' property must be defined."/>
      <fail unless="version" message="The 'version' property must be defined."/>

      <!-- Parameters for the test.xml script. -->
      <fail unless="com.vaadin.testingtools.tester.host" message="The 'com.vaadin.testingtools.tester.host' property must be defined."/>
      <fail unless="com.vaadin.testingtools.deployment.url" message="The 'com.vaadin.testingtools.deployment.url' property must be defined."/>

      <property name="package.platform.name" value="${product-file}-${package-platform}-${version}"/>

      <!-- Only Linux tests allowed. TODO: Generalize this. -->
      <property name="package.linux.filename" value="${result-path}/${package.platform.name}.tar.gz"/>

      <!-- Run the separate test script. -->
      <ant antfile="tests/test.xml" target="test-package" inheritall="false" inheritrefs="true">
          <property name="package.filename" value="${package.linux.filename}"/>
          <property name="testing.testarea" value="/tmp/testarea"/>
          <property name="package.name" value="${package.platform.name}"/>
          <property name="com.vaadin.testingtools.tester.host" value="${com.vaadin.testingtools.tester.host}"/>
          <property name="com.vaadin.testingtools.deployment.url" value="${com.vaadin.testingtools.deployment.url}"/>
      </ant>
    </target>

    <target name="ant-tests">
        <echo>##teamcity[testSuiteStarted name='com.vaadin.tests.test-framework']</echo>

        <!-- A smoke test for testing the testing framework. -->
        <echo>##teamcity[testStarted name='testingSmoketest']</echo>
        <echo>##teamcity[testStdOut name='testingSmoketest' out='Here be some text related to the test.]</echo>
        <echo>##teamcity[testFinished name='testingSmoketest']</echo>

        <echo>##teamcity[testSuiteFinished name='com.vaadin.tests.test-framework']</echo>
    </target>
</project>