buildr 1.4.4-x86-mswin32 → 1.4.5-x86-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. data/CHANGELOG +46 -0
  2. data/Rakefile +0 -1
  3. data/addon/buildr/bnd.rb +147 -0
  4. data/addon/buildr/jaxb_xjc.rb +72 -0
  5. data/addon/buildr/protobuf.rb +14 -1
  6. data/buildr.gemspec +6 -2
  7. data/doc/artifacts.textile +6 -0
  8. data/doc/contributing.textile +3 -0
  9. data/doc/download.textile +60 -0
  10. data/doc/index.textile +9 -15
  11. data/doc/installing.textile +23 -6
  12. data/doc/mailing_lists.textile +4 -0
  13. data/doc/more_stuff.textile +333 -6
  14. data/doc/packaging.textile +187 -1
  15. data/lib/buildr.rb +8 -1
  16. data/lib/buildr/clojure.rb +34 -0
  17. data/lib/buildr/clojure/shell.rb +52 -0
  18. data/lib/buildr/core.rb +3 -0
  19. data/lib/buildr/core/#application.rb# +700 -0
  20. data/lib/buildr/core/application.rb +18 -8
  21. data/lib/buildr/core/build.rb +2 -2
  22. data/lib/buildr/core/cc.rb +57 -63
  23. data/lib/buildr/core/checks.rb +4 -5
  24. data/lib/buildr/core/doc.rb +3 -1
  25. data/lib/buildr/core/generate.rb +2 -0
  26. data/lib/buildr/core/jrebel.rb +42 -0
  27. data/lib/buildr/core/linux.rb +30 -0
  28. data/lib/buildr/core/project.rb +9 -8
  29. data/lib/buildr/core/run.rb +3 -3
  30. data/lib/buildr/core/shell.rb +29 -90
  31. data/lib/buildr/core/test.rb +3 -3
  32. data/lib/buildr/core/transports.rb +5 -5
  33. data/lib/buildr/core/util.rb +2 -2
  34. data/lib/buildr/groovy.rb +1 -0
  35. data/lib/buildr/groovy/compiler.rb +12 -1
  36. data/lib/buildr/groovy/doc.rb +76 -0
  37. data/lib/buildr/groovy/shell.rb +24 -15
  38. data/lib/buildr/ide.rb +1 -1
  39. data/lib/buildr/ide/idea.rb +527 -141
  40. data/lib/buildr/java/bdd.rb +18 -13
  41. data/lib/buildr/java/ecj.rb +1 -3
  42. data/lib/buildr/java/jtestr_result.rb +295 -0
  43. data/lib/buildr/java/jtestr_runner.rb.erb +4 -6
  44. data/lib/buildr/java/packaging.rb +14 -3
  45. data/lib/buildr/java/pom.rb +6 -2
  46. data/lib/buildr/java/test_result.rb +15 -243
  47. data/lib/buildr/java/tests.rb +1 -1
  48. data/lib/buildr/packaging.rb +2 -1
  49. data/lib/buildr/packaging/#package.rb.rej# +19 -0
  50. data/lib/buildr/packaging/archive.rb +13 -3
  51. data/lib/buildr/packaging/artifact.rb +11 -12
  52. data/lib/buildr/packaging/tar.rb +4 -1
  53. data/lib/buildr/packaging/zip.rb +106 -1
  54. data/lib/buildr/resources/completed.png +0 -0
  55. data/lib/buildr/resources/failed.png +0 -0
  56. data/lib/buildr/resources/icons-license.txt +17 -0
  57. data/lib/buildr/run.rb +7 -14
  58. data/lib/buildr/scala/#Untitled-2# +7 -0
  59. data/lib/buildr/scala/bdd.rb +1 -1
  60. data/lib/buildr/scala/compiler.rb +1 -1
  61. data/lib/buildr/scala/doc.rb +20 -2
  62. data/lib/buildr/scala/shell.rb +14 -22
  63. data/lib/buildr/scala/tests.rb +2 -2
  64. data/lib/buildr/shell.rb +113 -108
  65. data/lib/buildr/version.rb +1 -1
  66. data/rakelib/checks.rake +9 -7
  67. data/rakelib/doc.rake +10 -0
  68. data/rakelib/release.rake +9 -0
  69. data/rakelib/rspec.rake +27 -28
  70. data/rakelib/setup.rake +1 -1
  71. data/rakelib/stage.rake +2 -2
  72. data/spec/addon/bnd_spec.rb +330 -0
  73. data/spec/addon/jaxb_xjc_spec.rb +125 -0
  74. data/spec/core/application_spec.rb +1 -1
  75. data/spec/core/build_spec.rb +7 -7
  76. data/spec/core/cc_spec.rb +154 -104
  77. data/spec/core/compile_spec.rb +3 -3
  78. data/spec/core/project_spec.rb +10 -0
  79. data/spec/core/run_spec.rb +1 -0
  80. data/spec/core/shell_spec.rb +146 -0
  81. data/spec/groovy/doc_spec.rb +65 -0
  82. data/spec/ide/eclipse_spec.rb +1 -1
  83. data/spec/ide/idea_spec.rb +1145 -0
  84. data/spec/java/bdd_spec.rb +3 -3
  85. data/spec/java/emma_spec.rb +2 -0
  86. data/spec/java/packaging_spec.rb +40 -11
  87. data/spec/java/test_coverage_helper.rb +1 -1
  88. data/spec/packaging/archive_spec.rb +76 -21
  89. data/spec/packaging/artifact_namespace_spec.rb +1 -1
  90. data/spec/packaging/artifact_spec.rb +14 -7
  91. data/spec/sandbox.rb +11 -4
  92. data/spec/scala/bdd_spec.rb +2 -2
  93. data/spec/scala/compiler_spec.rb +2 -2
  94. data/spec/scala/doc_spec.rb +24 -4
  95. data/spec/scala/scala.rb +2 -2
  96. data/spec/scala/tests_spec.rb +2 -2
  97. data/spec/spec_helpers.rb +9 -8
  98. data/spec/xpath_matchers.rb +121 -0
  99. metadata +246 -166
  100. data/lib/buildr/ide/idea.ipr.template +0 -300
  101. data/lib/buildr/ide/idea7x.ipr.template +0 -290
  102. data/lib/buildr/ide/idea7x.rb +0 -231
  103. data/spec/ide/idea7x_spec.rb +0 -96
