buildr 1.4.12-x86-mswin32 → 1.4.13-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +15 -0
  2. data/CHANGELOG +62 -0
  3. data/addon/buildr/checkstyle.rb +6 -4
  4. data/addon/buildr/gpg.rb +9 -2
  5. data/addon/buildr/gwt.rb +1 -0
  6. data/buildr.gemspec +18 -20
  7. data/doc/download.textile +30 -6
  8. data/doc/index.textile +21 -9
  9. data/doc/packaging.textile +29 -0
  10. data/lib/buildr.rb +3 -0
  11. data/lib/buildr/core/application.rb +24 -0
  12. data/lib/buildr/core/assets.rb +93 -0
  13. data/lib/buildr/core/build.rb +3 -2
  14. data/lib/buildr/core/common.rb +3 -2
  15. data/lib/buildr/core/compile.rb +0 -1
  16. data/lib/buildr/core/generate.rb +2 -2
  17. data/lib/buildr/core/project.rb +1 -1
  18. data/lib/buildr/core/shell.rb +1 -1
  19. data/lib/buildr/core/transports.rb +4 -1
  20. data/lib/buildr/core/util.rb +8 -0
  21. data/lib/buildr/ide/idea.rb +267 -114
  22. data/lib/buildr/java/commands.rb +16 -2
  23. data/lib/buildr/java/packaging.rb +6 -4
  24. data/lib/buildr/java/pom.rb +1 -1
  25. data/lib/buildr/java/tests.rb +3 -3
  26. data/lib/buildr/packaging/archive.rb +4 -3
  27. data/lib/buildr/packaging/package.rb +0 -2
  28. data/lib/buildr/packaging/ziptask.rb +1 -1
  29. data/lib/buildr/version.rb +2 -2
  30. data/rakelib/rspec.rake +5 -49
  31. data/rakelib/stage.rake +7 -5
  32. data/spec/addon/jaxb_xjc_spec.rb +2 -2
  33. data/spec/core/application_spec.rb +8 -8
  34. data/spec/core/build_spec.rb +41 -41
  35. data/spec/core/common_spec.rb +3 -2
  36. data/spec/core/test_spec.rb +34 -34
  37. data/spec/core/transport_spec.rb +21 -17
  38. data/spec/ide/idea_spec.rb +707 -4
  39. data/spec/java/packaging_spec.rb +20 -0
  40. data/spec/java/tests_spec.rb +2 -2
  41. data/spec/packaging/packaging_spec.rb +0 -22
  42. metadata +54 -116
@@ -331,10 +331,11 @@ module Buildr #:nodoc:
331
331
  @this_version = extract_version
332
332
  check
333
333
  with_release_candidate_version do |release_candidate_buildfile|
334
- args = '-S', 'buildr', "_#{Buildr::VERSION}_", '--buildfile', release_candidate_buildfile
334
+ args = []
335
+ args << 'buildr' << '--buildfile' << release_candidate_buildfile
335
336
  args << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?
336
337
  args << 'clean' << 'upload' << 'DEBUG=no'
337
- ruby *args
338
+ sh *args
338
339
  end
339
340
  tag_release resolve_tag
340
341
  update_version_to_next if this_version != resolve_next_version(this_version)
@@ -46,9 +46,10 @@ module Buildr #:nodoc:
46
46
  # For example:
47
47
  # write('README') { read('README').sub("${build}", Time.now) }
48
48
  def write(name, content = nil)
49
- mkpath File.dirname(name)
49
+ filename = name.to_s
50
+ mkpath File.dirname(filename)
50
51
  content = yield if block_given?
51
- File.open(name.to_s, 'wb') { |file| file.write content.to_s }
52
+ File.open(filename, 'wb') { |file| file.write content.to_s }
52
53
  content.to_s
53
54
  end
54
55
 
@@ -86,7 +86,6 @@ module Buildr #:nodoc:
86
86
  def applies_to?(project, task)
87
87
  paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
88
88
  paths.flatten!
89
- ext_glob = Array(source_ext).join(',')
90
89
 
