buildr 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/CHANGELOG +35 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +1 -1
  4. data/buildr.buildfile +6 -1
  5. data/buildr.gemspec +10 -9
  6. data/doc/_config.yml +1 -0
  7. data/doc/_layouts/default.html +25 -19
  8. data/doc/artifacts.textile +0 -36
  9. data/doc/building.textile +0 -38
  10. data/doc/contributing.textile +51 -15
  11. data/doc/css/default.css +11 -4
  12. data/doc/css/print.css +32 -24
  13. data/doc/download.textile +2 -1
  14. data/doc/extending.textile +10 -20
  15. data/doc/images/1442160941-frontcover.jpg +0 -0
  16. data/doc/images/asf-logo.png +0 -0
  17. data/doc/images/note.png +0 -0
  18. data/doc/images/project-structure.png +0 -0
  19. data/doc/images/tip.png +0 -0
  20. data/doc/images/zbuildr.png +0 -0
  21. data/doc/index.textile +39 -17
  22. data/doc/{getting_started.textile → installing.textile} +2 -67
  23. data/doc/languages.textile +50 -52
  24. data/doc/more_stuff.textile +154 -62
  25. data/doc/packaging.textile +0 -82
  26. data/doc/preface.textile +41 -15
  27. data/doc/projects.textile +0 -18
  28. data/doc/quick_start.textile +210 -0
  29. data/doc/scripts/install-linux.sh +10 -2
  30. data/doc/settings_profiles.textile +1 -33
  31. data/doc/testing.textile +6 -32
  32. data/lib/buildr.rb +2 -1
  33. data/lib/buildr/core.rb +6 -0
  34. data/lib/buildr/core/application.rb +2 -5
  35. data/lib/buildr/core/build.rb +29 -19
  36. data/lib/buildr/core/compile.rb +22 -4
  37. data/lib/buildr/core/filter.rb +2 -4
  38. data/lib/buildr/core/project.rb +5 -4
  39. data/lib/buildr/core/shell.rb +198 -0
  40. data/lib/buildr/core/test.rb +2 -0
  41. data/lib/buildr/core/transports.rb +18 -19
  42. data/lib/buildr/core/util.rb +178 -9
  43. data/lib/buildr/groovy.rb +1 -0
  44. data/lib/buildr/groovy/bdd.rb +5 -5
  45. data/lib/buildr/groovy/shell.rb +48 -0
  46. data/lib/buildr/ide/eclipse.rb +148 -36
  47. data/lib/buildr/ide/eclipse/java.rb +53 -0
  48. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  49. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  50. data/lib/buildr/java/bdd.rb +16 -8
  51. data/lib/buildr/java/cobertura.rb +44 -13
  52. data/lib/buildr/java/commands.rb +5 -3
  53. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  54. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +18 -0
  55. data/lib/buildr/java/packaging.rb +2 -2
  56. data/lib/buildr/java/rjb.rb +1 -1
  57. data/lib/buildr/java/test_result.rb +48 -1
  58. data/lib/buildr/java/tests.rb +8 -5
  59. data/lib/buildr/packaging/artifact_namespace.rb +1 -1
  60. data/lib/buildr/packaging/package.rb +6 -2
  61. data/lib/buildr/packaging/zip.rb +10 -1
  62. data/lib/buildr/packaging/ziptask.rb +5 -2
  63. data/lib/buildr/scala.rb +1 -0
  64. data/lib/buildr/scala/bdd.rb +17 -8
  65. data/lib/buildr/scala/compiler.rb +66 -21
  66. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  67. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  68. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  69. data/lib/buildr/scala/shell.rb +55 -0
  70. data/lib/buildr/scala/tests.rb +6 -5
  71. data/lib/buildr/shell.rb +180 -0
  72. data/rakelib/doc.rake +2 -3
  73. data/rakelib/jekylltask.rb +42 -32
  74. data/rakelib/package.rake +4 -2
  75. data/rakelib/rspec.rake +3 -3
  76. data/rakelib/setup.rake +7 -1
  77. data/rakelib/stage.rake +9 -2
  78. data/rakelib/stage.rake~ +213 -0
  79. data/spec/core/application_spec.rb +84 -1
  80. data/spec/core/build_spec.rb +54 -2
  81. data/spec/core/common_spec.rb +1 -1
  82. data/spec/core/compile_spec.rb +2 -1
  83. data/spec/core/extension_spec.rb +93 -0
  84. data/spec/core/test_spec.rb +2 -2
  85. data/spec/core/transport_spec.rb +1 -1
  86. data/spec/groovy/bdd_spec.rb +6 -6
  87. data/spec/groovy/compiler_spec.rb +1 -0
  88. data/spec/ide/eclipse_spec.rb +262 -72
  89. data/spec/java/{ant.rb → ant_spec.rb} +0 -0
  90. data/spec/java/bdd_spec.rb +15 -0
  91. data/spec/java/cobertura_spec.rb +9 -1
  92. data/spec/java/emma_spec.rb +1 -1
  93. data/spec/java/java_spec.rb +26 -0
  94. data/spec/java/packaging_spec.rb +9 -7
  95. data/spec/java/{test_coverage_spec.rb → test_coverage_helper.rb} +6 -4
  96. data/spec/java/tests_spec.rb +22 -0
  97. data/spec/packaging/archive_spec.rb +14 -0
  98. data/spec/packaging/artifact_spec.rb +2 -2
  99. data/spec/packaging/packaging_spec.rb +97 -2
  100. data/spec/sandbox.rb +3 -1
  101. data/spec/scala/bdd_spec.rb +17 -48
  102. data/spec/scala/compiler_spec.rb +31 -2
  103. data/spec/scala/tests_spec.rb +1 -0
  104. data/spec/spec_helpers.rb +12 -0
  105. metadata +145 -148