@@ -160,11 +160,11 @@ module Buildr
160
160
  def install
161
161
  invoke
162
162
  in_local_repository = Buildr.repositories.locate(self)
163
+ if pom && pom != self && classifier.nil?
164
+ pom.invoke
165
+ pom.install
166
+ end
163
167
  if name != in_local_repository
164
- if pom && pom != self
165
- pom.invoke
166
- pom.install
167
- end
168
168
  mkpath File.dirname(in_local_repository)
169
169
  cp name, in_local_repository, :preserve => false
170
170
  info "Installed #{name} to #{in_local_repository}"
@@ -174,7 +174,7 @@ module Buildr
174
174
  def uninstall
175
175
  installed = Buildr.repositories.locate(self)
176
176
  rm installed if File.exist?(installed)
177
- pom.uninstall if pom && pom != self
177
+ pom.uninstall if pom && pom != self && classifier.nil?
178
178
  end
179
179
 
180
180
  # :call-seq:
@@ -208,7 +208,7 @@ module Buildr
208
208
 
209
209
  unless task = Buildr.application.lookup(uri+path)
210
210
  deps = [self]
211
- deps << pom.upload_task( upload_to ) if pom && pom != self
211
+ deps << pom.upload_task( upload_to ) if pom && pom != self && classifier.nil?
212
212
 
213
213
  task = Rake::Task.define_task uri + path => deps do
214
214
  # Upload artifact relative to base URL, need to create path before uploading.
@@ -353,7 +353,7 @@ module Buildr
353
353
  if download_needed? task
354
354
  info "Downloading #{to_spec}"
355
355
  download
356
- pom.invoke rescue nil if pom && pom != self
356
+ pom.invoke rescue nil if pom && pom != self && classifier.nil?
357
357
  end
358
358
  end
359
359
  end
@@ -869,16 +869,15 @@ module Buildr
869
869
  # install artifact('group:id:jar:1.0').from('some_jar.jar')
870
870
  # $ buildr install
871
871
  def install(*args, &block)
872
- artifacts = artifacts(args)
872
+ artifacts = artifacts(args).uniq
873
873
  raise ArgumentError, 'This method can only install artifacts' unless artifacts.all? { |f| f.respond_to?(:to_spec) }