91
90
  paths.each { |path|
92
91
  Find.find(path) {|found|
@@ -58,7 +58,7 @@ module Buildr #:nodoc:
58
58
  end
59
59
 
60
60
  def has_eclipse_project?
61
- candidates = Dir.glob("**/.project")
61
+ candidates = Dir.glob("**/.project", File::FNM_DOTMATCH)
62
62
  return false if candidates.size == 0
63
63
  candidates.find { |x| get_project_natures(x) }
64
64
  return candidates.size > 0
@@ -134,7 +134,7 @@ EOF
134
134
  script << " # dependencies << 'junit should be commented out and replace by correct ARTIFACT definition. Eg"
135
135
  script << " # dependencies << 'junit:junit:jar:3.8.2'"
136
136
  script << setLayout('src', 'bin') # default values for eclipse
137
- dot_projects = Dir.glob('**/.project').find_all { |dot_project| get_project_natures(dot_project) }
137
+ dot_projects = Dir.glob('**/.project', File::FNM_DOTMATCH).find_all { |dot_project| get_project_natures(dot_project) }
138
138
  dot_projects.sort.each { |dot_project| from_eclipse(File.dirname(dot_project), false) } if dot_projects
139
139
  else
140
140
  # Skip fragments. Buildr cannot handle it without the help of buildr4osgi
@@ -251,7 +251,7 @@ module Buildr #:nodoc:
251
251
  end
252
252
  project ||= @projects[name] # Not found in scope.
253
253
  raise "No such project #{name}" unless project
254
- project.invoke
254
+ project.invoke unless Buildr.application.current_scope.join(":").to_s == project.name.to_s
255
255
  project
256
256
  end
257
257
 
@@ -66,7 +66,7 @@ module Buildr #:nodoc:
66
66
  props.merge! jrebel_props(project)
67
67
  props.merge! task.properties
68
68
 
69
- if not Util.win_os?
69
+ unless Util.win_os?
70
70
  uname = `uname -m`
71
71
  cpu = if uname =~ /i[34567]86/
72
72
  'i386'
@@ -271,7 +271,10 @@ module URI
271
271
  options ||= {}
272
272
  connect do |http|
273
273
  trace "Requesting #{self}"
274
- headers = { 'If-Modified-Since' => CGI.rfc1123_date(options[:modified].utc) } if options[:modified]
274
+ headers = {}
275
+ headers['If-Modified-Since'] = CGI.rfc1123_date(options[:modified].utc) if options[:modified]
276
+ headers['Cache-Control'] = 'no-cache'
277
+ headers['User-Agent'] = "Buildr-#{Buildr::VERSION}"
275
278
  request = Net::HTTP::Get.new(request_uri.empty? ? '/' : request_uri, headers)
276
279
  request.basic_auth self.user, self.password if self.user
277
280
  http.request request do |response|
@@ -76,6 +76,14 @@ module Buildr #:nodoc:
76
76
  end
77
77
  end
78
78
 
79
+ def uuid
80
+ return SecureRandom.uuid if SecureRandom.respond_to?(:uuid)
81
+ ary = SecureRandom.random_bytes(16).unpack("NnnnnN")
82
+ ary[2] = (ary[2] & 0x0fff) | 0x4000
83
+ ary[3] = (ary[3] & 0x3fff) | 0x8000
84
+ "%08x-%04x-%04x-%04x-%04x%08x" % ary
85
+ end
86
+
79
87
  # Return the path to the first argument, starting from the path provided by the
80
88
  # second argument.
81
89
  #
@@ -100,9 +100,9 @@ module Buildr #:nodoc:
100
100
  @components ||= []
101
101
  end
102
102
 
103
- def create_composite_component(name, components)
103
+ def create_composite_component(name, attrs, components)
104
104
  return nil if components.empty?
105
- component = self.create_component(name)
105
+ component = self.create_component(name, attrs)
106
106
  components.each do |element|
107
107
  element = element.call if element.is_a?(Proc)
108
108
  component.add_element element
@@ -298,60 +298,102 @@ module Buildr #:nodoc:
298
298
 
299
299
  def add_web_facet(options = {})
300
300
  name = options[:name] || "Web"
301
- url_base = options[:url_base] || "/"
302
- default_webroots = [buildr_project._(:source, :main, :webapp)]
301
+ default_webroots = {}
302
+ buildr_project.assets.paths.each {|p| default_webroots[p] = "/" }
303
303
  webroots = options[:webroots] || default_webroots
304
- default_web_xml = "#{buildr_project._(:source, :main, :webapp)}/WEB-INF/web.xml"
305
- web_xml = options[:web_xml] || default_web_xml
306
- version = options[:version] || "3.0"
304
+ default_deployment_descriptors = []
305
+ ['web.xml', 'sun-web.xml', 'glassfish-web.xml', 'jetty-web.xml', 'geronimo-web.xml',
306
+ 'context.xml', 'weblogic.xml',
307
+ 'jboss-deployment-structure.xml', 'jboss-web.xml',
308
+ 'ibm-web-bnd.xml', 'ibm-web-ext.xml', 'ibm-web-ext-pme.xml'].
309
+ each do |descriptor|
310
+ webroots.each_pair do |path, relative_url|
311
+ next unless relative_url == "/"
312
+ d = "#{path}/WEB-INF/#{descriptor}"
313
+ default_deployment_descriptors << d if File.exist?(d)
314
+ end
315
+ end
316
+ deployment_descriptors = options[:deployment_descriptors] || default_deployment_descriptors
307
317
 
308
318
  add_facet(name, "web") do |f|
309
319
  f.configuration do |c|
310
320
  c.descriptors do |d|
311
- if File.exist?(web_xml) || default_web_xml != web_xml
312
- d.deploymentDescriptor :name => 'web.xml', :url => file_path(web_xml), :optional => "true", :version => version
321
+ deployment_descriptors.each do |deployment_descriptor|
322
+ d.deploymentDescriptor :name => File.basename(deployment_descriptor), :url => file_path(deployment_descriptor)
313
323
  end
314
324
  end
315
325
  c.webroots do |w|
316
- webroots.each do |webroot|
317
- w.root :url => file_path(webroot), :relative => url_base
326
+ webroots.each_pair do |webroot, relative_url|
327
+ w.root :url => file_path(webroot), :relative => relative_url
318
328
  end
319
329
  end
320
330
  end
331
+ default_enable_jsf = webroots.select{|webroot| File.exist?("#{webroot}/WEB-INF/faces-config.xml")}
332
+ enable_jsf = options[:enable_jsf].nil? ? default_enable_jsf : options[:enable_jsf]
333
+ enable_jsf = false if root_project.ipr? && root_project.ipr.version >= '13'
334
+ f.facet(:type => 'jsf', :name => 'JSF') do |jsf|
335
+ jsf.configuration
336
+ end if enable_jsf
321
337
  end
322
338
  end
323
339
 
324
340
  def add_jruby_facet(options = {})
325
341
  name = options[:name] || "JRuby"
326
- jruby_version = options[:jruby_version] || "jruby-1.5.2-p249"
342
+
343
+ ruby_version_file = buildr_project._('.ruby-version')
344
+ default_jruby_version = File.exist?(ruby_version_file) ? "rbenv: #{IO.read(ruby_version_file).strip}" : 'jruby-1.6.7.2'
345
+ jruby_version = options[:jruby_version] || default_jruby_version
327
346
  add_facet(name, "JRUBY") do |f|
328
- f.configuration(:number => 0) do |c|
347
+ f.configuration do |c|
329
348
  c.JRUBY_FACET_CONFIG_ID :NAME => "JRUBY_SDK_NAME", :VALUE => jruby_version
349
+ c.LOAD_PATH :number => "0"
350
+ c.I18N_FOLDERS :number => "0"
330
351
  end
331
352
  end
332
353
  end
333
354
 
334
355
  def add_jpa_facet(options = {})
335
356
  name = options[:name] || "JPA"
357
+
358
+ source_roots = [buildr_project.iml.main_source_directories, buildr_project.compile.sources, buildr_project.resources.sources].flatten.compact
359
+ default_deployment_descriptors = []
360
+ ['orm.xml', 'persistence.xml'].
361
+ each do |descriptor|
362
+ source_roots.each do |path|
363
+ d = "#{path}/META-INF/#{descriptor}"
364
+ default_deployment_descriptors << d if File.exist?(d)
365
+ end
366
+ end
367
+ deployment_descriptors = options[:deployment_descriptors] || default_deployment_descriptors
368
+
336
369
  factory_entry = options[:factory_entry] || buildr_project.name.to_s
337
370
  validation_enabled = options[:validation_enabled].nil? ? true : options[:validation_enabled]
338
- provider_enabled = options[:provider_enabled] || 'Hibernate'
339
- default_persistence_xml = buildr_project._(:source, :main, :resources, "META-INF/persistence.xml")
340
- persistence_xml = options[:persistence_xml] || default_persistence_xml
341
- default_orm_xml = buildr_project._(:source, :main, :resources, "META-INF/orm.xml")
342
- orm_xml = options[:orm_xml] || default_orm_xml
371
+ if options[:provider_enabled]
372
+ provider = options[:provider_enabled]
373
+ else
374
+ provider = nil
375
+ {'org.hibernate.ejb.HibernatePersistence' => 'Hibernate',
376
+ 'org.eclipse.persistence.jpa.PersistenceProvider' => 'EclipseLink'}.
377
+ each_pair do |match, candidate_provider|
378
+ deployment_descriptors.each do |descriptor|
379
+ if File.exist?(descriptor) && /#{Regexp.escape(match)}/ =~ IO.read(descriptor)
380
+ provider = candidate_provider
381
+ end
382
+ end
383
+ end
384
+ end
385
+
343
386
  add_facet(name, "jpa") do |f|
344
387
  f.configuration do |c|
345
- c.setting :name => "validation-enabled", :value => validation_enabled
346
- c.setting :name => "provider-name", :value => provider_enabled
388
+ if provider
389
+ c.setting :name => "validation-enabled", :value => validation_enabled
390
+ c.setting :name => "provider-name", :value => provider
391
+ end
347
392
  c.tag!('datasource-mapping') do |ds|
348
393
  ds.tag!('factory-entry', :name => factory_entry)
349
394
  end
350
- if File.exist?(persistence_xml) || default_persistence_xml != persistence_xml
351
- c.deploymentDescriptor :name => 'persistence.xml', :url => file_path(persistence_xml)
352
- end
353
- if File.exist?(orm_xml) || default_orm_xml != orm_xml
354
- c.deploymentDescriptor :name => 'orm.xml', :url => file_path(orm_xml)
395
+ deployment_descriptors.each do |descriptor|
396
+ c.deploymentDescriptor :name => File.basename(descriptor), :url => file_path(descriptor)
355
397
  end
356
398
  end
357
399
  end
@@ -359,15 +401,27 @@ module Buildr #:nodoc:
359
401
 
360
402
  def add_ejb_facet(options = {})
361
403
  name = options[:name] || "EJB"
362
- default_ejb_xml = buildr_project._(:source, :main, :resources, "WEB-INF/ejb-jar.xml")
363
- ejb_xml = options[:ejb_xml] || default_ejb_xml
364
- ejb_roots = options[:ejb_roots] || [buildr_project.compile.sources, buildr_project.resources.sources].flatten
404
+
405
+ default_ejb_roots = [buildr_project.iml.main_source_directories, buildr_project.compile.sources, buildr_project.resources.sources].flatten.compact
406
+ ejb_roots = options[:ejb_roots] || default_ejb_roots
407
+
408
+ default_deployment_descriptors = []
409
+ ['ejb-jar.xml', 'glassfish-ejb-jar.xml', 'ibm-ejb-jar-bnd.xml', 'ibm-ejb-jar-ext-pme.xml', 'ibm-ejb-jar-ext.xml',
410
+ 'jboss.xml', 'jbosscmp-jdbc.xml', 'openejb-jar.xml', 'sun-cmp-mapping.xml', 'sun-ejb-jar.xml',
411
+ 'weblogic-cmp-rdbms-jar.xml', 'weblogic-ejb-jar.xml'].
412
+ each do |descriptor|
413
+ ejb_roots.each do |path|
414
+ d = "#{path}/WEB-INF/#{descriptor}"
415
+ default_deployment_descriptors << d if File.exist?(d)
416
+ end
417
+ end
418
+ deployment_descriptors = options[:deployment_descriptors] || default_deployment_descriptors
365
419
 
366
420
  add_facet(name, "ejb") do |facet|
367
421
  facet.configuration do |c|
368
422
  c.descriptors do |d|
369
- if File.exist?(ejb_xml) || default_ejb_xml != ejb_xml
370
- d.deploymentDescriptor :name => 'ejb-jar.xml', :url => file_path(ejb_xml)
423
+ deployment_descriptors.each do |deployment_descriptor|
424
+ d.deploymentDescriptor :name => File.basename(deployment_descriptor), :url => file_path(deployment_descriptor)
371
425
  end
372
426
  end
373
427
  c.ejbRoots do |e|
@@ -381,6 +435,14 @@ module Buildr #:nodoc:
381
435
 
382
436
  protected
383
437
 
438
+ def root_project
439
+ p = buildr_project
440
+ while p.parent
441
+ p = p.parent
442
+ end
443
+ p
444
+ end
445
+
384
446
  def test_dependency_details
385
447
  main_dependencies_paths = main_dependencies.map(&:to_s)
386
448
  target_dir = buildr_project.compile.target.to_s
@@ -415,7 +477,7 @@ module Buildr #:nodoc:
415
477
  end
416
478
 
417
479
  def facet_component
418
- create_composite_component("FacetManager", self.facets)
480
+ create_composite_component("FacetManager", {}, self.facets)
419
481
  end
420
482
 
421
483
  def module_root_component
@@ -553,17 +615,24 @@ module Buildr #:nodoc:
553
615
  class IdeaProject < IdeaFile
554
616
  attr_accessor :extra_modules
555
617
  attr_accessor :artifacts
618
+ attr_accessor :data_sources
556
619
  attr_accessor :configurations
557
620
  attr_writer :jdk_version
621
+ attr_writer :version
558
622
 
559
623
  def initialize(buildr_project)
560
624
  super()
561
625
  @buildr_project = buildr_project
562
626
  @extra_modules = []
563
627
  @artifacts = []
628
+ @data_sources = []
564
629
  @configurations = []
565
630
  end
566
631
 
632
+ def version
633
+ @version || "12"
634
+ end
635
+
567
636
  def jdk_version
568
637
  @jdk_version ||= buildr_project.compile.options.source || "1.6"
569
638
  end
@@ -584,47 +653,86 @@ module Buildr #:nodoc:
584
653
  end
585
654
  end
586
655
 
656
+ def add_postgres_data_source(name, options = {})
657
+ if options[:url].nil? && options[:database]
658
+ default_url = "jdbc:postgresql://#{(options[:host] || "127.0.0.1")}:#{(options[:port] || "5432")}/#{options[:database]}"
659
+ end
660
+
661
+ params = {
662
+ :driver => 'org.postgresql.Driver',
663
+ :url => default_url,
664
+ :username => ENV["USER"],
665
+ :dialect => 'PostgreSQL',
666
+ :classpath => ["org.postgresql:postgresql:jar:9.2-1003-jdbc4"]
667
+ }.merge(options)
668
+ add_data_source(name, params)
669
+ end
670
+
671
+ def add_sql_server_data_source(name, options = {})
672
+ if options[:url].nil? && options[:database]
673
+ default_url = "jdbc:jtds:sqlserver://#{(options[:host] || "127.0.0.1")}:#{(options[:port] || "1433")}/#{options[:database]}"
674
+ end
675
+
676
+ params = {
677
+ :driver => 'net.sourceforge.jtds.jdbc.Driver',
678
+ :url => default_url,
679
+ :username => ENV["USER"],
680
+ :dialect => 'TSQL',
681
+ :classpath => ['net.sourceforge.jtds:jtds:jar:1.2.7']
682
+ }.merge(options)
683
+ add_data_source(name, params)
684
+ end
685
+
686
+ def add_data_source(name, options = {})
687
+ add_to_composite_component(self.data_sources) do |xml|
688
+ data_source_options = {
689
+ :source => "LOCAL",
690
+ :name => name,
691
+ :uuid => Buildr::Util.uuid
692
+ }
693
+ classpath = options[:classpath] || []
694
+ xml.tag!("data-source", data_source_options) do |xml|
695
+ xml.tag!("synchronize", (options[:synchronize]||"true"))
696
+ xml.tag!("jdbc-driver", options[:driver]) if options[:driver]
697
+ xml.tag!("jdbc-url", options[:url]) if options[:url]
698
+ xml.tag!("user-name", options[:username]) if options[:username]
699
+ xml.tag!("user-password", encrypt(options[:password])) if options[:password]
700
+ xml.tag!("default-dialect", options[:dialect]) if options[:dialect]
701
+
702
+ xml.libraries do |xml|
703
+ classpath.each do |classpath_element|
704
+ a = Buildr.artifact(classpath_element)
705
+ a.invoke
706
+ xml.library do |xml|
707
+ xml.tag!("url", resolve_path(a.to_s))
708
+ end
709
+ end
710
+ end if classpath.size > 0
711
+ end
712
+ end
713
+ end
714
+
587
715
  def add_exploded_war_artifact(project, options = {})
588
- artifact_name = options[:name] || project.iml.id
589
- build_on_make = options[:build_on_make].nil? ? false : options[:build_on_make]
716
+ artifact_name = to_artifact_name(project, options)
717
+ artifacts = options[:artifacts] || []
590
718
 
591
- add_artifact(artifact_name, "exploded-war", build_on_make) do |xml|
719
+ add_artifact(artifact_name, "exploded-war", build_on_make(options)) do |xml|
592
720
  dependencies = (options[:dependencies] || ([project] + project.compile.dependencies)).flatten
593
721
  libraries, projects = partition_dependencies(dependencies)
594
722
 
595
- ## The content here can not be indented
596
- output_dir = options[:output_dir] || project._(:artifacts, artifact_name)
597
- xml.tag!('output-path', output_dir)
598
-
723
+ emit_output_path(xml, artifact_name, options)
599
724
  xml.root :id => "root" do
600
725
  xml.element :id => "directory", :name => "WEB-INF" do
601
726
  xml.element :id => "directory", :name => "classes" do
602
- projects.each do |p|
603
- xml.element :id => "module-output", :name => p.iml.id
604
- end
605
- if options[:enable_jpa]
606
- module_names = options[:jpa_module_names] || [project.iml.id]
607
- module_names.each do |module_name|
608
- facet_name = options[:jpa_facet_name] || "JPA"
609
- xml.element :id => "jpa-descriptors", :facet => "#{module_name}/jpa/#{facet_name}"
610
- end
611
- end
612
- if options[:enable_ejb]
613
- module_names = options[:ejb_module_names] || [project.iml.id]
614
- module_names.each do |module_name|
615
- facet_name = options[:ejb_facet_name] || "EJB"
616
- xml.element :id => "javaee-facet-resources", :facet => "#{module_name}/ejb/#{facet_name}"
617
- end
618
- end
727
+ artifact_content(xml, project, projects, options)
619
728
  end
620
729
  xml.element :id => "directory", :name => "lib" do
621
- libraries.each(&:invoke).map(&:to_s).each do |dependency_path|
622
- xml.element :id => "file-copy", :path => resolve_path(dependency_path)
623
- end
730
+ emit_libraries(xml, libraries)
731
+ emit_jar_artifacts(xml, artifacts)
624
732
  end
625
733
  end
626
734
 
627
- if options[:enable_war].nil? || options[:enable_war]
735
+ if options[:enable_war].nil? || options[:enable_war] || (options[:war_module_names] && options[:war_module_names].size > 0)
628
736
  module_names = options[:war_module_names] || [project.iml.id]
629
737
  module_names.each do |module_name|
630
738
  facet_name = options[:war_facet_name] || "Web"
@@ -632,7 +740,7 @@ module Buildr #:nodoc:
632
740
  end
633
741
  end
634
742
 
635
- if options[:enable_gwt]
743
+ if options[:enable_gwt] || (options[:gwt_module_names] && options[:gwt_module_names].size > 0)
636
744
  module_names = options[:gwt_module_names] || [project.iml.id]
637
745
  module_names.each do |module_name|
638
746
  facet_name = options[:gwt_facet_name] || "GWT"
@@ -644,76 +752,53 @@ module Buildr #:nodoc:
644
752
  end
645
753
 
646
754
  def add_exploded_ear_artifact(project, options ={})
755
+ artifact_name = to_artifact_name(project, options)
647
756
 
648
- artifact_name = options[:name] || project.iml.id
649
- build_on_make = options[:build_on_make].nil? ? true : options[:build_on_make]
650
-
651
- add_artifact(artifact_name, "exploded-ear", build_on_make) do |xml|
757
+ add_artifact(artifact_name, "exploded-ear", build_on_make(options)) do |xml|
652
758
  dependencies = (options[:dependencies] || ([project] + project.compile.dependencies)).flatten
653
759
  libraries, projects = partition_dependencies(dependencies)
654
760
 
655
- ## The content here can not be indented
656
- output_dir = options[:output_dir] || project._(:artifacts, artifact_name)
657
- xml.tag!('output-path', output_dir)
658
-
761
+ emit_output_path(xml, artifact_name, options)
659
762
  xml.root :id => "root" do
660
-
661
- xml.element :id => "module-output", :name => project.iml.id
662
-
663
- projects.each do |p|
664
- xml.element :id => "directory", :name => p.iml.id do
665
- xml.element :id => "module-output", :name => p.iml.id
666
- end
667
- end
668
-
763
+ emit_module_output(xml, projects)
669
764
  xml.element :id => "directory", :name => "lib" do
670
- libraries.each(&:invoke).map(&:to_s).each do |dependency_path|
671
- xml.element :id => "file-copy", :path => resolve_path(dependency_path)
672
- end
765
+ emit_libraries(xml, libraries)
673
766
  end
767
+ end
768
+ end
769
+ end
674
770
 
771
+ def add_jar_artifact(project, options = {})
772
+ artifact_name = to_artifact_name(project, options)
773
+
774
+ dependencies = (options[:dependencies] || [project]).flatten
775
+ libraries, projects = partition_dependencies(dependencies)
776
+ raise "Unable to add non-project dependencies (#{libraries.inspect}) to jar artifact" if libraries.size > 0
777
+
778
+ jar_name = "#{artifact_name}.jar"
779
+ add_artifact(jar_name, "jar", build_on_make(options)) do |xml|
780
+ emit_output_path(xml, artifact_name, options)
781
+ xml.root(:id => "archive", :name => jar_name) do
782
+ artifact_content(xml, project, projects, options)
675
783
  end
676
784
  end
677
785
  end
678
786
 
679
787
  def add_exploded_ejb_artifact(project, options = {})
788
+ artifact_name = to_artifact_name(project, options)
680
789
 
681
- artifact_name = options[:name] || project.iml.id
682
- build_on_make = options[:build_on_make].nil? ? true : options[:build_on_make]
683
-
684
- add_artifact(artifact_name, "exploded-ejb", build_on_make) do |xml|
685
- dependencies = (options[:dependencies] || ([project] + project.compile.dependencies)).flatten
790
+ add_artifact(artifact_name, "exploded-ejb", build_on_make(options)) do |xml|
791
+ dependencies = (options[:dependencies] || [project]).flatten
686
792
  libraries, projects = partition_dependencies(dependencies)
793
+ raise "Unable to add non-project dependencies (#{libraries.inspect}) to ejb artifact" if libraries.size > 0
687
794
 
688
- ## The content here can not be indented
689
- output_dir = options[:output_dir] || project._(:artifacts, artifact_name)
690
- xml.tag!('output-path', output_dir)
691
-
795
+ emit_output_path(xml, artifact_name, options)
692
796
  xml.root :id => "root" do
693
-
694
- xml.element :id => "module-output", :name => project.iml.id
695
-
696
- if options[:enable_jpa]
697
- module_names = options[:jpa_module_names] || [project.iml.id]
698
- module_names.each do |module_name|
699
- facet_name = options[:jpa_facet_name] || "JPA"
700
- xml.element :id => "jpa-descriptors", :facet => "#{module_name}/jpa/#{facet_name}"
701
- end
702
- end
703
-
704
- if options[:enable_ejb].nil? || options[:enable_ejb]
705
- module_names = options[:ejb_module_names] || [project.iml.id]
706
- module_names.each do |module_name|
707
- facet_name = options[:ejb_facet_name] || "EJB"
708
- xml.element :id => "javaee-facet-resources", :facet => "#{module_name}/ejb/#{facet_name}"
709
- end
710
- end
711
-
797
+ artifact_content(xml, project, projects, options)
712
798
  end
713
799
  end
714
800
  end
715
801
 
716
-
717
802
  def add_gwt_configuration(launch_page, project, options = {})
718
803
  name = options[:name] || "Run #{launch_page}"
719
804
  shell_parameters = options[:shell_parameters] || ""
@@ -733,6 +818,12 @@ module Buildr #:nodoc:
733
818
 
734
819
  protected
735
820
 
821
+ def artifact_content(xml, project, projects, options)
822
+ emit_module_output(xml, projects)
823
+ emit_jpa_descriptors(xml, project, options)
824
+ emit_ejb_descriptors(xml, project, options)
825
+ end
826
+
736
827
  def extension
737
828
  "ipr"
738
829
  end
@@ -748,6 +839,7 @@ module Buildr #:nodoc:
748
839
  lambda { modules_component },
749
840
  vcs_component,
750
841
  artifacts_component,
842
+ lambda { data_sources_component },
751
843
  configurations_component,
752
844
  lambda { framework_detection_exclusion_component }
753
845
  ]
@@ -771,11 +863,11 @@ module Buildr #:nodoc:
771
863
  attribs["version"] = "2"
772
864
  attribs["languageLevel"] = "JDK_#{self.jdk_version.gsub('.', '_')}"
773
865
  attribs["assert-keyword"] = "true"
774
- attribs["jdk-15"] = "true"
866
+ attribs["jdk-15"] = (jdk_version >= "1.5").to_s
775
867
  attribs["project-jdk-name"] = self.jdk_version
776
868
  attribs["project-jdk-type"] = "JavaSDK"
777
869
  create_component("ProjectRootManager", attribs) do |xml|
778
- xml.output("url" => "file://$PROJECT_DIR$/out")
870
+ xml.output("url" => file_path(buildr_project._(:target, :idea, :project_out)))
779
871
  end
780
872
  end
781
873
 
@@ -840,12 +932,16 @@ module Buildr #:nodoc:
840
932
  end
841
933
  end
842
934
 
935
+ def data_sources_component
936
+ create_composite_component("DataSourceManagerImpl", {:format => "xml", :hash => "3208837817"}, self.data_sources)
937
+ end
938
+
843
939
  def artifacts_component
844
- create_composite_component("ArtifactManager", self.artifacts)
940
+ create_composite_component("ArtifactManager", {}, self.artifacts)
845
941
  end
846
942
 
847
943
  def configurations_component
848
- create_composite_component("ProjectRunConfigurationManager", self.configurations)
944
+ create_composite_component("ProjectRunConfigurationManager", {}, self.configurations)
849
945
  end
850
946
 
851
947
  def resolve_path(path)
@@ -854,6 +950,62 @@ module Buildr #:nodoc:
854
950
 
855
951
  private
856
952
 
953
+ def to_artifact_name(project, options)
954
+ options[:name] || project.iml.id
955
+ end
956
+
957
+ def build_on_make(options)
958
+ options[:build_on_make].nil? ? false : options[:build_on_make]
959
+ end
960
+
961
+ def emit_jar_artifacts(xml, artifacts)
962
+ artifacts.each do |p|
963
+ xml.element :id => "artifact", 'artifact-name' => "#{p}.jar"
964
+ end
965
+ end
966
+
967
+ def emit_libraries(xml, libraries)
968
+ libraries.each(&:invoke).map(&:to_s).each do |dependency_path|
969
+ xml.element :id => "file-copy", :path => resolve_path(dependency_path)
970
+ end
971
+ end
972
+
973
+ def emit_module_output(xml, projects)
974
+ projects.each do |p|
975
+ xml.element :id => "module-output", :name => p.iml.id
976
+ end
977
+ end
978
+
979
+ def emit_output_path(xml, artifact_name, options)
980
+ ## The content here can not be indented
981
+ output_dir = options[:output_dir] || buildr_project._(:artifacts, artifact_name)
982
+ xml.tag!('output-path', resolve_path(output_dir))
983
+ end
984
+
985
+ def emit_ejb_descriptors(xml, project, options)
986
+ if options[:enable_ejb] || (options[:ejb_module_names] && options[:ejb_module_names].size > 0)
987
+ module_names = options[:ejb_module_names] || [project.iml.id]
988
+ module_names.each do |module_name|
989
+ facet_name = options[:ejb_facet_name] || "EJB"
990
+ xml.element :id => "javaee-facet-resources", :facet => "#{module_name}/ejb/#{facet_name}"
991
+ end
992
+ end
993
+ end
994
+
995
+ def emit_jpa_descriptors(xml, project, options)
996
+ if options[:enable_jpa] || (options[:jpa_module_names] && options[:jpa_module_names].size > 0)
997
+ module_names = options[:jpa_module_names] || [project.iml.id]
998
+ module_names.each do |module_name|
999
+ facet_name = options[:jpa_facet_name] || "JPA"
1000
+ xml.element :id => "jpa-descriptors", :facet => "#{module_name}/jpa/#{facet_name}"
1001
+ end
1002
+ end
1003
+ end
1004
+
1005
+ def encrypt(password)
1006
+ password.bytes.inject("") { |x, y| x + (y ^ 0xdfaa).to_s(16) }
1007
+ end
1008
+
857
1009
  def partition_dependencies(dependencies)
858
1010
  libraries = []
859
1011
  projects = []
@@ -861,7 +1013,8 @@ module Buildr #:nodoc:
861
1013
  dependencies.each do |dependency|
862
1014
  artifacts = Buildr.artifacts(dependency)
863
1015
  artifacts_as_strings = artifacts.map(&:to_s)
864
- project = Buildr.projects.detect do |project|
1016
+ all_projects = Buildr::Project.instance_variable_get("@projects").keys - [buildr_project.name]
1017
+ project = Buildr.projects(all_projects).detect do |project|
865
1018
  [project.packages, project.compile.target, project.resources.target, project.test.compile.target, project.test.resources.target].flatten.
866
1019
  detect { |component| artifacts_as_strings.include?(component.to_s) }
867
1020
  end