@@ -68,6 +68,53 @@ module Buildr #:nodoc:
68
68
  module_eval "def #{meth}(*args); end"
69
69
  end
70
70
 
71
+ def example_group_started(example_group)
72
+ @example_group = example_group
73
+ end
74
+
75
+ def example_passed(example)
76
+ result.succeeded << example_group.location.gsub(/:\d+$/, '')
77
+ end
78
+
79
+ def example_pending(example, counter, failure)
80
+ result.succeeded << example_group.location.gsub(/:\d+$/, '')
81
+ end
82
+
83
+ def example_failed(example, counter, failure)
84
+ result.failed << example_group.location.gsub(/:\d+$/, '')
85
+ end
86
+
87
+ def start(example_count)
88
+ @result = TestResult.new
89
+ end
90
+
91
+ def close
92
+ result.succeeded = result.succeeded - result.failed
93
+ FileUtils.mkdir_p File.dirname(where)
94
+ File.open(where, 'w') { |f| f.puts YAML.dump(result) }
95
+ end
96
+ end # YamlFormatter
97
+
98
+ # Rspec formatter used for JtestR
99
+ # (JtestR provides its own version of rspec)
100
+ class JtestRYamlFormatter
101
+ attr_reader :result
102
+
103
+ attr_accessor :example_group, :options, :where
104
+
105
+ def initialize(options, where)
106
+ @options = options
107
+ @where = where
108
+ @result = Hash.new
109
+ @result[:succeeded] = []
110
+ @result[:failed] = []
111
+ end
112
+
113
+ %w[ example_started
114
+ start_dump dump_failure dump_summary dump_pending ].each do |meth|
115
+ module_eval "def #{meth}(*args); end"
116
+ end
117
+
71
118
  def add_example_group(example_group)
72
119
  @example_group = example_group
73
120
  end
@@ -108,7 +155,7 @@ module Buildr #:nodoc:
108
155
  FileUtils.mkdir_p File.dirname(where)
109
156
  File.open(where, 'w') { |f| f.puts YAML.dump(result) }
110
157
  end
111
- end # YamlFormatter
158
+ end # JtestRYamlFormatter
112
159
 
113
160
  # A JtestR ResultHandler
114
161
  # Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR
@@ -46,6 +46,7 @@ module Buildr
46
46
  # * :interfaces -- List of java interfaces or java classes
47
47
  # * :class_annotations -- List of annotations on class level
48
48
  # * :method_annotations -- List of annotations on method level
49
+ # * :fields -- List of java field names
49
50
  #
50
51
  def filter_classes(dependencies, criteria = {})
51
52
  return [] unless task.compile.target
@@ -69,13 +70,14 @@ module Buildr
69
70
  if criteria[:method_annotations]
70
71
  filter.add_method_annotations(criteria[:method_annotations].to_java(Java.java.lang.String))
71
72
  end
73
+ if criteria[:fields]
74
+ filter.add_fields(criteria[:fields].to_java(Java.java.lang.String))
75
+ end
72
76
  result.concat filter.filter(candidates.to_java(Java.java.lang.String)).map(&:to_s)