874
- all = (artifacts + artifacts.map { |artifact| artifact.pom }).uniq
875
874
  task('install').tap do |install|
876
- install.enhance(all) do
877
- all.each(&:install)
875
+ install.enhance(artifacts) do
876
+ artifacts.each(&:install)
878
877
  end
879
878
  install.enhance &block if block
880
879
  task('uninstall') do
881
- all.map(&:to_s ).each { |file| rm file if File.exist?(file) }
880
+ artifacts.map(&:to_s ).each { |file| rm file if File.exist?(file) }
882
881
  end
883
882
  end
884
883
  end
@@ -95,7 +95,10 @@ module Buildr
95
95
  file_map.each do |path, content|
96
96
  if content.respond_to?(:call)
97
97
  tar.add_file(path, options) { |os, opts| content.call os }
98
- elsif content.nil? || File.directory?(content.to_s)
98
+ elsif content.nil?
99
+ elsif File.directory?(content.to_s)
100
+ stat = File.stat(content.to_s)
101
+ tar.mkdir(path, options.merge(:mode=>stat.mode, :mtime=>stat.mtime))
99
102
  else
100
103
  File.open content.to_s, 'rb' do |is|
101
104
  tar.add_file path, options.merge(:mode=>is.stat.mode, :mtime=>is.stat.mtime, :uid=>is.stat.uid, :gid=>is.stat.gid) do |os, opts|
@@ -17,17 +17,19 @@
17
17
  if RUBY_VERSION >= '1.9.0' # Required to properly load RubyZip under Ruby 1.9
18
18
  $LOADED_FEATURES.unshift 'ftools'
19
19
  require 'fileutils'
20
+
20
21
  def File.move(source, dest)
21
22
  FileUtils.move source, dest
22
23
  end
24
+
23
25
  def File.rm_rf(path)
24
26
  FileUtils.rm_rf path
25
27
  end
26
28
  end
29
+
27
30
  require 'zip/zip'
28
31
  require 'zip/zipfilesystem'
29
32
 
30
-
31
33
  module Zip #:nodoc:
32
34
 
33
35
  class ZipCentralDirectory #:nodoc:
@@ -69,5 +71,108 @@ module Zip #:nodoc:
69
71
  all? { |pattern| content =~ pattern }
70
72
  end
71
73
 
74
+ # Override of write_c_dir_entry to fix comments being set to a fixnum instead of string
75
+ def write_c_dir_entry(io) #:nodoc:all
76
+ case @fstype
77
+ when FSTYPE_UNIX
78
+ ft = nil
79
+ case @ftype
80
+ when :file
81
+ ft = 010
82
+ @unix_perms ||= 0644
83
+ when :directory
84
+ ft = 004
85
+ @unix_perms ||= 0755
86
+ when :symlink
87
+ ft = 012
88
+ @unix_perms ||= 0755
89
+ else
90
+ raise ZipInternalError, "unknown file type #{self.inspect}"
91
+ end
92
+
93
+ @externalFileAttributes = (ft << 12 | (@unix_perms & 07777)) << 16
94
+ end
95
+
96
+ io <<
97
+ [0x02014b50,
98
+ @version, # version of encoding software
99
+ @fstype, # filesystem type
100
+ 10, # @versionNeededToExtract
101
+ 0, # @gp_flags
102
+ @compression_method,
103
+ @time.to_binary_dos_time, # @lastModTime
104
+ @time.to_binary_dos_date, # @lastModDate
105
+ @crc,
106
+ @compressed_size,
107
+ @size,
108
+ @name ? @name.length : 0,
109
+ @extra ? @extra.c_dir_length : 0,
110
+ @comment ? comment.to_s.length : 0,
111
+ 0, # disk number start
112
+ @internalFileAttributes, # file type (binary=0, text=1)
113
+ @externalFileAttributes, # native filesystem attributes
114
+ @localHeaderOffset,
115
+ @name,
116
+ @extra,
117
+ @comment
118
+ ].pack('VCCvvvvvVVVvvvvvVV')
119
+
120
+ io << @name
121
+ io << (@extra ? @extra.to_c_dir_bin : "")
122
+ io << @comment
123
+ end
124
+
125
+ # Override write_c_dir_entry to fix comments being set to a fixnum instead of string
126
+ def write_c_dir_entry(io) #:nodoc:all
127
+ @comment = "" if @comment.nil? || @comment == -1 # Hack fix @comment being nil or fixnum -1
128
+
129
+ case @fstype
130
+ when FSTYPE_UNIX
131
+ ft = nil
132
+ case @ftype
133
+ when :file
134
+ ft = 010
135
+ @unix_perms ||= 0644
136
+ when :directory
137
+ ft = 004
138
+ @unix_perms ||= 0755
139
+ when :symlink
140
+ ft = 012
141
+ @unix_perms ||= 0755
142
+ else
143
+ raise ZipInternalError, "unknown file type #{self.inspect}"
144
+ end
145
+
146
+ @externalFileAttributes = (ft << 12 | (@unix_perms & 07777)) << 16
147
+ end
148
+
149
+ io <<
150
+ [0x02014b50,
151
+ @version, # version of encoding software
152
+ @fstype, # filesystem type
153
+ 10, # @versionNeededToExtract
154
+ 0, # @gp_flags
155
+ @compression_method,
156
+ @time.to_binary_dos_time, # @lastModTime
157
+ @time.to_binary_dos_date, # @lastModDate
158
+ @crc,
159
+ @compressed_size,
160
+ @size,
161
+ @name ? @name.length : 0,
162
+ @extra ? @extra.c_dir_length : 0,
163
+ @comment ? @comment.length : 0,
164
+ 0, # disk number start
165
+ @internalFileAttributes, # file type (binary=0, text=1)
166
+ @externalFileAttributes, # native filesystem attributes
167
+ @localHeaderOffset,
168
+ @name,
169
+ @extra,
170
+ @comment].pack('VCCvvvvvVVVvvvvvVV')
171
+
172
+ io << @name
173
+ io << (@extra ? @extra.to_c_dir_bin : "")
174
+ io << @comment
175
+
176
+ end
72
177
  end
