forked from ozoneplatform/owf-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
739 lines (645 loc) · 35 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
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
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="owf-server" default="bundle" basedir=".">
<property file="${basedir}/application.properties" />
<import file="build-base.xml" optional="true"/>
<property name="lib.dir" value="${basedir}/lib" />
<property name="work.dir" value="${basedir}/work" />
<property name="jstoolkit.dir" value="${work.dir}/jsdoc/jsdoc_toolkit-2.3.2/jsdoc-toolkit" />
<property name="staging.dir" value="staging" />
<property name="tomcat.dir" value="${staging.dir}/apache-tomcat-${tomcat.ver}" />
<property name="build.base.dir" value="${basedir}" />
<property name="widget.samples.dir" value="${basedir}/sample-widgets" />
<property name="temp.dir" value="${basedir}/temp" />
<condition property="offline.arg" value="-DOFFLINE_REPO=${offline_repo}" else="" >
<isset property="offline_repo" />
</condition>
<condition property="no-test" value="true" >
<isset property="disconnected" />
</condition>
<condition property="owf.doc.extension" value="pdf" else="*" >
<istrue value="${owf.release}" />
</condition>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${ant.lib.dir}/ant-contrib-1.0b3.jar" />
<target name="_init-ivy" >
<antcall target="init-ivy" />
</target>
<condition property="isWindows">
<os family="windows" />
</condition>
<!--available file="${owf.build.module}-${owf.build.rev}/build-base.xml" property="build-base.available" /-->
<target name="init-build" >
<ant dir="." target="init-ivy" inheritall="false" />
</target>
<!-- =================================
target: resolve
================================= -->
<target name="-resolve" description="--> Retrieve dependencies with ivy" depends="_init-ivy">
<ivy:settings file="${build.base.dir}/${ivysettings.file}" id='ivy.settings' />
<ivy:resolve settingsRef='ivy.settings'/>
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]" conf="compressjs" settingsRef='ivy.settings'/>
<mkdir dir="${work.dir}" />
<ivy:retrieve pattern="${work.dir}/[conf]/[artifact]-[revision].[ext]" conf="jsdoc" settingsRef='ivy.settings'/>
</target>
<target name="buildInfo" unless="build.number" >
<buildnumber/>
</target>
<target name="-init" depends="-resolve,buildInfo">
<mkdir dir="${staging.dir}" />
<path id="compressor.classpath">
<fileset dir="${lib.dir}/compressjs" includes="*.jar" />
</path>
<tstamp/>
<taskdef name="yuicompress" classname="owf.ant.YUICompressTask" classpathref="compressor.classpath" />
<taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit">
<classpath>
<pathelement path="${work.dir}/jsdoc/jsdoctoolkit-ant-task-1.0.jar" />
<pathelement path="${work.dir}/jsdoc/js-1.7R1.jar" />
<pathelement path="${jstoolkit.dir}/java/classes/js.jar" />
<pathelement path="${jstoolkit.dir}/jsrun.jar" />
</classpath>
</taskdef>
<available file="${work.dir}/jsdoc/jsdoc-dist-2.3.2" property="jstoolkit.available" />
<ivy:info file="ivy.xml" />
</target>
<target name="zip-widgets">
<ant antfile="build.xml" dir="sample-widgets/" target="zip-widgets"/>
</target>
<target name="war-widgets">
<ant antfile="build.xml" dir="sample-widgets/" target="war"/>
</target>
<target name="unzip-jstoolkit" unless="jstoolkit.available">
<unzip src="${work.dir}/jsdoc/jsdoc-dist-2.3.2.zip" dest="${work.dir}/jsdoc" />
</target>
<target name="jsdoc" depends="-init,unzip-jstoolkit" unless="no-jsdoc">
<jsdoctoolkit jsdochome="${jstoolkit.dir}/" template="jsdoc" outputdir="${basedir}/src/assemble/docs/jsdoc" extensions="js" depth="3">
<fileset dir="${basedir}/web-app/js/util">
<include name="*.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/lang">
<include name="*.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/eventing">
<include name="*.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/pref">
<include name="*.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/layout">
<include name="*.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/launcher">
<include name="*.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/dd">
<include name="*.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/components">
<include name="AdminBanner.js" />
<include name="Banner.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/chrome">
<include name="WidgetChrome.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/state">
<include name="WidgetState.js" />
<include name="WidgetStateHandler.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/metrics">
<include name="BaseMetrics.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/widget">
<include name="*.js" />
</fileset>
<fileset dir="${basedir}/web-app/js/intents">
<include name="WidgetIntents.js" />
</fileset>
</jsdoctoolkit>
</target>
<target name="about" depends="-init">
<copy file="src/resources/about.properties" todir="web-app/WEB-INF/classes">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>
<target name="compress_js" description="--> yui compression of owf javascript files">
<grails script="createBundles" />
</target>
<target name="deps-report" depends="-resolve" description="--> Generate report of module dependencies.">
<ivy:report conf="*" />
</target>
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> Cleans a Grails application">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${basedir}/web-app/js-min" >
</fileset>
</delete>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${staging.dir}" >
</fileset>
</delete>
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${basedir}/target" >
</fileset>
</delete>
<grails script="clean" preargs="${offline.arg}" />
</target>
<target name="compile-themes">
<!-- Note that this only compiles themes that are in the war. It does not
compile themes that are in the external themes directory. That will
need to be done manually. (By default there are no external themes) -->
<uptodate property="compile-themes-in-war.uptodate" >
<srcfiles dir="${basedir}/web-app/themes" excludes="**/images/**,**/css/**,**/.sass-cache/**" />
<!-- Look for any source file that is newer than any css file. TODO: make this
so that we do not need to hard-code the theme names -->
<compositemapper>
<mergemapper to="${basedir}/web-app/themes/a_default.theme/css/a_default.css" />
<mergemapper to="${basedir}/web-app/themes/accessibility-bow.theme/css/accessibility-bow.css" />
<mergemapper to="${basedir}/web-app/themes/accessibility-wob.theme/css/accessibility-wob.css" />
<mergemapper to="${basedir}/web-app/themes/large-text.theme/css/large-text.css" />
</compositemapper>
</uptodate>
<antcall target="_compile-themes-in-war" />
<!-- make sure sass-cache folders are deleted -->
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${basedir}/web-app/themes" >
<include name="**/.sass-cache/**"/>
</fileset>
</delete>
</target>
<!-- Only recompile if compile-themes.uptodate is not set.
This prevents compilation from happening mulitple times
per build -->
<target name="_compile-themes-in-war" unless="compile-themes-in-war.uptodate">
<exec executable="cmd" dir="${basedir}/web-app/themes" failonerror="true" osfamily="windows">
<arg value="/c" />
<arg value="compile_all_themes.bat" />
<arg value="--force" />
</exec>
<exec executable="sh" dir="${basedir}/web-app/themes" failonerror="true" osfamily="unix">
<arg value="compile_all_themes.sh" />
<arg value="--force" />
</exec>
</target>
<target name="stage-samples" depends="zip-widgets" >
<mkdir dir="${staging.dir}/samples" />
<copy file="${widget.samples.dir}/dotnet-widget/dotnet-widget.zip" todir="${staging.dir}/samples" />
<copy file="${widget.samples.dir}/flex-widget/flex-widget.zip" todir="${staging.dir}/samples" />
<copy file="${widget.samples.dir}/flex-channel-listener/flex-channel-listener.zip" todir="${staging.dir}/samples" />
<copy file="${widget.samples.dir}/flex-channel-shouter/flex-channel-shouter.zip" todir="${staging.dir}/samples" />
<copy file="${widget.samples.dir}/gwt-widget/gwt-widget.zip" todir="${staging.dir}/samples" />
<copy file="${widget.samples.dir}/html-widgets/html-widget.zip" todir="${staging.dir}/samples" />
<copy file="${widget.samples.dir}/java-applet-widget/java-applet-widget.zip" todir="${staging.dir}/samples" />
<copy file="${widget.samples.dir}/silverlight-widget/silverlight-widget.zip" todir="${staging.dir}/samples" />
</target>
<target name="stage-extras" depends="compile-themes">
<mkdir dir="${tomcat.dir}" />
<mkdir dir="${staging.dir}/etc/override" />
<mkdir dir="${staging.dir}/owf-security" />
<mkdir dir="${staging.dir}/etc/tools" />
<ant antfile="build.xml" dir="${basedir}/tools/TestDbConversion"/>
<zip destfile="${basedir}/tools/dbvalidation.zip" >
<zipfileset dir="${basedir}/tools/TestDbConversion/target" includes="**/*" filemode="744" />
</zip>
<copy todir="${staging.dir}/etc/tools" includeEmptyDirs="false">
<fileset dir="tools">
<include name="*" />
</fileset>
</copy>
<delete dir="${basedir}/tools/TestDbConversion/target" />
<delete file="${basedir}/tools/dbvalidation.zip" />
<mkdir dir="${staging.dir}/etc/widget" />
<mkdir dir="${staging.dir}/etc/widget/js" />
<copy todir="${staging.dir}/etc/widget/js">
<fileset dir="web-app/js-min">
<include name="owf-widget-debug.js" />
<include name="owf-widget-min.js" />
</fileset>
</copy>
<copy todir="${staging.dir}/etc/widget/js/dojo-1.5.0-windowname-only">
<fileset dir="web-app/js-lib/dojo-1.5.0-windowname-only" />
</copy>
<mkdir dir="${staging.dir}/etc/widget/js/eventing" />
<copy todir="${staging.dir}/etc/widget/js/eventing" flatten="true">
<fileset dir="web-app/js/eventing">
<include name="rpc_relay.uncompressed.html" />
</fileset>
</copy>
<mkdir dir="${staging.dir}/etc/widget/css" />
<copy todir="${staging.dir}/etc/widget/css">
<fileset dir="web-app/css">
<include name="dragAndDrop.css" />
</fileset>
</copy>
<mkdir dir="${staging.dir}/etc/widget/images/dragAndDrop" />
<copy todir="${staging.dir}/etc/widget/images/dragAndDrop">
<fileset dir="web-app/themes/common/images/dragAndDrop">
<include name="dndMove.png" />
<include name="dndNoMove.png" />
</fileset>
</copy>
<mkdir dir="${staging.dir}/etc/widget/flash-dragAndDrop" />
<copy todir="${staging.dir}/etc/widget/flash-dragAndDrop">
<fileset dir="flash-dragAndDrop" />
</copy>
<mkdir dir="${staging.dir}/etc/widget/descriptor" />
<copy todir="${staging.dir}/etc/widget/descriptor">
<fileset dir="web-app/examples/walkthrough/widgets">
<include name="descriptor.html" />
</fileset>
</copy>
<mkdir dir="${staging.dir}/etc/docs" />
<copy todir="${staging.dir}/etc/docs">
<fileset dir="test/jmeter/performance">
<include name="OWF Performance Metrics.${owf.doc.extension}" />
</fileset>
<fileset dir="${basedir}/docs-internal">
<include name="OWF Release Notes.${owf.doc.extension}" />
</fileset>
</copy>
<mkdir dir="${staging.dir}/dbscripts" />
<copy todir="${staging.dir}/dbscripts">
<fileset dir="src/assemble/dbscripts">
</fileset>
</copy>
<mkdir dir="${staging.dir}/help" />
<if>
<istrue value="${owf.release}"/>
<then>
<copy todir="${staging.dir}/help">
<fileset dir="${basedir}/docs-internal">
<exclude name="libraries/**" />
<exclude name="*.doc" />
</fileset>
</copy>
</then>
<else>
<copy todir="${staging.dir}/help">
<fileset dir="${basedir}/docs-internal">
<exclude name="libraries/**" />
</fileset>
</copy>
</else>
</if>
<copy todir="${staging.dir}/help/jsdoc" failonerror="false">
<fileset dir="${basedir}/src/assemble/docs/jsdoc" />
</copy>
<copy todir="${tomcat.dir}/certs">
<fileset dir="certs">
<include name="keystore.jks" />
<include name="testUser1.p12" />
<include name="testAdmin1.p12" />
<include name="ca.crt" />
</fileset>
</copy>
<copy todir="${tomcat.dir}/lib">
<fileset dir="src/resources">
<include name="OwfConfig.groovy" />
<include name="OzoneConfig.properties" />
<include name="owf-override-log4j.xml" />
</fileset>
<fileset dir="${basedir}" includes="themes/**" />
<fileset dir="${basedir}" includes="help/**" />
<fileset dir="${basedir}" includes="js-plugins/**" />
</copy>
<copy todir="${tomcat.dir}">
<fileset dir="${basedir}">
<include name="prodDb.script" />
</fileset>
</copy>
<copy todir="${staging.dir}/etc/override">
<fileset dir="src/resources">
<include name="ehcache.xml" />
</fileset>
</copy>
</target>
<!-- =================================
target: compile
================================= -->
<target name="compile" depends="-init" description="--> Compiles a Grails application">
<grails script="Compile" preargs="${offline.arg}"/>
</target>
<target name="compileAccess" description="--->Compile data guard access capability">
<delete dir="${temp.dir}"/>
<mkdir dir="${temp.dir}"/>
<javac srcdir="${basedir}/src/java/custom/access" destdir="${temp.dir}"/>
<jar jarfile="${lib.dir}/access-1.0.jar" basedir="${temp.dir}"/>
<delete dir="${temp.dir}"/>
</target>
<!-- =================================
target: war
================================= -->
<target name="war" depends="test,jsdoc,about,compress_js,compile-themes" description="--> Creates a WAR of a Grails application">
<grails script="war" preargs="${offline.arg}"/>
</target>
<!-- =================================
target: test
================================= -->
<target name="test" depends="-init" unless="no-test" description="--> Run a Grails applications unit tests">
<grails script="test-app unit: integration:" preargs="${offline.arg}" args="-coverage -xml"/>
</target>
<target name="test-selenium-firefox" description="--> Run Grails applications Selenium tests in FF">
<grails script="-Dserver.port=8181 -Dwebdriver.browser=firefox -Duser=testAdmin1 test-app functional: marketplace.tests.* -http" />
</target>
<target name="test-selenium-ie" if="isWindows" description="--> Run Grails applications Selenium tests in IE">
<grails script="-Dserver.port=8181 -Dwebdriver.browser=ie -Duser=testAdmin1 test-app functional: marketplace.tests.* -http" />
</target>
<target name="test-selenium-chrome" description="--> Run Grails applications Selenium tests in Chrome">
<echo message="ant.lib.dir: ${ant.lib.dir}"></echo>
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${ant.lib.dir}/ant-contrib-1.0b3.jar" />
<if>
<os family="windows" />
<then>
<grails script="-Duser=testAdmin1 -Dserver.port=8181 -Dwebdriver.browser=chrome -Dwebdriver.chrome.driver=c:\chrome\chromedriver.exe test-app functional: marketplace.tests.* -http" />
</then>
<else>
<grails script="-Duser=testAdmin1 -Dserver.port=8181 -Dwebdriver.browser=chrome -Dwebdriver.chrome.driver=/usr/bin/chromedriver test-app functional: marketplace.tests.* -http" />
</else>
</if>
</target>
<target name="test-selenium" depends="test-selenium-firefox" description="--> Run Grails applications Selenium tests" />
<!-- =================================
end - test
================================= -->
<target name="bundle" depends="_init-ivy,-init,clean,war">
<!--<resolve ivyConf="bundle,jetty" />-->
<resolve ivyConf="bundle,tomcat" />
<mkdir dir="${staging.dir}" />
<antcall target="stage-tomcat">
<param name="bundle.dir" value="${staging.dir}" />
</antcall>
<antcall target="stage-cas">
<param name="bundle.dir" value="${staging.dir}" />
</antcall>
<antcall target="stage-owf" />
<antcall target="post-bundle-cleanup" />
<!-- Ensure shell scripts are executable (for local dev testing) -->
<chmod dir="${staging.dir}" perm="+x" includes="**/*.sh"/>
<!-- create owf bundle -->
<zip destfile="${staging.dir}/${app.name}-bundle.zip" >
<zipfileset dir="${staging.dir}" excludes="**/*.sh, help/**" />
<zipfileset dir="${staging.dir}" includes="**/*.sh" filemode="744" />
</zip>
<!-- copy owf bundle to the released name-->
<copy file="${staging.dir}/${app.name}-bundle.zip" tofile="${staging.dir}/${app.base.prefix}-bundle-${app.base.version}-${app.base.sprint}.zip" />
<!-- create owf help bundle -->
<zip destfile="${staging.dir}/${app.base.prefix}-help-${app.base.version}-${app.base.sprint}.zip" >
<zipfileset dir="${staging.dir}" includes="help/**" />
</zip>
<!-- create test widget bundle -->
<antcall target="bundle-test-widgets" />
<!-- create sample widget bundle -->
<antcall target="bundle-sample-widgets" />
</target>
<target name="bundle-sample-widgets" depends="stage-samples">
<zip destfile="${staging.dir}/${app.base.prefix}-sample-widgets-${app.base.version}-${app.base.sprint}.zip" >
<zipfileset dir="${staging.dir}/samples"/>
</zip>
</target>
<target name="bundle-test-widgets">
<ant antfile="build.xml" dir="test-widgets"/>
<copy todir="${staging.dir}/owf-test-widgets" includeEmptyDirs="false">
<flattenmapper/>
<fileset dir="${basedir}">
<include name="test-widgets/**/*.war" />
</fileset>
</copy>
<zip destfile="${staging.dir}/${app.base.prefix}-test-widgets-${app.base.version}-${app.base.sprint}.zip" >
<zipfileset dir="${staging.dir}/owf-test-widgets"/>
</zip>
</target>
<target name="stage-owf">
<!-- <ivy:retrieve pattern="${staging.dir}/[artifact]-[revision].[ext]" type="zip" conf="bundle" /> -->
<copy file="${basedir}/target/${app.name}-${app.version}.war" tofile="${tomcat.dir}/webapps/owf.war" />
<copy file="${staging.dir}/owf-security-project-${owf.security.rev}.zip" tofile="${staging.dir}/owf-security/owf-security-project.zip" />
<unzip src="${staging.dir}/owf-security-extras-${owf.security.rev}.zip" dest="${staging.dir}" />
<antcall target='stage-extras' />
<copy file="LICENSE.txt" tofile="${staging.dir}/LICENSE.txt"/>
<copy file="COPYRIGHT.txt" tofile="${staging.dir}/COPYRIGHT.txt" />
</target>
<target name="post-bundle-cleanup" >
<delete file="${staging.dir}/cas-server-extras-${cas.server.rev}.zip" />
<delete file="${staging.dir}/cas-server-owf-${cas.server.rev}.war" />
<delete file="${staging.dir}/owf-security-extras-${owf.security.rev}.zip" />
<delete file="${staging.dir}/owf-security-project-${owf.security.rev}.zip" />
<delete file="${staging.dir}/owf-security-${owf.security.rev}.jar" />
<delete>
<fileset dir="${staging.dir}" includes="*.zip"/>
</delete>
<delete>
<fileset dir="${staging.dir}" includes="*.jar"/>
</delete>
</target>
<target name="release" depends="_init-ivy,bundle">
<_release rel.org="${app.org}" rel.module="${app.name}" rel.version="${app.version}" rel.ext="zip" build.dir="${staging.dir}" conf="release"/>
</target>
<!-- Database Migration targets -->
<target name="initDBMigration">
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpath="${ant.lib.dir}/ant-contrib-1.0b3.jar" />
<outofdate property="databaseScripts.outOfDate">
<sourcefiles>
<fileset dir="${basedir}/grails-app/migrations" includes="*.groovy"/>
<fileset dir="${basedir}/grails-app/migrations/dbscripts" includes="*.sql"/>
</sourcefiles>
<targetfiles>
<fileset dir="${basedir}/src/assemble/dbscripts" includes="*InitialCreate.sql"/>
<fileset dir="${basedir}/src/assemble/dbscripts" includes="*Upgrade_v${app.base.prevVersion}*_v${app.base.version}*.sql"/>
<fileset dir="${basedir}/src/assemble/dbscripts" includes="*Update_v${app.base.version}*.sql"/>
</targetfiles>
</outofdate>
<for param="dbScript">
<path>
<fileset dir="${basedir}/src/assemble/dbscripts" includes="*InitialCreate.sql"/>
<fileset dir="${basedir}/src/assemble/dbscripts" includes="*Upgrade_v${app.base.prevVersion}*_v${app.base.version}*.sql"/>
<fileset dir="${basedir}/src/assemble/dbscripts" includes="*Update_v${app.base.version}*.sql"/>
</path>
<sequential>
<condition property="databaseScripts.outOfDate">
<not>
<available file="@{dbScript}"></available>
</not>
</condition>
</sequential>
</for>
<echo message="databaseScripts.outOfDate: ${databaseScripts.outOfDate}"/>
</target>
<target name="generateAllDatabaseCreationScripts" description="--> Generates schema creation SQL scripts for the current version" depends="initDBMigration">
<antcall target="doCreateUpdateForAllDatabases"><param name="targetName" value="generateDatabaseCreationScript"/></antcall>
</target>
<target name="generateAllDatabaseUpdateScripts" description="--> Generates database upgrade SQL scripts from the previous to the current version" depends="initDBMigration">
<antcall target="doCreateUpdateForAllDatabases"><param name="targetName" value="generateDatabaseUpdateScript"/></antcall>
</target>
<target name="generateAllDatabaseUpgradeScripts" description="--> Generates database upgrade SQL scripts from the previous to the current version" depends="initDBMigration">
<antcall target="doUpgradeForAllDatabases"><param name="targetName" value="generateDatabaseUpgradeScript"/></antcall>
</target>
<target name="generateMySQLDatabaseScripts" description="--> Generates database internal/creation/upgrade SQL scripts for MYSQL">
<antcall target="generateSingleDatabaseScripts"><param name="db.type" value="mysql"/><param name="db.name" value="MySqlPrefs"/></antcall>
</target>
<target name="generateOracleDatabaseScripts" description="--> Generates database internal/creation/upgrade SQL scripts for Oracle">
<antcall target="generateSingleDatabaseScripts"><param name="db.type" value="oracle"/><param name="db.name" value="OraclePrefs"/></antcall>
</target>
<target name="generatePostgresqlDatabaseScripts" description="--> Generates database internal/creation/upgrade SQL scripts for PostgreSQL">
<antcall target="generateSingleDatabaseScripts"><param name="db.type" value="postgres"/><param name="db.name" value="PostgreSQLPrefs"/></antcall>
</target>
<target name="generateSQLServerDatabaseScripts" description="--> Generates database internal/creation/upgrade SQL scripts for SQLServer">
<antcall target="generateSingleDatabaseScripts"><param name="db.type" value="sql_server"/><param name="db.name" value="SQLServerPrefs"/></antcall>
</target>
<target name="generateSingleDatabaseScripts" description="--> Generates database internal/creation/upgrade SQL scripts">
<antcall target="generateDatabaseCreationScript"><param name="db.type" value="${db.type}"/><param name="db.name" value="${db.name}"/></antcall>
<antcall target="generateDatabaseUpdateScript"><param name="db.type" value="${db.type}"/><param name="db.name" value="${db.name}"/></antcall>
<antcall target="generateDatabaseUpgradeScript"><param name="db.type" value="${db.type}"/><param name="db.name" value="${db.name}"/></antcall>
</target>
<target name="generateDatabaseCreationScript" depends="initDBMigration" if="databaseScripts.outOfDate">
<property name="sql.create.file.suffix" value="InitialCreate.sql" />
<delete failonerror="false" file="${basedir}/src/assemble/dbscripts/${db.name}${sql.create.file.suffix}" />
<!-- Generate SQL for the 'create' context -->
<if>
<os family="windows"/>
<then>
<grails script="-Dgrails.env=with_${db.type}_empty dbm-update-sql" args="${basedir}/src/assemble/dbscripts/${db.name}${sql.create.file.suffix} "--contexts=create"" />
</then>
<else>
<grails script="-Dgrails.env=with_${db.type}_empty dbm-update-sql" args="${basedir}/src/assemble/dbscripts/${db.name}${sql.create.file.suffix} --contexts=create" />
</else>
</if>
<!-- Test 'create' -->
<if>
<isset property="dbmTestMigration"/>
<then>
<grails script="-Dgrails.env=with_${db.type} dbm-drop-all"/>
<if>
<os family="windows"/>
<then>
<grails script="-Dgrails.env=with_${db.type} dbm-update" args=""--contexts=create"" />
</then>
<else>
<grails script="-Dgrails.env=with_${db.type} dbm-update" args="--contexts=create" />
</else>
</if>
<!--also run integration tests against this empty db-->
<grails script="-Dgrails.env=with_${db.type} test-app" args="integration:" />
</then>
</if>
</target>
<target name="generateDatabaseUpdateScript" depends="initDBMigration" if="databaseScripts.outOfDate">
<property name="sql.update.file.suffix" value="Update_v${app.base.version}.sql" />
<delete failonerror="false" file="${basedir}/src/assemble/dbscripts/${db.name}${sql.update.file.suffix}" />
<!-- make sure db is empty-->
<grails script="-Dgrails.env=with_${db.type} dbm-drop-all"/>
<!-- Generate SQL for the last version upgrade changesets-->
<if>
<os family="windows"/>
<then>
<grails script="-Dgrails.env=with_${db.type} dbm-update-sql" args="${basedir}/src/assemble/dbscripts/${db.name}${sql.update.file.suffix} "--contexts=sampleData"" />
</then>
<else>
<grails script="-Dgrails.env=with_${db.type} dbm-update-sql" args="${basedir}/src/assemble/dbscripts/${db.name}${sql.update.file.suffix} --contexts=sampleData" />
</else>
</if>
<!-- Test 'update' -->
<if>
<isset property="dbmTestMigration"/>
<then>
<if>
<os family="windows"/>
<then>
<grails script="-Dgrails.env=with_${db.type} dbm-update" args=""--contexts=create"" />
</then>
<else>
<grails script="-Dgrails.env=with_${db.type} dbm-update" args="--contexts=create" />
</else>
</if>
<if>
<os family="windows"/>
<then>
<grails script="-Dgrails.env=with_${db.type} dbm-update" args=""--contexts=sampleData"" />
</then>
<else>
<grails script="-Dgrails.env=with_${db.type} dbm-update" args="--contexts=sampleData" />
</else>
</if>
</then>
</if>
</target>
<target name="generateDatabaseUpgradeScript" depends="initDBMigration" if="databaseScripts.outOfDate">
<property name="sql.upgrade.file.suffix" value="Upgrade_v${app.base.prevVersion}_v${app.base.version}.sql" />
<delete failonerror="false" file="${basedir}/src/assemble/dbscripts/${db.name}${sql.upgrade.file.suffix}" />
<!-- make sure db is empty-->
<grails script="-Dgrails.env=with_${db.type} dbm-drop-all"/>
<!-- Generate SQL for the last version upgrade changesets-->
<if>
<os family="windows"/>
<then>
<grails script="-Dgrails.env=with_${db.type} dbm-update-sql" args="${basedir}/src/assemble/dbscripts/${db.name}${sql.upgrade.file.suffix} "--contexts=${app.base.version}"" />
</then>
<else>
<grails script="-Dgrails.env=with_${db.type} dbm-update-sql" args="${basedir}/src/assemble/dbscripts/${db.name}${sql.upgrade.file.suffix} --contexts=${app.base.version}" />
</else>
</if>
<!-- Test 'upgrade' -->
<if>
<isset property="dbmTestMigration"/>
<then>
<grails script="-Dgrails.env=with_${db.type} dbm-drop-all"/>
<if>
<os family="windows"/>
<then>
<grails script="-Dgrails.env=with_${db.type} -DdbmBuildPreviousVersion=true dbm-update" args=""--contexts=create"" />
</then>
<else>
<grails script="-Dgrails.env=with_${db.type} -DdbmBuildPreviousVersion=true dbm-update" args="--contexts=create" />
</else>
</if>
<if>
<os family="windows"/>
<then>
<grails script="-Dgrails.env=with_${db.type} dbm-update" args=""--contexts=${app.base.version}"" />
</then>
<else>
<grails script="-Dgrails.env=with_${db.type} dbm-update" args="--contexts=${app.base.version}" />
</else>
</if>
</then>
</if>
</target>
<target name="doUpgradeForAllDatabases">
<antcall target="${targetName}"><param name="db.type" value="mysql"/><param name="db.name" value="MySqlPrefs"/></antcall>
<antcall target="${targetName}"><param name="db.type" value="postgres"/><param name="db.name" value="PostgreSQLPrefs"/></antcall>
<antcall target="${targetName}"><param name="db.type" value="sql_server"/><param name="db.name" value="SQLServerPrefs"/></antcall>
<antcall target="${targetName}"><param name="db.type" value="oracle"/><param name="db.name" value="OraclePrefs"/></antcall>
</target>
<target name="doCreateUpdateForAllDatabases">
<antcall target="${targetName}"><param name="db.type" value="mysql"/><param name="db.name" value="MySqlPrefs"/></antcall>
<antcall target="${targetName}"><param name="db.type" value="postgres"/><param name="db.name" value="PostgreSQLPrefs"/></antcall>
<antcall target="${targetName}"><param name="db.type" value="sql_server"/><param name="db.name" value="SQLServerPrefs"/></antcall>
<antcall target="${targetName}"><param name="db.type" value="oracle"/><param name="db.name" value="OraclePrefs"/></antcall>
</target>
<target name="generateDatabaseScripts"
depends="generateAllDatabaseCreationScripts, generateAllDatabaseUpdateScripts, generateAllDatabaseUpgradeScripts">
<replaceregexp byline="true" flags="g">
<regexp pattern="^-- Against:.*$"/>
<substitution expression=""/>
<fileset dir="${basedir}/src/assemble/dbscripts" includes="*.sql"/>
</replaceregexp>
</target>
<target name="start-js-test-driver-server">
<java jar="JsTestDriver-1.3.4.b.jar"
fork="true"
failonerror="true"
maxmemory="128m"
>
<arg line='--port 9876 --preloadFiles'/>
</java>
</target>
<target name="start-js-test-driver-tests">
<java jar="JsTestDriver-1.3.4.b.jar"
fork="true"
failonerror="true"
maxmemory="128m"
>
<arg line='--tests "all" --testOutput test/js-test-driver/test-reports'/>
</java>
</target>
</project>