73
77
  rescue =>ex
74
78
  info "#{ex.class}: #{ex.message}"
75
79
  raise
76
80
  end
77
- # We strip Scala singleton objects whose .class ends with $
78
- result.map { |c| (c =~ /\$$/) ? c[0..(c.size - 2)] : c }.uniq
79
81
  end
80
82
 
81
83
  end
@@ -165,7 +167,7 @@ module Buildr
165
167
  end
166
168
 
167
169
  # JUnit version number.
168
- VERSION = '4.4'
170
+ VERSION = '4.5'
169
171
 
170
172
  class << self
171
173
  # :call-seq:
@@ -276,7 +278,7 @@ module Buildr
276
278
  # * :java_args -- Arguments passed to the JVM.
277
279
  class TestNG < TestFramework::Java
278
280
 
279
- VERSION = '5.7'
281
+ VERSION = '5.10'
280
282
 
281
283
  class << self
282
284
  def version
@@ -315,7 +317,8 @@ module Buildr
315
317
  rescue
316
318
  # testng-failed.xml contains the list of failed tests *only*
317
319
  report = File.read(File.join(task.report_to.to_s, 'testng-failed.xml'))
318
- failed = report.scan(/<class name="(.*)">/im).flatten
320
+ failed = report.scan(/<class name="(.*?)">/im).flatten
321
+ error "TestNG regexp returned unexpected failed tests #{failed.inspect}" unless (failed - tests).empty?
319
322
  # return the list of passed tests
320
323
  return tests - failed
321
324
  end
@@ -736,7 +736,7 @@ module Buildr
736
736
 
737
737
  # Like Hash#fetch
738
738
  def fetch(name, default = nil, &block)
739
- block ||= lambda { raise IndexError.new("No artifact found by name #{name.inspect} in namespace #{self}") }
739
+ block ||= proc { raise IndexError.new("No artifact found by name #{name.inspect} in namespace #{self}") }
740
740
  real_name = name.to_s[/^[\w\-\.]+$/] ? name : ArtifactRequirement.unversioned_spec(name)
741
741
  get(real_name.to_sym) || default || block.call(name)
742
742
  end
@@ -129,6 +129,7 @@ module Buildr
129
129
  # end
130
130
  def package(*args)
131
131
  spec = Hash === args.last ? args.pop.dup : {}
132
+ no_options = spec.empty? # since spec is mutated
132
133
  if spec[:file]
133
134
  rake_check_options spec, :file, :type
134
135
  spec[:type] = args.shift || spec[:type] || spec[:file].split('.').last
@@ -147,7 +148,10 @@ module Buildr
147
148
  spec = send("package_as_#{spec[:type]}_spec", spec) if respond_to?("package_as_#{spec[:type]}_spec")
148
149
  file_name = path_to(:target, Artifact.hash_to_file_name(spec))
149
150
  end
150
- package = packages.find { |pkg| pkg.name == file_name } || packager.call(file_name)
151
+ package = (no_options && packages.detect { |pkg| pkg.type == spec[:type] &&
152
+ (spec[:classifier].nil? || pkg.classifier == spec[:classifier])}) ||
153
+ packages.find { |pkg| pkg.name == file_name } ||
154
+ packager.call(file_name)
151
155
  else
152
156
  Buildr.application.deprecated "We changed the way package_as methods are implemented. See the package method documentation for more details."
153
157
  file_name ||= path_to(:target, Artifact.hash_to_file_name(spec))
@@ -164,7 +168,7 @@ module Buildr
164
168
 
165
169
  if spec[:file]
166
170
  class << package ; self ; end.send(:define_method, :type) { spec[:type] }
167
- elsif !package.respond_to?(:install)
171
+ else
168
172
  # Make it an artifact using the specifications, and tell it how to create a POM.
169
173
  package.extend ActsAsArtifact
170
174
  package.send :apply_spec, spec.only(*Artifact::ARTIFACT_ATTRIBUTES)
@@ -14,7 +14,16 @@
14
14
  # the License.
15
15
 
16
16
 