73
178
  end
Binary file
Binary file
@@ -0,0 +1,17 @@
1
+
2
+ MouseRunner.com Green/Red icons
3
+ -------------------------------
4
+
5
+ The graphics contained in the 'completed.png' and 'failed.png' files are
6
+ licensed under the Creative Commons Attribution-ShareAlike 2.5 License
7
+
8
+ Furthermore,
9
+ You may not claim the works as your own.
10
+ You must provide a link back to www.MouseRunner.com when using on a website,
11
+ for commercial purposes, and for applications.
12
+
13
+ Visit the address below to learn more about the Creative Commons license.
14
+ http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode
15
+
16
+
17
+
data/lib/buildr/run.rb CHANGED
@@ -43,15 +43,15 @@ module Buildr
43
43
  attr_reader :project
44
44
 
45
45
  class << self
46
- attr_accessor :name, :languages
46
+ attr_accessor :runner_name, :languages
47
47
 
48
48
  def specify(options)
49
- @name ||= options[:name]
49
+ @runner_name ||= options[:name]
50
50
  @languages ||= options[:languages]
51
51
  end
52
52
 
53
53
  def to_sym
54
- @name ||= name.split('::').last.downcase.to_sym
54
+ @runner_name || name.split('::').last.downcase.to_sym
55
55
  end
56
56
  end
57
57
 
@@ -128,19 +128,12 @@ module Buildr
128
128
  @runner ||= guess_runner
129
129
  end
130
130
 
131
- # :call-seq:
132
- # runner?(clazz) => boolean
133
- #
134
- # Check if the underlying runner is an instance of the given class.
135
- # If no class is supplied, simply check if runner is defined.
136
- def runner?(clazz = nil)
137
- begin
138
- @runner ||= guess_runner if project.compile.language
131
+ def runner?
132
+ @runner ||= begin
133
+ guess_runner if project.compile.language
139
134
  rescue
140
- return false
135
+ nil
141
136
  end
142
- return !@runner.nil? unless clazz
143
- @runner.is_a?(clazz) if @runner
144
137
  end
145
138
 
146
139
  def run
@@ -0,0 +1,7 @@
1
+
2
+ -server started
3
+
4
+ -update cube-common
5
+
6
+ -move existing data to new sugarcube server
7
+
@@ -32,7 +32,7 @@ module Buildr::Scala
32
32
  @lang = :scala
33
33
  @bdd_dir = :spec
34
34
 
35
- VERSION = '1.6.5'
35
+ VERSION = '1.6.6'
36
36
 
