buildr 1.3.5-x86-mswin32 → 1.4.0-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 (151) hide show
  1. data/CHANGELOG +153 -8
  2. data/README.rdoc +1 -1
  3. data/addon/buildr/antlr.rb +5 -5
  4. data/addon/buildr/drb.rb +18 -18
  5. data/addon/buildr/hibernate.rb +18 -14
  6. data/addon/buildr/javacc.rb +4 -4
  7. data/addon/buildr/jetty.rb +5 -5
  8. data/addon/buildr/nailgun.rb +23 -23
  9. data/addon/buildr/openjpa.rb +1 -1
  10. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  11. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  12. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  13. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  15. data/addon/buildr/protobuf.rb +75 -0
  16. data/addon/buildr/xmlbeans.rb +5 -5
  17. data/buildr.buildfile +2 -2
  18. data/buildr.gemspec +8 -7
  19. data/doc/_layouts/default.html +2 -2
  20. data/doc/artifacts.textile +4 -4
  21. data/doc/building.textile +35 -3
  22. data/doc/contributing.textile +5 -0
  23. data/doc/download.textile +16 -5
  24. data/doc/extending.textile +38 -12
  25. data/doc/installing.textile +6 -5
  26. data/doc/languages.textile +182 -42
  27. data/doc/more_stuff.textile +2 -2
  28. data/doc/packaging.textile +14 -15
  29. data/doc/projects.textile +7 -2
  30. data/doc/quick_start.textile +4 -4
  31. data/doc/scripts/buildr-git.rb +63 -63
  32. data/doc/scripts/gitflow.rb +21 -21
  33. data/doc/settings_profiles.textile +9 -2
  34. data/doc/testing.textile +16 -5
  35. data/etc/KEYS +38 -0
  36. data/lib/buildr.rb +1 -1
  37. data/lib/buildr/core.rb +1 -0
  38. data/lib/buildr/core/application.rb +33 -27
  39. data/lib/buildr/core/build.rb +41 -28
  40. data/lib/buildr/core/cc.rb +172 -0
  41. data/lib/buildr/core/checks.rb +1 -1
  42. data/lib/buildr/core/common.rb +7 -6
  43. data/lib/buildr/core/compile.rb +7 -8
  44. data/lib/buildr/core/doc.rb +263 -0
  45. data/lib/buildr/core/environment.rb +6 -6
  46. data/lib/buildr/core/filter.rb +77 -35
  47. data/lib/buildr/core/generate.rb +7 -7
  48. data/lib/buildr/core/help.rb +1 -1
  49. data/lib/buildr/core/osx.rb +6 -6
  50. data/lib/buildr/core/progressbar.rb +4 -4
  51. data/lib/buildr/core/project.rb +144 -36
  52. data/lib/buildr/core/shell.rb +34 -34
  53. data/lib/buildr/core/test.rb +89 -20
  54. data/lib/buildr/core/transports.rb +8 -7
  55. data/lib/buildr/core/util.rb +77 -23
  56. data/lib/buildr/groovy/bdd.rb +5 -5
  57. data/lib/buildr/groovy/compiler.rb +19 -15
  58. data/lib/buildr/groovy/shell.rb +6 -6
  59. data/lib/buildr/ide/eclipse.rb +148 -75
  60. data/lib/buildr/ide/eclipse/java.rb +3 -3
  61. data/lib/buildr/ide/eclipse/plugin.rb +8 -5
  62. data/lib/buildr/ide/eclipse/scala.rb +4 -2
  63. data/lib/buildr/ide/idea.rb +2 -2
  64. data/lib/buildr/ide/idea7x.rb +23 -4
  65. data/lib/buildr/java.rb +1 -0
  66. data/lib/buildr/java/ant.rb +4 -4
  67. data/lib/buildr/java/bdd.rb +51 -54
  68. data/lib/buildr/java/cobertura.rb +57 -35
  69. data/lib/buildr/java/commands.rb +14 -5
  70. data/lib/buildr/java/compiler.rb +3 -217
  71. data/lib/buildr/java/deprecated.rb +4 -4
  72. data/lib/buildr/java/doc.rb +70 -0
  73. data/lib/buildr/java/emma.rb +22 -22
  74. data/lib/buildr/java/jruby.rb +4 -4
  75. data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
  76. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  77. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
  78. data/lib/buildr/java/packaging.rb +30 -29
  79. data/lib/buildr/java/pom.rb +4 -4
  80. data/lib/buildr/java/rjb.rb +6 -6
  81. data/lib/buildr/java/test_result.rb +61 -85
  82. data/lib/buildr/java/tests.rb +44 -27
  83. data/lib/buildr/java/version_requirement.rb +8 -8
  84. data/lib/buildr/packaging/archive.rb +55 -22
  85. data/lib/buildr/packaging/artifact.rb +75 -36
  86. data/lib/buildr/packaging/artifact_namespace.rb +90 -78
  87. data/lib/buildr/packaging/artifact_search.rb +5 -5
  88. data/lib/buildr/packaging/gems.rb +11 -7
  89. data/lib/buildr/packaging/package.rb +10 -7
  90. data/lib/buildr/packaging/tar.rb +14 -14
  91. data/lib/buildr/packaging/version_requirement.rb +30 -10
  92. data/lib/buildr/packaging/ziptask.rb +51 -13
  93. data/lib/buildr/scala.rb +1 -0
  94. data/lib/buildr/scala/bdd.rb +25 -20
  95. data/lib/buildr/scala/compiler.rb +87 -40
  96. data/lib/buildr/scala/doc.rb +106 -0
  97. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  98. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  99. data/lib/buildr/scala/shell.rb +14 -9
  100. data/lib/buildr/scala/tests.rb +33 -26
  101. data/lib/buildr/shell.rb +33 -33
  102. data/rakelib/all-in-one.rake +113 -0
  103. data/rakelib/checks.rake +1 -1
  104. data/rakelib/doc.rake +7 -0
  105. data/rakelib/package.rake +1 -1
  106. data/rakelib/release.rake +9 -6
  107. data/rakelib/rspec.rake +26 -7
  108. data/rakelib/setup.rake +15 -3
  109. data/rakelib/stage.rake +18 -11
  110. data/spec/addon/drb_spec.rb +25 -25
  111. data/spec/core/application_spec.rb +111 -21
  112. data/spec/core/build_spec.rb +16 -15
  113. data/spec/core/cc_spec.rb +174 -0
  114. data/spec/core/checks_spec.rb +34 -34
  115. data/spec/core/common_spec.rb +51 -5
  116. data/spec/core/compile_spec.rb +89 -14
  117. data/spec/core/extension_spec.rb +127 -19
  118. data/spec/core/generate_spec.rb +2 -2
  119. data/spec/core/project_spec.rb +10 -10
  120. data/spec/core/test_spec.rb +144 -35
  121. data/spec/core/transport_spec.rb +8 -8
  122. data/spec/core/util_spec.rb +63 -5
  123. data/spec/groovy/bdd_spec.rb +5 -5
  124. data/spec/groovy/compiler_spec.rb +29 -18
  125. data/spec/ide/eclipse_spec.rb +185 -9
  126. data/spec/ide/idea7x_spec.rb +22 -10
  127. data/spec/java/ant_spec.rb +9 -5
  128. data/spec/java/bdd_spec.rb +29 -37
  129. data/spec/java/cobertura_spec.rb +12 -12
  130. data/spec/java/commands_spec.rb +34 -0
  131. data/spec/java/compiler_spec.rb +53 -53
  132. data/spec/java/emma_spec.rb +11 -11
  133. data/spec/java/java_spec.rb +10 -10
  134. data/spec/java/packaging_spec.rb +67 -20
  135. data/spec/java/test_coverage_helper.rb +18 -18
  136. data/spec/java/tests_spec.rb +13 -9
  137. data/spec/packaging/archive_spec.rb +187 -20
  138. data/spec/packaging/artifact_namespace_spec.rb +172 -83
  139. data/spec/packaging/artifact_spec.rb +83 -18
  140. data/spec/packaging/packaging_spec.rb +41 -14
  141. data/spec/sandbox.rb +23 -12
  142. data/spec/scala/bdd_spec.rb +13 -8
  143. data/spec/scala/compiler_spec.rb +18 -13
  144. data/spec/scala/scala.rb +3 -3
  145. data/spec/scala/tests_spec.rb +46 -24
  146. data/spec/spec_helpers.rb +28 -10
  147. data/spec/version_requirement_spec.rb +25 -11
  148. metadata +149 -133
  149. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  150. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
  151. data/rakelib/stage.rake~ +0 -213