17
- $LOADED_FEATURES.unshift 'ftools' if RUBY_VERSION >= '1.9.0' # Required to properly load RubyZip under Ruby 1.9
17
+ if RUBY_VERSION >= '1.9.0' # Required to properly load RubyZip under Ruby 1.9
18
+ $LOADED_FEATURES.unshift 'ftools'
19
+ require 'fileutils'
20
+ def File.move(source, dest)
21
+ FileUtils.move source, dest
22
+ end
23
+ def File.rm_rf(path)
24
+ FileUtils.rm_rf path
25
+ end
26
+ end
18
27
  require 'zip/zip'
19
28
  require 'zip/zipfilesystem'
20
29
 
@@ -74,8 +74,9 @@ module Buildr
74
74
  elsif content.nil? || File.directory?(content.to_s)
75
75
  mkpath.call path
76
76
  else
77
- zip.put_next_entry(path, compression_level)
77
+ entry = zip.put_next_entry(path, compression_level)
78
78
  File.open content.to_s, 'rb' do |is|
79
+ entry.unix_perms = is.stat.mode & 07777
79
80
  while data = is.read(4096)
80
81
  zip << data
81
82
  end
@@ -122,7 +123,8 @@ module Buildr
122
123
 
123
124
  # Initialize with hash argument of the form target=>zip_file.
124
125
  def initialize(args)
125
- @target, arg_names, @zip_file = Buildr.application.resolve_args([args])
126
+ @target, arg_names, zip_file = Buildr.application.resolve_args([args])
127
+ @zip_file = zip_file.first
126
128
  @paths = {}
127
129
  end
128
130
 
@@ -154,6 +156,7 @@ module Buildr
154
156
  dest = File.expand_path(dest, target.to_s)
155
157
  trace "Extracting #{dest}"
156
158
  mkpath File.dirname(dest) rescue nil
159
+ entry.restore_permissions = true
157
160
  entry.extract(dest) { true }
158
161
  end
159
162
  end
@@ -20,5 +20,6 @@ Buildr.repositories.remote << 'http://scala-tools.org/repo-releases'
20
20
  require 'buildr/scala/compiler'
21
21
  require 'buildr/scala/tests'
22
22
  require 'buildr/scala/bdd'
23
+ require 'buildr/scala/shell'
23
24
 
24
25
  Object::Scala = Buildr::Scala
@@ -32,7 +32,7 @@ module Buildr::Scala
32
32
  @lang = :scala
33
33
  @bdd_dir = :spec
34
34
 
35
- VERSION = '1.4.3'
35
+ VERSION = '1.5.0'
36
36
 
37
37
  class << self
38
38
  def version
@@ -40,8 +40,7 @@ module Buildr::Scala
40
40
  end
41
41
 
42
42
  def dependencies
43
- ["org.specs:specs:jar:#{version}"] + Check.dependencies +
44
- JMock.dependencies + JUnit.dependencies
43
+ ["org.scala-tools.testing:specs:jar:#{version}"] + Check.dependencies + JUnit.dependencies
45
44
  end
46
45
 
47
46
  def applies_to?(project) #:nodoc:
@@ -68,20 +67,30 @@ module Buildr::Scala
68
67
 
69
68
  def tests(dependencies)
70
69
  dependencies += [task.compile.target.to_s]
71
- filter_classes(dependencies, :interfaces => ['org.specs.Specification'])
70
+ candidates = filter_classes(dependencies, :interfaces => ['org.specs.Specification'])
71
+
72
+ Java.load # Java is already loaded, but just in case
73
+
74
+ filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
75
+ filter.add_fields ['MODULE$'].to_java(Java.java.lang.String)
76
+ filter.filter(candidates.to_java(Java.java.lang.String)) # we only want singletons
72
77
  end
73
78
 
74
79
  def run(specs, dependencies) #:nodoc:
75
- dependencies += [task.compile.target.to_s] + Scalac.dependencies
80
+ dependencies += [task.compile.target.to_s, File.join(File.dirname(__FILE__))] + Scalac.dependencies
76
81
 
77
82
  cmd_options = { :properties => options[:properties],
78
83
  :java_args => options[:java_args],
79
84
  :classpath => dependencies}
80
-
85
+
86
+ runner = 'org.apache.buildr.SpecsSingletonRunner'
81
87
  specs.inject [] do |passed, spec|
82
88
  begin
83
- Java.load
84
- Java::Commands.java(spec, cmd_options)
89
+ unless Util.win_os?
90
+ Java::Commands.java(runner, task.compile.target.to_s, '-c', spec, cmd_options)
91
+ else
92
+ Java::Commands.java(runner, task.compile.target.to_s, spec, cmd_options)
93
+ end
85
94
  rescue => e
