-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildfile
1660 lines (1433 loc) · 66.6 KB
/
buildfile
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
#L
# Copyright Northwestern University.
#
# Distributed under the OSI-approved BSD 3-Clause License.
# See http://ncip.github.com/psc/LICENSE.txt for details.
#L
ENV['JAVA_OPTS'] ||= "-Xmx256M -XX:MaxPermSize=96M -Dcom.sun.management.jmxremote"
if env_true?('YOURKIT')
ENV['JAVA_OPTS'] += " #{yourkit_javaopt}"
end
if env_true?('REMOTE_DEBUG')
ENV['JAVA_OPTS'] += " #{remote_debug_javaopt}"
end
puts "Using JAVA_OPTS=#{ENV['JAVA_OPTS'].inspect}"
require "buildr"
require "buildr/jetty"
require "buildr/emma" if emma?
require "buildr/core/filter"
require 'fileutils'
require 'rexml/document'
require 'buildr_iidea'
###### buildr script for PSC
# In order to use this, you'll need buildr. See http://buildr.apache.org/ .
# Version number is set in build/project.properties for BDA compatibility
VERSION_NUMBER=File.read(File.expand_path("../build/project.properties", __FILE__)).
scan(/^psc-webapp.version=(.*?)$/).first.first
APPLICATION_SHORT_NAME = 'psc'
###### Jetty config
# enable JSP support in Jetty
::Java.classpath.concat([
#"org.mortbay.jetty:jsp-api-2.1:jar:#{Buildr::Jetty::VERSION}",
#"org.mortbay.jetty:jsp-2.1:jar:#{Buildr::Jetty::VERSION}"
# Same jsp version in jetty as of tomcat 5.5.
"org.mortbay.jetty:jsp-api-2.0:jar:#{Buildr::Jetty::VERSION}",
"tomcat:jasper-compiler:jar:5.5.15",
"tomcat:jasper-runtime:jar:5.5.15",
"tomcat:jasper-compiler-jdt:jar:5.5.15",
"org.slf4j:jcl-over-slf4j:jar:#{SLF4J_VERSION}",
"commons-el:commons-el:jar:1.0"
])
jetty.url = jetty_url
###### PROJECT
desc "Patient Study Calendar"
define "psc" do
project.version = VERSION_NUMBER
project.group = "edu.northwestern.bioinformatics"
compile.options.target = "1.6"
compile.options.source = "1.6"
compile.options.other = %w(-encoding UTF-8)
test.using(:properties => { "psc.config.datasource" => db_name })
test.enhance [:check_module_packages]
iml.local_repository_env_override = nil
ipr.add_component("CompilerConfiguration") do |component|
component.option :name => 'DEFAULT_COMPILER', :value => 'Javac'
component.option :name => 'DEPLOY_AFTER_MAKE', :value => '0'
component.resourceExtensions do |xml|
xml.entry :name => '.+\.nonexistent'
end
component.wildcardResourceExtensions do |xml|
xml.entry :name => '?*.nonexistent'
end
end
task :public_demo_deploy do
cp FileList[_("test/public/*")], "/opt/tomcat/webapps-vera/studycalendar/"
end
desc "Ensures that the BDA build includes an explicit install for each gem mentioned in build.yml"
task :verify_bda_gems do
requirements = *Buildr.settings.build["gems"].
collect { |line| line.split(/\s+/, 2) }.
collect { |name, version| [name, (Gem::Requirement.new(version) if version)] }
bda_installs = {}
REXML::Document.new(File.new _("build-adapter.xml")).elements.each("project/property") do |prop|
if prop.attributes["name"] =~ /gems.(\S+).version/
bda_installs[$1] = Gem::Version.new(prop.attributes["value"])
end
end
missing = requirements.reject { |gem, req|
(req.nil? && bda_installs.keys.include?(gem)) ||
(bda_installs[gem] && req.satisfied_by?(bda_installs[gem]))
}
unless missing.empty?
fail "The BDA installer is missing the following gem#{'s' unless missing.size == 1}:\n" <<
"- #{missing.collect { |pair| pair.join(' ') }.join("\n- ")}"
end
end
desc "Pure utility code"
define "utility" do
bnd.wrap!
bnd.name = "PSC Utility Module"
bnd.category = :infrastructure
bnd.import_packages.clear
bnd.import_packages << 'edu.northwestern.bioinformatics.*' << '*;resolution:=optional'
compile.with SLF4J.api, SPRING, SPRING_WEB.web, SPRING_WEB.webmvc, JAKARTA_COMMONS.collections,
CTMS_COMMONS.base, CTMS_COMMONS.lang, CTMS_COMMONS.core, CONTAINER_PROVIDED, OSGI.core
test.with(UNIT_TESTING, FELIX.framework)
package(:jar)
package(:sources)
desc "Bidirectional object bridge for sharing object instances across the membrane between the OSGi classloader and the main application classloader"
define "osgimosis" do
compile.with SLF4J.api, CGLIB
test.using(:junit).with(UNIT_TESTING, JAKARTA_COMMONS.io)
package(:jar)
package(:sources)
end
end
desc "The domain classes for PSC"
define "domain" do
bnd.wrap!
bnd.name = "PSC Domain Model"
bnd.category = :infrastructure
bnd.import_packages <<
"org.hibernate;version=3.3" <<
"org.hibernate.type;version=3.3" <<
"org.hibernate.cfg;version=3.3" <<
"edu.northwestern.bioinformatics.studycalendar.osgi.felixcm"
compile.with project('utility'), SLF4J.api,
CTMS_COMMONS.base, CTMS_COMMONS.lang, CTMS_COMMONS.core,
JAKARTA_COMMONS.beanutils, JAKARTA_COMMONS.collections,
JAKARTA_COMMONS.lang, JAKARTA_COMMONS.collections_generic,
SPRING, SECURITY.acegi, SECURITY.csm, HIBERNATE
test.with(UNIT_TESTING)
package(:jar)
package(:sources)
end
desc "Database configuration and testing"
define "database" do
bnd.wrap!
bnd.name = 'PSC Database Support'
bnd.category = :infrastructure
# Migrations are resources, too
resources.enhance([_("src/main/db/migrate")]) do
filter.from(_("src/main/db/migrate")).
into(resources.target.to_s + "/db/migrate").run
end
compile.with SLF4J.api, SLF4J.jcl, SPRING,
CTMS_COMMONS.base, CTMS_COMMONS.core, JAKARTA_COMMONS, db_deps,
HIBERNATE, EHCACHE
test.with UNIT_TESTING, BERING, CORE_COMMONS
test.resources.filter.using(:ant, 'application-short-name' => APPLICATION_SHORT_NAME)
# Automatically generate the HSQLDB when the migrations change
# if using hsqldb.
test.enhance hsqldb[:files]
hsqldb[:files].each do |f|
file(f => Dir[_('src/main/db/migrate/**/*')]) do
if hsqldb?
task(:create_hsqldb).invoke
end
end
end
task :migrate do
cp = ant_classpath(project('database'), BERING, CORE_COMMONS)
ant('bering') do |ant|
# Load DS properties from /etc/psc or ~/.psc
datasource_properties(ant)
ant.echo :message => "Migrating ${datasource.url}"
# default values
ant.property :name => 'migrate.version', :value => ENV['MIGRATE_VERSION'] || ""
ant.property :name => 'bering.dialect', :value => ""
ant.taskdef :resource => "edu/northwestern/bioinformatics/bering/antlib.xml",
:classpath => cp
ant.migrate :driver => '${datasource.driver}',
:dialect => "${bering.dialect}",
:url => "${datasource.url}",
:userid => "${datasource.username}",
:password => "${datasource.password}",
:targetVersion => "${migrate.version}",
:migrationsDir => _("src/main/db/migrate"),
:classpath => cp
if hsqldb?
# database must be explicitly shutdown in HSQLDB >=1.7.2, so that the lock is
# released and the tests can reopen it
ant.sql :driver => "${datasource.driver}",
:url => "${datasource.url}",
:userid => "${datasource.username}",
:password => "${datasource.password}",
:autocommit => "true",
:classpath => cp,
:pcdata => "SHUTDOWN SCRIPT;"
end
end
end
task :create_hsqldb => :clean_hsqldb do |t|
psc_dir = "#{::Java.java.lang.System.getProperty("user.home")}/.psc"
mkdir_p psc_dir
File.open("#{psc_dir}/#{db_name}.properties", 'w') do |f|
f.puts( (<<-PROPERTIES).split(/\n/).collect { |row| row.strip }.join("\n") )
# Generated by PSC's psc:database:create_hsqldb task
datasource.url=#{hsqldb[:url]}
datasource.username=sa
datasource.password=
datasource.driver=org.hsqldb.jdbcDriver
PROPERTIES
end
# Apply the bering migrations to build the HSQLDB schema
mkdir_p hsqldb[:dir]
task(:migrate).invoke
# Mark read-only
File.open("#{hsqldb[:dir]}/#{db_name}.properties", 'a') do |f|
f.puts "hsqldb.files_readonly=true"
end
info "Read-only HSQLB instance named #{db_name} generated in #{hsqldb[:dir]}"
end
task :clean_hsqldb do
rm_rf hsqldb[:dir]
end
package(:jar)
package(:sources)
end # database
define "authorization" do
project.no_iml
desc "PSC-specific specialization of suite authorization"
define "definitions" do
bnd.wrap!
bnd.name = "PSC Authorization Definitions"
bnd.import_packages <<
"org.acegisecurity" <<
"org.springframework.core" <<
"gov.nih.nci.cabig.ctms.domain"
bnd.category = :infrastructure
compile.with SECURITY.acegi, project('domain').and_dependencies, SECURITY.csm, SECURITY.clm,
SECURITY.suite_authorization
test.with UNIT_TESTING, project('domain').test_dependencies
package(:jar)
end
desc "Interfaces and base classes for PSC's simplified authorization plugin mechanism"
define "plugin-api" do
project.iml.id = 'authorization-plugin-api'
bnd.wrap!
bnd.name = "PSC Authorization Plugin API"
bnd.category = :infrastructure
compile.with SLF4J.api, SECURITY.suite_authorization, SPRING,
CTMS_COMMONS.base, CTMS_COMMONS.core
test.with UNIT_TESTING, LOGBACK, CTMS_COMMONS.lang
package(:jar)
end
desc "The adapter that converts an authorization plugin into a CSM AuthorizationManager"
define "socket" do
project.iml.id = 'authorization-socket'
bnd.wrap!
bnd.name = "PSC Authorization Plugin Socket"
bnd['Service-Component'] = 'OSGI-INF/plugin-socket-creator.xml'
bnd.export_packages.clear
bnd.export_packages << '!gov.nih.nci.cabig.ctms.suite.authorization.socket.internal'
package(:jar)
compile.with project('plugin-api').and_dependencies, project('utility'), SLF4J.api,
SECURITY.csm, SECURITY.suite_authorization, CTMS_COMMONS.base, JAKARTA_COMMONS.lang,
OSGI
test.with UNIT_TESTING, LOGBACK
end
desc 'A sample plugin that authorizes a single, statically-defined user'
define 'mock-plugin' do
bnd.wrap!
bnd.name = 'PSC Authorization Mock Plugin'
bnd['Bundle-Activator'] =
'gov.nih.nci.cabig.ctms.suite.authorization.plugins.mock.Activator'
bnd.category = :optional_plugins
package(:jar)
compile.with project('plugin-api').and_dependencies, SLF4J.api, project('utility'),
SECURITY.suite_authorization, OSGI.core, CTMS_COMMONS.base
test.with UNIT_TESTING, LOGBACK
end
desc 'The OSGi plugin that configures and exposes the default CSM authorization manager'
define 'default-csm' do
bnd.wrap!
bnd.name = 'PSC Default CSM Authorization Manager'
bnd['Bundle-Activator'] = 'edu.northwestern.bioinformatics.studycalendar.security.csm.Activator'
bnd['DynamicImport-Package'] = '*' # For JDBC drivers
bnd.category = :automatic_plugins
package(:jar)
compile.with project('utility'), project('database'), CTMS_COMMONS.core,
OSGI.core, OSGI.compendium, HIBERNATE.main, SLF4J.api, SLF4J.log4j,
SPRING, SECURITY.csm, SECURITY.clm, SECURITY.suite_authorization
test.with UNIT_TESTING, LOGBACK
end
desc 'Publishes AuthorizationManager-based services no matter which AuthorizationManager is used'
define 'auxiliary-services' do
bnd.wrap!
bnd.name = 'PSC Auxiliary Authorization Services'
bnd.category = :infrastructure
bnd.export_packages.clear
bnd.export_packages << '!edu.northwestern.bioinformatics.studycalendar.authorization.auxiliary.internal'
bnd['Service-Component'] = 'OSGI-INF/suite-role-membership-loader.xml'
package(:jar)
compile.with SLF4J.api, SECURITY.suite_authorization, OSGI, SECURITY.csm, project('utility')
test.with UNIT_TESTING, LOGBACK
end
end
desc "Pluggable authentication definition and included plugins"
define "authentication" do
project.no_iml
desc "Interfaces and base classes for PSC's pluggable authentication system"
define "plugin-api" do
project.iml.id = 'authentication-plugin-api'
bnd.wrap!
bnd.name = "PSC Pluggable Auth API"
bnd.category = :infrastructure
compile.with project('utility'), project('authorization:definitions'),
SLF4J.api, OSGI, CONTAINER_PROVIDED, SPRING, SPRING_WEB.web, SECURITY.acegi,
CTMS_COMMONS.core, JAKARTA_COMMONS.lang, SPRING_OSGI,
SECURITY.suite_authorization
test.with UNIT_TESTING, EHCACHE,
project('mocks').and_dependencies,
project('domain').and_dependencies,
project('domain').test_dependencies
package(:jar)
end
desc "PSC's framework for using the authentication plugins"
define "socket" do
project.iml.id = 'authentication-socket'
bnd.wrap!
bnd.name = "PSC Pluggable Auth Socket"
bnd.import_packages <<
"org.acegisecurity.context" <<
"org.acegisecurity.providers.anonymous" <<
"org.acegisecurity.providers.dao.cache" <<
"org.acegisecurity.intercept.web" <<
"org.acegisecurity.ui.logout" <<
"org.acegisecurity.wrapper" <<
"org.acegisecurity.vote" <<
"org.springframework.cache.ehcache"
compile.with project('plugin-api').and_dependencies, SPRING_OSGI,
project('domain').and_dependencies, EHCACHE, JAKARTA_COMMONS.codec
test.with UNIT_TESTING,
project.parent.project('local-plugin'),
project('plugin-api').test_dependencies,
project('domain').test_dependencies,
SECURITY.suite_authorization
package(:jar)
end
desc "Authentication using PSC's local CSM instance"
define "local-plugin" do
bnd.wrap!
bnd.name = "PSC Local Auth Plugin"
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.security.plugin.local.Activator"
bnd.category = :automatic_plugins
compile.with project('plugin-api').and_dependencies, SECURITY.csm
test.with project('plugin-api').test_dependencies,
project('domain').and_dependencies, project('domain').test_dependencies,
project('database').and_dependencies, project('database').test_dependencies, db_deps
package(:jar)
end
desc "Authentication via an enterprise-wide CAS server"
define "cas-plugin" do
bnd.wrap!
bnd.name = "PSC CAS Auth Plugin"
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.security.plugin.cas.Activator"
bnd.category = :automatic_plugins
bnd.import_packages <<
"org.springframework.beans.factory.config;version=2.5" <<
"org.springframework.cache.ehcache;version=2.5" <<
"org.acegisecurity.providers.cas" <<
"org.acegisecurity.providers.cas.cache" <<
"org.acegisecurity.providers.cas.populator" <<
"org.acegisecurity.providers.cas.proxy" <<
"org.acegisecurity.providers.cas.ticketvalidator" <<
"org.acegisecurity.ui.cas" <<
"org.acegisecurity.ui.logout"
compile.with project('plugin-api').and_dependencies, SECURITY.cas,
EHCACHE, JAKARTA_COMMONS.httpclient, HTMLPARSER
test.with project('plugin-api').test_dependencies, JAKARTA_COMMONS.io
package(:jar)
end
desc "Authentication via caGrid's customized version of CAS"
define "websso-plugin" do
bnd.wrap!
bnd.name = "PSC caGrid WebSSO Auth Plugin"
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.security.plugin.websso.Activator"
bnd.category = :automatic_plugins
bnd.import_packages.clear
bnd.import_packages <<
"!org.globus.gsi" << "*" <<
"org.springframework.beans.factory.config;version=2.5" <<
"org.springframework.cache.ehcache;version=2.5" <<
"org.acegisecurity.providers.cas" <<
"org.acegisecurity.providers.cas.cache" <<
"org.acegisecurity.providers.cas.populator" <<
"org.acegisecurity.providers.cas.proxy" <<
"org.acegisecurity.providers.cas.ticketvalidator" <<
"org.acegisecurity.ui.cas" <<
"org.acegisecurity.ui.logout" <<
"gov.nih.nci.cabig.caaers.web.security.cas" <<
"org.apache.commons.httpclient" << # an instance is directly created in cas-authentication-beans.xml, so it needs to be visible
"edu.northwestern.bioinformatics.studycalendar.security.plugin.cas.direct" <<
"gov.nih.nci.cagrid.metadata"
compile.with project('plugin-api').and_dependencies,
project('cas-plugin').and_dependencies,
project('domain').and_dependencies,
SECURITY.caaers_cas, CAGRID,
GLOBUS.core, GLOBUS_UNDUPLICABLE
test.with project('plugin-api').test_dependencies,
project('cas-plugin').test_dependencies,
project('domain').and_dependencies,
project('domain').test_dependencies
package(:jar)
end
desc "A completely insecure implementation for integrated tests and the like"
define "insecure-plugin" do
bnd.wrap!
bnd.name = "PSC Insecure Auth Plugin"
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.security.plugin.insecure.Activator"
bnd.category = :automatic_plugins
compile.with project('plugin-api').and_dependencies
test.with project('plugin-api').test_dependencies,
project('domain').and_dependencies, project('domain').test_dependencies
package(:jar)
end
end
desc "External data-providing plugins"
define "providers" do
desc "The interfaces under which data providers expose data"
define "api" do
bnd.wrap!
bnd.name = "PSC Data Providers API"
bnd.category = :infrastructure
compile.with project('domain').and_dependencies
package(:jar)
end
desc "Mock data providers with static data"
define "mock" do
bnd.wrap!
bnd.name = "PSC Mock Data Providers"
bnd.category = :optional_plugins
bnd.import_packages <<
"edu.northwestern.bioinformatics.studycalendar.domain.delta" <<
"edu.northwestern.bioinformatics.studycalendar.domain.tools" <<
"gov.nih.nci.cabig.ctms.domain"
iml.id = "providers-mock"
compile.with parent.project('api').and_dependencies, SPRING
test.with UNIT_TESTING, project('domain').test_dependencies
package(:jar)
end
desc "Data providers which talk to COPPA"
define "coppa" do
define "common" do
bnd.wrap!
bnd.name = "PSC COPPA Data Providers Common Library"
bnd.category = :optional_plugins
bnd.import_packages <<
"edu.northwestern.bioinformatics.studycalendar.domain.delta" <<
"edu.northwestern.bioinformatics.studycalendar.domain.tools" <<
"gov.nih.nci.cabig.ctms.domain"
compile.with parent.project('api').and_dependencies, SPRING, OSGI,
GLOBUS, CAGRID, COPPA
test.using(:junit).with UNIT_TESTING, project('domain').test_dependencies
package(:jar)
end
define "ihub" do
bnd.wrap!
bnd.name = "PSC COPPA Integration Hub Data Providers"
bnd.description = "A suite of data providers which communicate with COPPA via caBIG Integration Hub"
bnd.category = :optional_plugins
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.dataproviders.coppa.ihub.Activator"
bnd.import_packages.clear
bnd.import_packages <<
"!org.globus.gsi" << "*" <<
"edu.northwestern.bioinformatics.studycalendar.domain.delta" <<
"edu.northwestern.bioinformatics.studycalendar.domain.tools" <<
"gov.nih.nci.cabig.ctms.domain"
compile.with project('psc:providers:coppa:common').and_dependencies,
CIH, GLOBUS_UNDUPLICABLE, project('authorization:definitions')
test.using(:junit).with UNIT_TESTING
package(:jar)
end
end
desc "Commands for interacting with the providers from the felix console"
define "felix-commands" do
compile.with FELIX.shell, OSGI.core,
parent.project('api').and_dependencies
test.with UNIT_TESTING, project('domain').test_dependencies
iml.id = "providers-felix-commands"
bnd.wrap!
bnd.name = "PSC Data Provider Felix Shell Commands"
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.dataproviders.commands.Activator"
package(:jar)
end
end
desc "Submodules related to building and deploying PSC's embedded plugin layer"
define "osgi-layer" do
task :embedder_artifacts => :artifacts do |task|
class << task; attr_accessor :values; end
bundle_projects = Buildr::projects.select { |p| p.bnd.wrap? }
jars_for_category = lambda do |category|
bundle_projects.select { |p| p.bnd.category == category }.collect { |p| p.package(:jar) }
end
all_categories = bundle_projects.collect { |p| p.bnd.category }.uniq
unmapped_categories = all_categories - [:system, :infrastructure, :automatic_plugins, :optional_plugins, :application]
unless unmapped_categories.empty?
fail "Unhandled categories for OSGi layer: #{unmapped_categories.inspect}"
end
system_optional = [(FELIX.shell_remote unless ENV['OSGI_TELNET'] == 'yes')].compact.collect { |b| artifact(b) }
system_bundles = (FELIX.values - [FELIX.framework]).collect { |b| artifact(b) } - system_optional
system_bundles += (LOGBACK.values + [SLF4J.api, SLF4J.jcl]).collect { |spec| artifact(spec) }
system_bundles += jars_for_category[:system]
application_infrastructure = [ SPRING_OSGI.extender, GLOBUS.jaxb_api, STAX_API ].collect { |a| artifact(a) }
application_infrastructure += jars_for_category[:infrastructure]
application_libraries = bundle_projects.
collect { |p| p.and_dependencies }.flatten.uniq.
select { |a| Buildr::Artifact === a }.
reject { |a| a.to_s =~ /org.osgi/ }.reject { |a| a.to_s =~ /sources/ } -
system_bundles - system_optional - application_infrastructure -
[FELIX.shell, GLOBUS_UNDUPLICABLE.values].flatten.collect { |b| artifact(b) } +
project('psc:osgi-layer:domain-fragments').projects.collect { |p| p.package(:jar) }
task.values = {
"001_system/start" => system_bundles,
"001_system/install" => system_optional,
"010_infrastructure/start" => application_infrastructure,
"010_infrastructure/install" => application_libraries,
"020_plugins/start" => jars_for_category[:automatic_plugins],
"020_plugins/install" => jars_for_category[:optional_plugins],
"030_application/start" => jars_for_category[:application]
}
end
task :build_test_embedder => ["psc:osgi-layer:embedder_artifacts"] do |task|
base = _('target', 'test', 'embedder')
rm_rf base
mkdir_p base
cp _(:src, :main, :resources, 'framework.properties'), base
task("psc:osgi-layer:embedder_artifacts").values.each do |path, artifacts|
edir = File.join(base, path)
mkdir_p edir
artifacts.each { |a|
trace "Putting #{a} in #{path}"
a.invoke;
cp a.to_s, edir
}
end
end
task :examine => :'psc:osgi-layer:console:run'
task :analyze_package_consistency => [:build_test_embedder] do
test_dal = _('target', 'test', 'embedder')
boot_packages = Hash.from_java_properties(
File.read("#{test_dal}/framework.properties"))['org.osgi.framework.bootdelegation'].
split(/\s*,\s*/) +
['java.*', 'javax.*', 'org.xml.sax.*', 'org.w3c.dom.*', 'org.omg.*', 'org.osgi.*']
AnalyzeOsgiConsistency.analyze_packages(Dir["#{test_dal}/**/*.jar"], boot_packages)
end
# Finds packages which contain classes in different bundles.
# Note that these are not all necessarily errors -- fragment bundles
# may extend packages from their associated bundles and internal-only
# packages may be repeated across bundles
task :find_duplicate_packages => [:build_test_embedder] do
Dir[_('target', 'test', 'embedder') + "/**/*.jar"].inject({}) { |h, jar|
`jar tf #{jar}`.split(/\n/).grep(/.class$/).collect { |path|
path.sub(/\/[^\/]+$/, '').gsub('/', '.')
}.uniq.each { |package|
h[package] ||= []
h[package] << jar
}
h
}.each_pair { |package, jars|
if jars.size > 1
puts package
puts '=' * package.size
jars.each { |jar| puts "- #{jar}"}
puts
end
}
end
define "console" do
compile.with SLF4J, LOGBACK, project('utility').and_dependencies, FELIX.framework,
project('core').and_dependencies
task :run => [:build_test_embedder, 'psc:osgi-layer:console:compile'] do
mkdir_p _('tmp/logs')
cd _("target/classes") do
deps = project.test.dependencies.collect { |p| p.to_s }
if ENV['WEBAPP_SIM']
deps = [deps, project('psc:web').and_dependencies].flatten.uniq
deps += GLOBUS_UNDUPLICABLE.values if (env_true?('WEBSSO') || env_true?('GLOBUS'))
end
classpath = deps.collect { |d| d.to_s }.join(':')
puts "Classpath:\n- #{deps.join("\n- ")}"
cmd = [
'rlwrap',
'java', "-Dcatalina.base=#{_('tmp')}",
'-Dpsc.logging.debug=true',
'-cp', classpath,
'edu.northwestern.bioinformatics.studycalendar.osgi.console.EmbedderConsole',
project('osgi-layer')._('target', 'test', 'embedder')
].join(' ')
exec cmd
end
end
end
desc 'An OSGi bundle that exports DataSources configured for PSC'
define 'datasources' do
bnd.wrap!
bnd.name = 'PSC Data Sources'
bnd['DynamicImport-Package'] = '*' # For JDBC drivers
bnd.import_packages <<
'edu.northwestern.bioinformatics.studycalendar.database' <<
'org.apache.commons.dbcp' <<
'gov.nih.nci.cabig.ctms.tools.spring' <<
'javax.sql'
bnd.category = :infrastructure
compile.with project('database'), CTMS_COMMONS.core, db_deps
package(:jar)
end
desc "Advertises host-configured services to the OSGi layer"
define "host-services" do
bnd.wrap!
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.osgi.hostservices.Activator"
bnd.name = "PSC OSGi Layer Access to Host Services"
bnd.import_packages <<
"org.acegisecurity.userdetails" <<
"edu.northwestern.bioinformatics.studycalendar.domain" <<
"javax.security.auth" <<
"gov.nih.nci.security.authorization.jaas" <<
"gov.nih.nci.security.authorization.domainobjects" <<
"gov.nih.nci.security.exceptions" <<
"gov.nih.nci.security.dao"
compile.with project('utility').and_dependencies,
project('authorization:definitions'), SECURITY.acegi, OSGI, FELIX.configadmin, SECURITY.csm
test.using(:junit).with UNIT_TESTING,
project('domain').and_dependencies, project('domain').test_dependencies
package(:jar)
end
desc "Routes from the OSGi Log Service to SLF4J"
define 'log-adapter' do
bnd.wrap!
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.osgi.log.Adapter"
bnd.name = "PSC OSGi Log to SLF4J Adapter"
bnd.category = :infrastructure
compile.with project('utility').and_dependencies, OSGI
package(:jar)
end
define "log-configuration" do
bnd.wrap!
bnd.name = "PSC OSGi Layer Log Configuration"
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.osgi.logback.LogbackConfigurator"
bnd.category = :system
compile.with SLF4J.api, LOGBACK, OSGI.core
package(:jar)
end
desc "A bundle which exports services for testing OSGi config interfaces"
define "mock" do
bnd.wrap!
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.osgi.mock.Activator"
bnd.name = "PSC OSGi Layer Mock Services"
bnd.category = :optional_plugins
iml.id = "osgi-layer-mock"
compile.with project('utility').and_dependencies, OSGI
package(:jar)
end
desc "Provides a PersistenceManager for Felix's CM implementation"
define 'felix-persistence-manager' do
bnd.wrap!
bnd.name = "PSC Felix Configuration Persistence"
bnd.category = :infrastructure
bnd['Service-Component'] = 'OSGI-INF/psc-felix-persistence-manager.xml'
bnd.export_packages.unshift '!edu.northwestern.bioinformatics.studycalendar.osgi.felixcm.internal'
bnd.import_packages << 'edu.northwestern.bioinformatics.bering.dialect.hibernate'
bnd['DynamicImport-Package'] = '*' # for JDBC drivers
compile.with project('utility'), project('domain'),
SLF4J.api, OSGI, FELIX.configadmin, HIBERNATE,
JAKARTA_COMMONS.collections_generic, CTMS_COMMONS.core, CTMS_COMMONS.lang,
SPRING.core, SPRING.beans, SPRING.orm, SPRING.tx, BERING
test.with UNIT_TESTING, project('database').test_dependencies
package(:jar)
end
define 'domain-fragments' do
DOMAIN_PACKAGES = %w(
edu.northwestern.bioinformatics.studycalendar.osgi.felixcm
)
{
'hibernate' => 'org.hibernate.edu.northwestern.bioinformatics.osgi.hibernate-core',
'ctms-commons-core' => 'gov.nih.nci.cabig.ctms.ctms-commons.core'
}.each do |name, host|
desc "Allows #{name} to import PSC domain packages"
define name do
iml.id = ['domain-fragments', name].join('-')
package(:jar).with(:manifest => {
'Bundle-ManifestVersion' => 2,
'Bundle-Name' => "PSC Domain to #{name} Fragment",
'Bundle-SymbolicName' => [project.group, project.name.gsub(':', '.')].join('.'),
'Bundle-Version' => project.version,
'Fragment-Host' => host,
'Import-Package' => DOMAIN_PACKAGES.collect { |pkg| "#{pkg};version=\"#{project.version.split('.')[0,2].join('.')}\"" }.join(',')
})
end
end
end
desc "Non-PSC-specific commands for the felix shell"
define "felix-commands" do
bnd.wrap!
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.osgi.commands.Activator"
bnd.name = "PSC Utility Felix Commands"
iml.id = "osgi-layer-felix-commands"
compile.with FELIX.shell, OSGI.core, JAKARTA_COMMONS.lang
test.with UNIT_TESTING, project('utility').and_dependencies
package(:jar)
end
desc 'Arranges for deployment-specific plugins to be automatically installed'
define 'plugin-installer' do
bnd.wrap!
bnd['Bundle-Activator'] =
"edu.northwestern.bioinformatics.studycalendar.osgi.plugininstaller.Activator"
bnd.name = 'PSC Plugin Installer'
bnd.category = :system
compile.with OSGI, SLF4J.api
test.with UNIT_TESTING
package(:jar)
end
define "integrated-tests" do
directory _('tmp/logs')
test.using(:junit, :properties => { 'psc.logging.debug' => 'true', 'psc.config.datasource' => db_name }).with UNIT_TESTING,
FELIX.framework,
project('authentication:socket').and_dependencies,
project('authentication:cas-plugin').and_dependencies,
project('web').and_dependencies,
project('web').test_dependencies,
project('authentication:plugin-api').test_dependencies,
project('providers:mock'),
project('authorization:plugin-api').test_dependencies,
project('authorization:mock-plugin'),
project('plugin-installer').and_dependencies,
project('mock')
test.enhance([:build_test_embedder, _('tmp/logs')])
end
end
desc "Core data access, serialization and non-substitutable business logic"
define "core" do
project('providers') # Have to reference this before refing project('providers:mock') in buildr 1.3.3 for some reason. Investigate later. RMS20090331.
resources.filter.using(:ant,
'application-short-name' => APPLICATION_SHORT_NAME,
"buildInfo.versionNumber" => project.version,
"buildInfo.username" => ENV['USER'],
"buildInfo.hostname" => `hostname`.chomp,
"buildInfo.timestamp" => Time.now.strftime("%Y-%m-%d %H:%M:%S")
).exclude "**/.DS_Store"
compile.with project('domain').and_dependencies,
project('authorization:definitions').and_dependencies,
project('providers:api').and_dependencies,
project('database').and_dependencies,
project('utility:osgimosis').and_dependencies,
project('psc:osgi-layer:host-services').and_dependencies,
XML, RESTLET.framework, FREEMARKER, CSV, CORE_COMMONS, BERING,
QUARTZ, SECURITY, OSGI, SLF4J.jcl, FELIX.configadmin,
CONTAINER_PROVIDED, SPRING_WEB # tmp for mail
test.with UNIT_TESTING, project('domain').test.compile.target,
project('database').test_dependencies,
project('mocks').and_dependencies,
project('authorization:default-csm').and_dependencies
package(:jar)
package(:sources)
iml.add_facet("Spring", "Spring") do |facet|
facet.configuration do |conf|
conf.fileset(:id => 'core-common', :name => 'Core Common ApplicationContext') do |fs|
Dir[_(:source, :main, :java) + "/applicationContext*xml"].reject { |f| f =~ /osgi/ }.each do |f|
fs.file "file://$MODULE_DIR$/#{f.sub(_(), '')}"
end
end
conf.fileset(:id => 'core-prod', :name => 'Core Production ApplicationContext') do |fs|
fs.dependency "core-common"
fs.file "file://$MODULE_DIR$/src/main/java/applicationContext-core-osgi.xml"
end
conf.fileset(:id => 'core-testing', :name => 'Core Testing ApplicationContext') do |fs|
fs.dependency "core-common"
fs.file "file://$MODULE_DIR$/src/main/java/applicationContext-core-testing-osgi.xml"
end
end
end
check do
acSetup = File.read(_('target/resources/applicationContext-setup.xml'))
acSetup.should include(`hostname`.chomp)
acSetup.should include(project.version)
end
end # core
##Adding the grid module.
desc "Grid Services, includes Registration Consumer, Study Consumer and AE Service"
define "grid" do
project.no_iml
task :check_globus do |task|
raise "GLOBUS_LOCATION not set. Cannot build grid services without globus" unless ENV['GLOBUS_LOCATION']
end
task :check_ccts do |task|
raise "CCTS_HOME not set. Cannot deploy grid service without CAAERS" unless ENV['CCTS_HOME']
end
task :check_grid_tomcat do |task|
raise "CATALINA_HOME not set. Cannot deploy grid service without TOMCAT" unless ENV['CATALINA_HOME']
end
task :check_wsrf do |task|
raise "#{wsrf_dir} not found. Cannot deploy grid service" unless File.directory? wsrf_dir
end
task :work_directories do
mkdir_p _('target/work-tomcat/webapps/wsrf')
mkdir_p _('target/work-tomcat/common/lib')
end
task :deploy_globus do |task|
raise "GLOBUS_LOCATION not found. Cannot deploy globus" unless ENV['GLOBUS_LOCATION']
ant('deploy-globus') do |ant|
ant.echo :message => "deploying secured globus on tomcat, #{ENV['tomcat.dir']}"
ant.subant :buildpath => ENV['GLOBUS_LOCATION'], :antfile => "share/globus_wsrf_common/tomcat/tomcat.xml", :target => "deploySecureTomcat", :inheritAll => "false" do |subant|
subant.property :name => "tomcat.dir", :value => ENV['CATALINA_HOME']
subant.property :name => "webapp.name", :value => wsrf_dir_name
end
end
##using filtertask to filter the server-config.wsdd. Migrated the update-wsdd ant task to buildr. Added a custom mapper for filters
##Wasnt able to do an inplace filtering hence creating a work directory and then deleting it.
##Tested and working
## 1093 task
FileUtils.mkdir_p _('target/work')
filter.from(wsrf_dir+"/WEB-INF/etc/globus_wsrf_core").into(_('target/work')).include("server-config.wsdd").using(
:xml, :xpath => "/deployment/globalConfiguration",
:insert_type => :under,
:xml_content => "<parameter name=\"disableDNS\" value=\"true\"/>
<parameter name=\"logicalHost\" value=\"" + tomcat_hostname + "\"/>"
).run
FileUtils.rm wsrf_dir+"/WEB-INF/etc/globus_wsrf_core/server-config.wsdd"
filter.from(_('target/work')).into(wsrf_dir+"/WEB-INF/etc/globus_wsrf_core").include("server-config.wsdd").run
FileUtils.remove_dir _('target/work')
end
##this will deploy all the psc implementations together with the grid services provided PSC. Consider this for CCTS deployments since the
##container will most likely be secured before deploy the PSC specific implementations. Also check the "deploy_with_globus" task.
task :deploy => ['psc:grid:adverse-event-consumer-impl:deploy' , 'psc:grid:registration-consumer-impl:deploy' , 'psc:grid:study-consumer-impl:deploy']
##this will grid secure the tomcat and then deploy all the implementation.
task :deploy_with_globus => [:deploy_globus , :deploy]
## packaging the war file by deploying the grid services on the work tomcat folder.
package(:war, :file => _('target/'+wsrf_dir_name+'.war')).clean.include(:from=>_('target/work-tomcat/webapps/wsrf')).enhance [:'psc:grid:work_directories'] do
ENV['CATALINA_HOME']=_('target/work-tomcat').to_s
ENV['WSRF_DIR_NAME']='wsrf'
task(:deploy_with_globus).invoke
end
##Project src and test compiling successfully but test cases are failing.
desc "AdverseEvent Grid Service"
define "adverse-event-consumer-impl", :base_dir => _('adverse-event-consumer') do
compile.from(_('src/java')).with project('core').and_dependencies, GLOBUS, ADVERSE_EVENT_CONSUMER_GRID, SLF4J, LOGBACK
resources.from(_('src/java')).include('*.xml')
package(:jar)
package(:sources)
#Test cases are written with DBUnit 2.2, hence its added as a seperate dependency
test.with(UNIT_TESTING, project('core').test_dependencies, project('database').test_dependencies, CAGRID_1, DBUNIT_GRID).compile.from(_('test/src/java'))
test.resources.from(_('test/resources')).include('*')
test.resources.from('src/test/resources').include('logback-test.xml')
#removing the DBUNIT 2.1 from the test dependencies
test.dependencies.reject! do |dep|
dep == artifact(eponym("dbunit", "2.1"))
end
task :deploy => ['psc:grid:check_globus', 'psc:grid:check_ccts', 'psc:grid:check_grid_tomcat'] do |task|
##Delegating to caaers.
##Not Tested therefore commented temporarily
ant('deploy-adverse-event-consumer-service') do |ant|
ant.echo :message => "delegating the adverse event consumer service deployment to caaers"
ant.subant :buildpath => ENV['CCTS_HOME']+"/AdverseEventConsumerService-caGrid1.4", :antfile => "ivy-build.xml", :target => "deployTomcat", :inheritAll => "false" do |subant|
subant.property :name => "tomcat.dir", :value => ENV['CATALINA_HOME']
subant.property :name => "globus.webapp", :value => wsrf_dir_name
end
end
##FileUtils.rm wsrf_dir+"/WEB-INF/lib/spring-2.0.2.jar"