@@ -19,30 +19,52 @@ require 'buildr/core/compile'
19
19
  require 'buildr/packaging'
20
20
 
21
21
  module Buildr::Scala
22
- DEFAULT_VERSION = '2.7.5' # currently the latest (Jun 19, 2009)
23
-
22
+ DEFAULT_VERSION = '2.7.7' # currently the latest (Oct 31, 2009)
23
+
24
24
  class << self
25
-
26
- # Retrieves the Scala version string from the
27
- # standard library or nil if Scala is not
28
- # available.
25
+
29
26
  def version_str
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
27
+ warn "Use of Scala.version_str is deprecated. Use Scala.version instead"
28
+ version
29
+ end
30
+
31
+ def installed_version
32
+ unless @installed_version
33
+ @installed_version = if Scalac.installed?
34
+ begin
35
+ # try to read the value from the properties file
36
+ props = Zip::ZipFile.open(File.expand_path('lib/scala-library.jar', Scalac.scala_home)) do |zipfile|
37
+ zipfile.read 'library.properties'
38
+ end
39
+
40
+ version_str = props.match(/version\.number\s*=\s*([^\s]+)/).to_a[1]
41
+
42
+ if version_str
43
+ md = version_str.match(/\d+\.\d[\d\.]*/) or
44
+ fail "Unable to parse Scala version: #{version_str}"
45
+
46
+ md[0].sub(/.$/, "") # remove trailing dot, if any
47
+ end
48
+ rescue => e
49
+ warn "Unable to parse library.properties in $SCALA_HOME/lib/scala-library.jar: #{e}"
50
+ nil
51
+ end
52
+ end
35
53
  end