37
37
  class << self
38
38
  def version
@@ -19,7 +19,7 @@ require 'buildr/core/compile'
19
19
  require 'buildr/packaging'
20
20
 
21
21
  module Buildr::Scala
22
- DEFAULT_VERSION = '2.8.0'
22
+ DEFAULT_VERSION = '2.8.1'
23
23
 
24
24
  class << self
25
25
 
@@ -61,8 +61,11 @@ module Buildr
61
61
  info "Generating Scaladoc for #{project.name}"
62
62
  trace (['scaladoc'] + cmd_args).join(' ')
63
63
  Java.load
64
- Java.scala.tools.nsc.ScalaDoc.main(cmd_args.to_java(Java.java.lang.String)) == 0 or
65
- fail 'Failed to generate Scaladocs, see errors above'
64
+ begin
65
+ Java.scala.tools.nsc.ScalaDoc.process(cmd_args.to_java(Java.java.lang.String))
66
+ rescue => e
67
+ fail 'Failed to generate Scaladocs, see errors above: ' + e
68
+ end
66
69
  end
67
70
  end
68
71
  end
@@ -115,8 +118,23 @@ module Buildr
115
118
  end
116
119
  end
117
120
 
121
+ module Packaging
122
+ module Scala
123
+ def package_as_scaladoc_spec(spec) #:nodoc:
124
+ spec.merge(:type=>:jar, :classifier=>'scaladoc')
125
+ end
126
+
127
+ def package_as_scaladoc(file_name) #:nodoc:
128
+ ZipTask.define_task(file_name).tap do |zip|
129
+ zip.include :from=>doc.target
130
+ end
131
+ end
132
+ end
133
+ end
134
+
118
135
  class Project
119
136
  include ScaladocDefaults
137
+ include Packaging::Scala
120
138
  end
121
139
  end
122
140
 
@@ -20,41 +20,33 @@ require 'buildr/java/commands'
20
20
  module Buildr
21
21
  module Scala
22
22
  class ScalaShell < Buildr::Shell::Base
23
- include Buildr::Shell::JavaRebel
23
+ include Buildr::JRebel
24
24
 
25
- class << self
26
- def lang
27
- :scala
28
- end
25
+ specify :name => :scala, :languages => [:scala]
29
26
 
30
- def to_sym
31
- :scala
32
- end
33
- end
27
+ def launch(task)
28
+ jline = [File.expand_path("lib/jline.jar", Scalac.scala_home)].find_all { |f| File.exist? f }
29
+ jline = ['jline:jline:jar:0.9.94'] if jline.empty?
34
30
 
35
- def launch
36
31
  cp = project.compile.dependencies +
37
- Scalac.dependencies +
38
- [project.path_to(:target, :classes)]
32
+ Scalac.dependencies +
33
+ project.test.dependencies +
34
+ task.classpath
39
35
 
40
- props = {
41
- 'scala.home' => Scalac.scala_home
42
- }
36
+ java_args = jrebel_args + task.java_args
43
37
 
44
- jline = [File.expand_path("lib/jline.jar", Scalac.scala_home)].find_all do |f|
45
- File.exist? f
46
- end
38
+ props = jrebel_props(project).merge(task.properties)
47
39
 
48
40
  Java::Commands.java 'scala.tools.nsc.MainGenericRunner',
49
41
  '-cp', cp.join(File::PATH_SEPARATOR),
50
42
  {
51
- :properties => props.merge(rebel_props(project)),
52
- :classpath => Scalac.dependencies + jline,
53
- :java_args => rebel_args
43
+ :properties => props,
44
+ :classpath => cp + jline,
45
+ :java_args => java_args
54
46
  }
55
47
  end
56
48
  end
57
49
  end
58
50
  end
59
51
 
60
- Buildr::ShellProviders << Buildr::Scala::ScalaShell
52
+ Buildr::Shell.providers << Buildr::Scala::ScalaShell
@@ -23,7 +23,7 @@ require 'buildr/java/tests'
23
23
  module Buildr::Scala
24
24
  # Scala::Check is available when using Scala::Test or Scala::Specs
25
25
  module Check
26
- VERSION = '1.7'
26
+ VERSION = '1.8'
27
27
 
28
28
  class << self
29
29
  def version