86
95
  passed
87
96
  else
@@ -19,18 +19,31 @@ require 'buildr/core/compile'
19
19
  require 'buildr/packaging'
20
20
 
21
21
  module Buildr::Scala
22
-
22
+ DEFAULT_VERSION = '2.7.5' # currently the latest (Jun 19, 2009)
23
+
23
24
  class << self
25
+
26
+ # Retrieves the Scala version string from the
27
+ # standard library or nil if Scala is not
28
+ # available.
24
29
  def version_str
25
- # Scala version string normally looks like "version 2.7.3.final"
26
- Java.scala.util.Properties.versionString.sub 'version ', ''
30
+ begin
31
+ # Scala version string normally looks like "version 2.7.3.final"
32
+ Java.scala.util.Properties.versionString.sub 'version ', ''
33
+ rescue
34
+ nil
35
+ end
27
36
  end
28
37
 
29
38
  def version
30
- # any consecutive sequence of numbers followed by dots
31
- match = version_str.match(/\d+\.\d[\d\.]*/) or
32
- fail "Unable to parse Scala version: #{version_str} "
33
- match[0].sub(/.$/, "") # remove trailing dot, if any
39
+ if version_str
40
+ # any consecutive sequence of numbers followed by dots
41
+ match = version_str.match(/\d+\.\d[\d\.]*/) or
42
+ fail "Unable to parse Scala version: #{version_str} "
43
+ match[0].sub(/.$/, "") # remove trailing dot, if any
44
+ else
45
+ DEFAULT_VERSION # TODO return the version installed from Maven repo
46
+ end
34
47
  end
35
48
  end
36
49
 
@@ -47,17 +60,44 @@ module Buildr::Scala
47
60
  # * :debug -- Generate debugging info.
48
61
  # * :other -- Array of options to pass to the Scalac compiler as is, e.g. -Xprint-types
49
62
  class Scalac < Buildr::Compiler::Base
63
+
64
+ # The scalac compiler jars are added to classpath at load time,
65
+ # if you want to customize artifact versions, you must set them on the
66
+ #
67
+ # artifact_ns['Buildr::Compiler::Scalac'].library = '2.7.5'
68
+ #
69
+ # namespace before this file is required. This is of course, only
70
+ # if SCALA_HOME is not set or invalid.
71
+ REQUIRES = ArtifactNamespace.for(self) do |ns|
72
+ ns.library! 'org.scala-lang:scala-library:jar:>=' + DEFAULT_VERSION
73
+ ns.compiler! 'org.scala-lang:scala-compiler:jar:>=' + DEFAULT_VERSION
74
+ end
75
+
50
76
  class << self
51
77
  def scala_home
52
- @home ||= ENV['SCALA_HOME']
78
+ env_home = ENV['SCALA_HOME']
79
+
80
+ @home ||= (if !env_home.nil? && File.exists?(env_home + '/lib/scala-library.jar') && File.exists?(env_home + '/lib/scala-compiler.jar')
81
+ env_home
82
+ else
83
+ nil
84
+ end)
85
+ end
86
+
87
+ def installed?
88
+ !scala_home.nil?
53
89
  end
54
90
 
55
91
  def dependencies
56
- [ 'scala-library.jar', 'scala-compiler.jar'].map { |jar| File.expand_path("lib/#{jar}", scala_home) }
92
+ if installed?
93
+ ['scala-library', 'scala-compiler'].map { |s| File.expand_path("lib/#{s}.jar", scala_home) }
94
+ else
95
+ REQUIRES.artifacts.map(&:to_s)
96
+ end
57
97
  end
58
98
 
59
99
  def use_fsc
60
- ENV["USE_FSC"] =~ /^(yes|on|true)$/i
100
+ installed? && ENV["USE_FSC"] =~ /^(yes|on|true)$/i
61
101
  end
62
102
 
63
103
  def applies_to?(project, task) #:nodoc:
@@ -101,32 +141,37 @@ module Buildr::Scala
101
141
  cmd_args += files_from_sources(sources)
102
142
 
103
143
  unless Buildr.application.options.dryrun
104
- Scalac.scala_home or fail 'Are we forgetting something? SCALA_HOME not set.'
105
144
  trace((['scalac'] + cmd_args).join(' '))
145
+
106
146
  if Scalac.use_fsc