54
+
55
+ @installed_version
36
56
  end
37
-
57
+
38
58
  def version
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
59
+ Buildr.settings.build['scala.version'] || installed_version || DEFAULT_VERSION
60
+ end
61
+
62
+ def compatible_28?
63
+ major, minor = version.match(/^(\d)\.(\d)/).to_a[1,2]
64
+ if major && minor
65
+ (major.to_i == 2 && minor.to_i >= 8) || (major.to_i > 2)
44
66
  else
45
- DEFAULT_VERSION # TODO return the version installed from Maven repo
67
+ false
46
68
  end
47
69
  end
48
70
  end
@@ -60,7 +82,7 @@ module Buildr::Scala
60
82
  # * :debug -- Generate debugging info.
61
83
  # * :other -- Array of options to pass to the Scalac compiler as is, e.g. -Xprint-types
62
84
  class Scalac < Buildr::Compiler::Base
63
-
85
+
64
86
  # The scalac compiler jars are added to classpath at load time,
65
87
  # if you want to customize artifact versions, you must set them on the
66
88
  #
@@ -69,27 +91,36 @@ module Buildr::Scala
69
91
  # namespace before this file is required. This is of course, only
70
92
  # if SCALA_HOME is not set or invalid.
71
93
  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
94
+ version = Buildr.settings.build['scala.version'] || DEFAULT_VERSION
95
+ ns.library! 'org.scala-lang:scala-library:jar:>=' + version
96
+ ns.compiler! 'org.scala-lang:scala-compiler:jar:>=' + version
74
97
  end
75
-
98
+
76
99
  class << self
77
100
  def scala_home
78
101
  env_home = ENV['SCALA_HOME']
79
-
102
+
80
103
  @home ||= (if !env_home.nil? && File.exists?(env_home + '/lib/scala-library.jar') && File.exists?(env_home + '/lib/scala-compiler.jar')
81
104
  env_home
82
105
  else
83
106
  nil
84
107
  end)
85
108
  end
86
-
109
+
87
110
  def installed?
88
111
  !scala_home.nil?
89
112
  end
90
113
 
114
+ def use_installed?
115
+ if installed? && Buildr.settings.build['scala.version']
116
+ Buildr.settings.build['scala.version'] == Scala.installed_version
117
+ else
118
+ Buildr.settings.build['scala.version'].nil? && installed?
119
+ end
120
+ end
121
+
91
122
  def dependencies