@@ -60,7 +60,7 @@ module Buildr::Scala
60
60
  # * :java_args -- Arguments passed as is to the JVM.
61
61
  class ScalaTest < Buildr::TestFramework::Java
62
62
 
63
- VERSION = '1.2'
63
+ VERSION = '1.3'
64
64
 
65
65
  class << self
66
66
  def version
data/lib/buildr/shell.rb CHANGED
@@ -15,49 +15,73 @@
15
15
 
16
16
 
17
17
  module Buildr
18
- module ShellProviders
18
+ module Shell
19
+ include Extension
20
+
19
21
  class << self
20
- def add(p)
21
- @providers ||= {}
22
-
23
- if p.lang == :none
24
- @providers[:none] ||= []
25
- @providers[:none] << p
26
- else
27
- @providers[p.lang] = p
28
- end
22
+ def providers
23
+ @providers ||= []
29
24
  end
30
- alias :<< :add
31
25
 
32
- def providers
33
- @providers ||= {}
26
+ def select_by_lang(lang)
27
+ fail 'Unable to define shell task for nil language' if lang.nil?
28
+ providers.detect { |e| e.languages.nil? ? false : e.languages.include?(lang.to_sym) }
29
+ end
30
+
31
+ alias_method :select, :select_by_lang
32
+
33
+ def select_by_name(name)
34
+ fail 'Unable to define run task for nil' if name.nil?
35
+ providers.detect { |e| e.to_sym == name.to_sym }
34
36
  end
35
37
 
36
- def each
37
- providers.each do |lang, p|
38
- if lang == :none
39
- p.each do |x|
40
- yield x
41
- end
42
- else
43
- yield p
38
+ def define_task(project, name, provider = nil)
39
+ ShellTask.define_task(name).tap do |t|
40
+ t.send(:associate_with, project)
41
+ t.enhance([project.compile]) do |t|
42
+ # double-enhance to execute the provider last
43
+ t.enhance { |t| t.run }
44
44
  end
45
+ t.using provider.to_sym if provider
45
46
  end
46
47
  end
47
48
  end
48
- end
49
49
 
50
- module Shell
50
+ first_time do
51
+ Project.local_task 'shell'
52
+
53
+ providers.each { |provider| Project.local_task "shell:#{provider.to_sym}" }
54
+ end
55
+
56
+ before_define(:shell => :compile) do |project|
57
+ define_task(project, "shell")
58
+ providers.each { |provider| define_task(project, "shell:#{provider.to_sym}", provider) }
59
+ end
60
+
61
+ after_define(:shell => :compile) do |project|
62
+ unless project.shell.provider
63
+ provider = providers.find { |p| p.languages.include? project.compile.language if p.languages }
64
+ if provider
65
+ project.shell.using provider.to_sym
66
+ project.shell.with project.test.compile.dependencies
67
+ end
68
+ end
69
+ end
70
+
71
+ # Base class for any shell provider.
51
72
  class Base
52
- attr_reader :project
73
+ attr_reader :project # :nodoc:
53
74
 
54
75
  class << self
55
- def lang
56
- :none
76
+ attr_accessor :shell_name, :languages
77
+
78
+ def specify(options)
79
+ @shell_name ||= options[:name]
80
+ @languages ||= options[:languages]
57
81
  end
58
82
 
59
83
  def to_sym
60
- @symbol ||= name.split('::').last.downcase.to_sym
84
+ @shell_name || name.split('::').last.downcase.to_sym
61
85
  end
62
86
  end
63
87
 
@@ -65,116 +89,97 @@ module Buildr
65
89
  @project = project
66
90
  end
67
91
 
68
- def build?
69
- true
70
- end
71
-
72
- def launch
92
+ def launch(task)
73
93
  fail 'Not implemented'
74
94
  end
95
+
75
96
  end
76
97
 
77
- module JavaRebel
78
- def rebel_home
79
- unless @rebel_home
80
- @rebel_home = ENV['REBEL_HOME'] || ENV['JREBEL'] || ENV['JREBEL_HOME']
98
+ class ShellTask < Rake::Task
99
+ attr_reader :project # :nodoc:
81
100
 
82
- if @rebel_home and File.directory? @rebel_home
83
- @rebel_home += File::SEPARATOR + 'jrebel.jar'
84
- end
85
- end
101
+ # Classpath dependencies.
102
+ attr_accessor :classpath
86
103
 