107
147
  system(([File.expand_path('bin/fsc', Scalac.scala_home)] + cmd_args).join(' ')) or
108
148
  fail 'Failed to compile, see errors above'
109
149
  else
110
150
  Java.load
111
- Java.scala.tools.nsc.Main.process(cmd_args.to_java(Java.java.lang.String))
151
+ begin
152
+ Java.scala.tools.nsc.Main.process(cmd_args.to_java(Java.java.lang.String))
153
+ rescue => e
154
+ fail "Scala compiler crashed:\n#{e.inspect}"
155
+ end
112
156
  fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
113
157
  end
114
-
115
- if java_applies? sources
158
+
159
+ java_sources = java_sources(sources)
160
+ unless java_sources.empty?
116
161
  trace 'Compiling mixed Java/Scala sources'
117
162
 
118
- deps = dependencies + [ File.expand_path('lib/scala-library.jar', Scalac.scala_home),
119
- File.expand_path(target) ]
120
- @java.compile(sources, target, deps)
163
+ # TODO includes scala-compiler.jar
164
+ deps = dependencies + Scalac.dependencies + [ File.expand_path(target) ]
165
+ @java.compile(java_sources, target, deps)
121
166
  end
122
167
  end
123
168
  end
124
169
 
125
170
  private
126
-
127
- def java_applies?(sources)
128
- not sources.flatten.map { |source| File.directory?(source) ? FileList["#{source}/**/*.java"] : source }.
129
- flatten.reject { |file| File.directory?(file) }.map { |file| File.expand_path(file) }.uniq.empty?
171
+
172
+ def java_sources(sources)
173
+ sources.flatten.map { |source| File.directory?(source) ? FileList["#{source}/**/*.java"] : source } .
174
+ flatten.reject { |file| File.directory?(file) || File.extname(file) != '.java' }.map { |file| File.expand_path(file) }.uniq
130
175
  end
131
176
 
132
177
  # Returns Scalac command line arguments from the set of options.
@@ -0,0 +1,35 @@
1
+ package org.apache.buildr
2
+
3
+ import java.net.{URL, URLClassLoader}
4
+ import java.io.File
5
+
6
+ /**
7
+ * @author Daniel Spiewak
8
+ */
9
+ object SpecsSingletonRunner {
10
+ type Spec = { def main(args: Array[String]) }
11
+
12
+ // Incompatible with JVM 1.4 target
13
+ // @throws(classOf[Throwable])
14
+ def main(args: Array[String]) {
15
+ val (colors, spec) = if (args.length > 1 && args(1) == "-c")
16
+ (true, args(2))
17
+ else
18
+ (false, args(1))
19
+
20
+ run(args(0), colors, spec)
21
+ }
22
+
23
+ // Incompatible with JVM 1.4 target
24
+ // @throws(classOf[Throwable])
25
+ def run(path: String, colors: Boolean, spec: String) = {
26
+ val parent = new File(path)
27
+ val specURL = new File(parent, spec.replace('.', '/') + ".class").toURL
28
+ val loader = new URLClassLoader(Array(specURL), getClass.getClassLoader)
29
+
30
+ val clazz = loader.loadClass(spec)
31
+ val instance = clazz.getField("MODULE$").get(null).asInstanceOf[Spec]
32
+
33
+ instance.main(if (colors) Array("-c") else Array())
34
+ }
35
+ }
@@ -0,0 +1,55 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'buildr/shell'
18
+ require 'buildr/java/commands'
19
+
20
+ module Buildr
21
+ module Scala
22
+ class ScalaShell < Buildr::Shell::Base
23
+ include Buildr::Shell::JavaRebel
24
+
25
+ class << self
26
+ def lang
27
+ :scala
28
+ end
29
+
30
+ def to_sym
31
+ :scala
32
+ end
33
+ end
34
+
35
+ def launch
36
+ cp = project.compile.dependencies +
37
+ Scalac.dependencies +
38
+ [project.path_to(:target, :classes)]
39
+
40
+ props = {
41
+ 'env.classpath' => cp.join(File::PATH_SEPARATOR),
42
+ 'scala.home' => Scalac.scala_home
43
+ }
44
+
45
+ Java::Commands.java 'scala.tools.nsc.MainGenericRunner', {
46
+ :properties => props.merge(rebel_props(project)),
47
+ :classpath => cp,
48
+ :java_args => rebel_args
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ Buildr::ShellProviders << Buildr::Scala::ScalaShell