92
- if installed?
123
+ if use_installed?
93
124
  ['scala-library', 'scala-compiler'].map { |s| File.expand_path("lib/#{s}.jar", scala_home) }
94
125
  else
95
126
  REQUIRES.artifacts.map(&:to_s)
@@ -97,23 +128,24 @@ module Buildr::Scala
97
128
  end
98
129
 
99
130
  def use_fsc
100
- installed? && ENV["USE_FSC"] =~ /^(yes|on|true)$/i
131
+ use_installed? && ENV["USE_FSC"] =~ /^(yes|on|true)$/i
101
132
  end
102
-
133
+
103
134
  def applies_to?(project, task) #:nodoc:
104
135
  paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
105
136
  paths.flatten!
106
-
137
+
107
138
  # Just select if we find .scala files
108
139
  paths.any? { |path| !Dir["#{path}/**/*.scala"].empty? }
109
140
  end
110
141
  end
111
-
142
+
112
143
  Javac = Buildr::Compiler::Javac
113
144
 
114
145
  OPTIONS = [:warnings, :deprecation, :optimise, :target, :debug, :other, :javac]
115
-
116
- Java.classpath << dependencies
146
+
147
+ # Lazy evaluation to allow change in buildfile
148
+ Java.classpath << lambda { dependencies }
117
149
 
118
150
  specify :language=>:scala, :sources => [:scala, :java], :source_ext => [:scala, :java],
119
151
  :target=>'classes', :target_ext=>'class', :packaging=>:jar
@@ -124,25 +156,41 @@ module Buildr::Scala
124
156
  options[:warnings] = verbose if options[:warnings].nil?
125
157
  options[:deprecation] ||= false
126
158
  options[:optimise] ||= false
159
+ options[:make] ||= :transitivenocp if Scala.compatible_28?
127
160
  options[:javac] ||= {}
128
-
161
+
129
162
  @java = Javac.new(project, options[:javac])
130
163
  end
131
164
 
132
165
  def compile(sources, target, dependencies) #:nodoc:
133
- check_options options, OPTIONS
166
+ check_options(options, OPTIONS + (Scala.compatible_28? ? [:make] : []))
167
+
168
+ java_sources = java_sources(sources)
169
+ enable_dep_tracing = Scala.compatible_28? && java_sources.empty?
170
+
171
+ dependencies.unshift target if enable_dep_tracing
134
172
 
135
173
  cmd_args = []
136
- cmd_args << '-classpath' << (dependencies + Scalac.dependencies).join(File::PATH_SEPARATOR)
174
+ cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR)
137
175
  source_paths = sources.select { |source| File.directory?(source) }
138
176
  cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
139
177
  cmd_args << '-d' << File.expand_path(target)
140
178
  cmd_args += scalac_args
179
+
180
+ if enable_dep_tracing
181
+ dep_dir = File.expand_path(target)
182
+ Dir.mkdir dep_dir unless File.exists? dep_dir
183
+
184
+ cmd_args << '-make:' + options[:make].to_s
185
+ cmd_args << '-dependencyfile'
186
+ cmd_args << File.expand_path('.scala-deps', dep_dir)
187
+ end
188
+
141
189
  cmd_args += files_from_sources(sources)
142
190
 
143
191
  unless Buildr.application.options.dryrun
144
192
  trace((['scalac'] + cmd_args).join(' '))
145
-
193
+
146
194
  if Scalac.use_fsc
147
195
  system(([File.expand_path('bin/fsc', Scalac.scala_home)] + cmd_args).join(' ')) or
148
196
  fail 'Failed to compile, see errors above'
@@ -151,15 +199,14 @@ module Buildr::Scala
151
199
  begin
152
200
  Java.scala.tools.nsc.Main.process(cmd_args.to_java(Java.java.lang.String))
153
201
  rescue => e
154
- fail "Scala compiler crashed:\n#{e.inspect}"
202
+ fail "Scala compiler crashed:\n#{e.inspect}"
155
203
  end
156
204
  fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
157
205
  end
158
-
159
- java_sources = java_sources(sources)
206
+
160
207
  unless java_sources.empty?
161
208
  trace 'Compiling mixed Java/Scala sources'
162
-
209
+
163
210
  # TODO includes scala-compiler.jar