87
- if @rebel_home and File.exists? @rebel_home
88
- @rebel_home
89
- else
90
- nil
91
- end
92
- end
104
+ # Returns the run options.
105
+ attr_reader :options
93
106
 
94
- def rebel_args
95
- if rebel_home
96
- [
97
- '-noverify',
98
- "-javaagent:#{rebel_home}"
99
- ]
100
- else
101
- []
102
- end
103
- end
107
+ # Underlying shell provider
108
+ attr_reader :provider
104
109
 
105
- def rebel_props(project)
106
- {}
110
+ def initialize(*args) # :nodoc:
111
+ super
112
+ @options = {}
113
+ @classpath = []
107
114
  end
108
- end
109
- end
110
-
111
- module ShellExtension
112
- include Extension
113
115
 
114
- first_time do
115
- Project.local_task 'shell'
116
-
117
- ShellProviders.each { |p| Project.local_task "shell:#{p.to_sym}" } # TODO not working
118
- end
119
-
120
- before_define(:shell => :compile) do |project|
121
- ShellProviders.each do |p|
122
- name = p.to_sym
123
-
124
- trace "Defining task #{project.name}:shell:#{name}"
116
+ # :call-seq:
117
+ # with(*artifacts) => self
118
+ #
119
+ # Adds files and artifacts as classpath dependencies, and returns self.
120
+ def with(*specs)
121
+ @classpath |= Buildr.artifacts(specs.flatten).uniq
122
+ self
123
+ end
125
124
 
126
- p_inst = p.new project
127
- deps = if p_inst.build? then [:compile] else [] end
125
+ # :call-seq:
126
+ # using(options) => self
127
+ #
128
+ # Sets the run options from a hash and returns self.
129
+ #
130
+ # For example:
131
+ # shell.using :properties => {'foo' => 'bar'}
132
+ # shell.using :bsh
133
+ def using(*args)
134
+ if Hash === args.last
135
+ args.pop.each { |key, value| @options[key.to_sym] = value }
136
+ end
128
137
 
129
- project.task "shell:#{name}" => deps do
130
- trace "Launching #{name} shell"
131
- p_inst.launch
138
+ until args.empty?
139
+ new_shell = Shell.select_by_name(args.pop)
140
+ @provider = new_shell.new(project) unless new_shell.nil?
132
141
  end
133
- end
134
- end
135
142
 
136
- after_define(:shell => :compile) do |project|
137
- default_shell = project.shell.using
143
+ self
144
+ end
138
145
 
139
- if default_shell
140
- dep = "shell:#{default_shell.to_sym}"
146
+ def run
147
+ fail "No shell provider defined in project '#{project.name}' for language '#{project.compile.language.inspect}'" unless provider
148
+ provider.launch(self)
149
+ end
141
150
 
142
- trace "Defining task shell based on #{dep}"
143
- project.task :shell => dep
144
- else
145
- project.task :shell do
146
- fail "No shell provider defined for language '#{project.compile.language}'"
147
- end
151
+ def prerequisites #:nodoc:
152
+ super + classpath
148
153
  end
149
- end
150
154
 
151
- class ShellConfig
152
- def initialize(project)
153
- @project = project
155
+ def java_args
156
+ @options[:java_args] || (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split
154
157
  end
155
158
 
156
- def using(*args)
157
- if args.size > 0
158
- @using ||= args.first
159
- else
160
- @using ||= find_shell_task
161
- end
159
+ def properties
160
+ @options[:properties] || {}
162
161
  end
163
162
 
164
163
  private
165
- def find_shell_task
166
- lang = @project.compile.language
167
- ShellProviders.providers[lang]
164
+ def associate_with(project)
165
+ @project ||= project
168
166
  end
167
+
169
168
  end
170
169
 
171
- # TODO temporary hack
172
- def shell
173
- @shell ||= ShellConfig.new self
170
+ # :call-seq:
171
+ # shell(&block) => ShellTask
172
+ #
173
+ # This method returns the project's shell task. It also accepts a block to be executed
174
+ # when the shell task is invoked.
175
+ def shell(&block)
176
+ task('shell').tap do |t|
177
+ t.enhance &block if block
178
+ end
174
179
  end
175
180
  end
176
181
 
177
182
  class Project
178
- include ShellExtension
183
+ include Shell
179
184
  end
180
185
  end