164
211
  deps = dependencies + Scalac.dependencies + [ File.expand_path(target) ]
165
212
  @java.compile(java_sources, target, deps)
@@ -187,7 +234,7 @@ module Buildr::Scala
187
234
  end
188
235
 
189
236
  end
190
-
237
+
191
238
  end
192
239
 
193
240
  # Scala compiler comes first, ahead of Javac, this allows it to pick
@@ -0,0 +1,106 @@
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
+ require 'buildr/core/doc'
17
+ require 'buildr/scala/compiler' # ensure Scala dependencies are ready
18
+
19
+ module Buildr
20
+ module Doc
21
+ class Scaladoc < Base
22
+ specify :language => :scala, :source_ext => 'scala'
23
+
24
+ def generate(sources, target, options = {})
25
+ cmd_args = [ '-d', target, Buildr.application.options.trace ? '-verbose' : '' ]
26
+ options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
27
+ each { |key, value| value.invoke if value.respond_to?(:invoke) }.
28
+ each do |key, value|
29
+ case value
30
+ when true, nil
31
+ cmd_args << "-#{key}"
32
+ when false
33
+ cmd_args << "-no#{key}"
34
+ when Hash
35
+ value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
36
+ else
37
+ cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
38
+ end
39
+ end
40
+ [:sourcepath, :classpath].each do |option|
41
+ Array(options[option]).flatten.tap do |paths|
42
+ cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
43
+ end
44
+ end
45
+ cmd_args += sources.flatten.uniq
46
+ unless Buildr.application.options.dryrun
47
+ info "Generating Scaladoc for #{project.name}"
48
+ trace (['scaladoc'] + cmd_args).join(' ')
49
+ Java.load
50
+ Java.scala.tools.nsc.ScalaDoc.main(cmd_args.to_java(Java.java.lang.String)) == 0 or
51
+ fail 'Failed to generate Scaladocs, see errors above'
52
+ end
53
+ end
54
+ end
55
+
56
+ class VScaladoc < Base
57
+ VERSION = '1.2-SNAPSHOT'
58
+ Buildr.repositories.remote << 'http://scala-tools.org/repo-snapshots'
59
+
60
+ class << self
61
+ def dependencies
62
+ [ "org.scala-tools:vscaladoc:jar:#{VERSION}" ]
63
+ end
64
+ end
65
+
66
+ Java.classpath << dependencies
67
+
68
+ specify :language => :scala, :source_ext => 'scala'
69
+
70
+ def generate(sources, target, options = {})
71
+ cmd_args = [ '-d', target, (Buildr.application.options.trace ? '-verbose' : ''),
72
+ '-sourcepath', project.compile.sources.join(File::PATH_SEPARATOR) ]
73
+ options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
74
+ each { |key, value| value.invoke if value.respond_to?(:invoke) }.
75
+ each do |key, value|
76
+ case value
77
+ when true, nil
78
+ cmd_args << "-#{key}"
79
+ when false
80
+ cmd_args << "-no#{key}"
81
+ when Hash
82
+ value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
83
+ else
84
+ cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
85
+ end
86
+ end
87
+ [:sourcepath, :classpath].each do |option|
88
+ Array(options[option]).flatten.tap do |paths|
89
+ cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
90
+ end
91
+ end
92
+ cmd_args += sources.flatten.uniq
93
+ unless Buildr.application.options.dryrun
94
+ info "Generating VScaladoc for #{project.name}"
95
+ trace (['vscaladoc'] + cmd_args).join(' ')
96
+ Java.load
97
+ Java.org.scala_tools.vscaladoc.Main.main(cmd_args.to_java(Java.java.lang.String)) == 0 or
98
+ fail 'Failed to generate VScaladocs, see errors above'
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ Buildr::Doc.engines << Buildr::Doc::Scaladoc
106
+ Buildr::Doc.engines << Buildr::Doc::VScaladoc
@@ -0,0 +1,57 @@
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
14
+ * under the License.
15
+ */
16
+
17
+ package org.apache.buildr;
18
+
19
+ import java.lang.reflect.Field;
20
+ import java.lang.reflect.Method;
21
+ import java.net.URL;
22
+ import java.net.URLClassLoader;
23
+ import java.io.File;
24
+
25
+ /**
26
+ * @author Daniel Spiewak
27
+ */
28
+ public class SpecsSingletonRunner {
29
+ // Incompatible with JVM 1.4 target
30
+ // @throws(classOf[Throwable])
31
+ public static void main(String[] args) {
32
+ boolean colors = (args.length > 1 && args[1].equals("-c"));
33
+ String spec = colors ? args[2] : args[1];
34
+
35
+ run(args[0], colors, spec);
36
+ }
37
+
38
+ // Incompatible with JVM 1.4 target
39
+ // @throws(classOf[Throwable])
40
+ static void run(String path, boolean colors, String spec) {
41
+ try {
42
+ File parent = new File(path);
43
+ URL specURL = new File(parent, spec.replace('.', '/') + ".class").toURL();
44
+ URLClassLoader loader = new URLClassLoader(new URL[] { specURL }, Thread.currentThread().getContextClassLoader());
45
+
46
+ Class clazz = loader.loadClass(spec);
47
+ Object instance = clazz.getField("MODULE$").get(null);
48
+
49
+ Method main = clazz.getMethod("main", String[].class);
50
+
51
+ String[] args = colors ? new String[] { "-c" } : new String[] {};
52
+ main.invoke(instance, new Object[] { args });
53
+ } catch (Exception e) {
54
+ throw new RuntimeException(e);
55
+ }
56
+ }
57
+ }
@@ -21,30 +21,35 @@ module Buildr
21
21
  module Scala
22
22
  class ScalaShell < Buildr::Shell::Base
23
23
  include Buildr::Shell::JavaRebel
24
-
24
+
25
25
  class << self
26
26
  def lang
27
27
  :scala
28
28
  end
29
-
29
+
30
30
  def to_sym
31
31
  :scala
32
32
  end
33
33
  end
34
-
34
+
35
35
  def launch
36
- cp = project.compile.dependencies +
36
+ cp = project.compile.dependencies +
37
37
  Scalac.dependencies +
38
38
  [project.path_to(:target, :classes)]
39
-
39
+
40
40
  props = {
41
- 'env.classpath' => cp.join(File::PATH_SEPARATOR),
42
41
  'scala.home' => Scalac.scala_home
43
42
  }
44
-
45
- Java::Commands.java 'scala.tools.nsc.MainGenericRunner', {
43
+
44
+ jline = [File.expand_path("lib/jline.jar", Scalac.scala_home)].find_all do |f|
45
+ File.exist? f
46
+ end
47
+
48
+ Java::Commands.java 'scala.tools.nsc.MainGenericRunner',
49
+ '-cp', cp.join(File::PATH_SEPARATOR),
50
+ {
46
51
  :properties => props.merge(rebel_props(project)),
47
- :classpath => cp,
52
+ :classpath => Scalac.dependencies + jline,
48
53
  :java_args => rebel_args
49
54
  }
50
55
  end
@@ -23,16 +23,20 @@ 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.5'
27
-
26
+ VERSION = '1.6'
27
+
28
28
  class << self
29
29
  def version
30
30
  Buildr.settings.build['scala.check'] || VERSION
31
31
  end
32
-
32
+
33
+ def classifier
34
+ Buildr.settings.build['scala.check.classifier'] || ""
35
+ end
36
+
33
37
  def dependencies
34
- ["org.scala-tools.testing:scalacheck:jar:#{version}"]
35
- end
38
+ ["org.scala-tools.testing:scalacheck:jar:#{classifier}:#{version}"]
39
+ end
36
40
 
37
41
  private
38
42
  def const_missing(const)
@@ -42,8 +46,8 @@ module Buildr::Scala
42
46
  end
43
47
  end
44
48
  end
45
-
46
-
49
+
50
+
47
51
  # ScalaTest framework, the default test framework for Scala tests.
48
52
  #
49
53
  # Support the following options:
@@ -52,36 +56,36 @@ module Buildr::Scala
52
56
  # * :java_args -- Arguments passed as is to the JVM.
53
57
  class ScalaTest < Buildr::TestFramework::Java
54
58
 
55
- VERSION = '0.9.5'
59
+ VERSION = '1.0.1'
56
60
 
57
61
  class << self
58
62
  def version
59
63
  Buildr.settings.build['scala.test'] || VERSION
60
64
  end
61
-
65
+
62
66
  def dependencies
63
- ["org.scala-tools.testing:scalatest:jar:#{version}"] + Check.dependencies +
67
+ ["org.scalatest:scalatest:jar:#{version}"] + Check.dependencies +
64
68
  JMock.dependencies + JUnit.dependencies
65
- end
69
+ end
66
70
 
67
71
  def applies_to?(project) #:nodoc:
68
72
  !Dir[project.path_to(:source, :test, :scala, '**/*.scala')].empty?
69
- end
70
-
73
+ end
74
+
71
75
  private
72
76
  def const_missing(const)
73
77
  return super unless const == :REQUIRES # TODO: remove in 1.5
74
78
  Buildr.application.deprecated "Please use Scala::Test.dependencies/.version instead of ScalaTest::REQUIRES/VERSION"
75
79
  dependencies
76
80
  end
77
- end
81
+ end
78
82
 
79
83
  # annotation-based group inclusion
80
84
  attr_accessor :group_includes
81
-
85
+
82
86
  # annotation-based group exclusion
83
87
  attr_accessor :group_excludes
84
-
88
+
85
89
  def initialize(test_task, options)
86
90
  super
87
91
  @group_includes = []
@@ -100,7 +104,8 @@ module Buildr::Scala
100
104
  scalatest.each do |suite|
101
105
  info "ScalaTest #{suite.inspect}"
102
106
  # Use Ant to execute the ScalaTest task, gives us performance and reporting.
103
- reportFile = File.join(task.report_to.to_s, "TEST-#{suite}.txt")
107
+ reportDir = task.report_to.to_s
108
+ reportFile = File.join(reportDir, "TEST-#{suite}.txt")
104
109
  taskdef = Buildr.artifacts(self.class.dependencies).each(&:invoke).map(&:to_s)
105
110
  Buildr.ant('scalatest') do |ant|
106
111
  ant.taskdef :name=>'scalatest', :classname=>'org.scalatest.tools.ScalaTestTask',
@@ -109,42 +114,44 @@ module Buildr::Scala
109
114
  ant.suite :classname=>suite
110
115
  ant.reporter :type=>'stdout', :config=>reporter_options
111
116
  ant.reporter :type=>'file', :filename=> reportFile, :config=>reporter_options
117
+ ant.reporter :type=>(ScalaTest.version == "1.0") ? "xml" : "junitxml",
118
+ :directory=> reportDir, :config=>reporter_options
112
119
  # TODO: This should be name=>value pairs!
113
120
  #ant.includes group_includes.join(" ") if group_includes
114
121
  #ant.excludes group_excludes.join(" ") if group_excludes
115
- (options[:properties] || []).each { |name, value| ant.property :name=>name, :value=>value }
122
+ (options[:properties] || []).each { |name, value| ant.config :name=>name, :value=>value }
116
123
  end
117
124
  end
118
-
125
+
119
126
  # Parse for failures, errors, etc.
120
127
  # This is a bit of a pain right now because ScalaTest doesn't flush its
121
- # output synchronously before the Ant test finishes so we have to loop
122
- # and wait for an indication that the test run was completed.
128
+ # output synchronously before the Ant test finishes so we have to loop
129
+ # and wait for an indication that the test run was completed.
123
130
  failed = false
124
131
  completed = false
125
132
  wait = 0
126
133
  while (!completed) do
127
134
  File.open(reportFile, "r") do |input|
128
135
  while (line = input.gets) do
129
- failed = (line =~ /(TESTS? FAILED -)|(RUN STOPPED)|(RUN ABORTED)/) unless failed
130
- completed |= (line =~ /Run completed\./)
136
+ failed = (line =~ /(TESTS? FAILED)|(RUN STOPPED)|(RUN ABORTED)/) unless failed
137
+ completed |= (line =~ /Run completed/)
131
138
  break if (failed)
132
139
  end
133
140
  end
134
141
  wait += 1
135
- break if (failed || wait > 10)
142
+ break if (failed || wait > 10)
136
143
  unless completed
137
144
  sleep(1)
138
145
  end
139
146
  end
140
147
  success << suite if (completed && !failed)
141
148
  end
142
-
149
+
143
150
  success
144
151
  end # run
145
152
 
146
153
  end # ScalaTest
147
-
154
+
148
155
  end
149
156
 
150
157