buildr 1.3.5-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +998 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +244 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +79 -0
  40. data/doc/extending.textile +186 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +266 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +430 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +271 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +280 -0
  68. data/doc/testing.textile +222 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +656 -0
  73. data/lib/buildr/core/build.rb +452 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +362 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +866 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +723 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +334 -0
  94. data/lib/buildr/ide/eclipse/java.rb +53 -0
  95. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  96. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  97. data/lib/buildr/ide/idea.ipr.template +300 -0
  98. data/lib/buildr/ide/idea.rb +190 -0
  99. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  100. data/lib/buildr/ide/idea7x.rb +212 -0
  101. data/lib/buildr/java.rb +23 -0
  102. data/lib/buildr/java/ant.rb +94 -0
  103. data/lib/buildr/java/bdd.rb +459 -0
  104. data/lib/buildr/java/cobertura.rb +274 -0
  105. data/lib/buildr/java/commands.rb +213 -0
  106. data/lib/buildr/java/compiler.rb +349 -0
  107. data/lib/buildr/java/deprecated.rb +141 -0
  108. data/lib/buildr/java/emma.rb +244 -0
  109. data/lib/buildr/java/jruby.rb +117 -0
  110. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  111. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
  113. data/lib/buildr/java/packaging.rb +716 -0
  114. data/lib/buildr/java/pom.rb +174 -0
  115. data/lib/buildr/java/rjb.rb +155 -0
  116. data/lib/buildr/java/test_result.rb +353 -0
  117. data/lib/buildr/java/tests.rb +333 -0
  118. data/lib/buildr/java/version_requirement.rb +172 -0
  119. data/lib/buildr/packaging.rb +24 -0
  120. data/lib/buildr/packaging/archive.rb +488 -0
  121. data/lib/buildr/packaging/artifact.rb +749 -0
  122. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  123. data/lib/buildr/packaging/artifact_search.rb +140 -0
  124. data/lib/buildr/packaging/gems.rb +102 -0
  125. data/lib/buildr/packaging/package.rb +238 -0
  126. data/lib/buildr/packaging/tar.rb +186 -0
  127. data/lib/buildr/packaging/version_requirement.rb +172 -0
  128. data/lib/buildr/packaging/zip.rb +73 -0
  129. data/lib/buildr/packaging/ziptask.rb +316 -0
  130. data/lib/buildr/resources/buildr.icns +0 -0
  131. data/lib/buildr/scala.rb +25 -0
  132. data/lib/buildr/scala/bdd.rb +109 -0
  133. data/lib/buildr/scala/compiler.rb +195 -0
  134. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  137. data/lib/buildr/scala/shell.rb +55 -0
  138. data/lib/buildr/scala/tests.rb +157 -0
  139. data/lib/buildr/shell.rb +180 -0
  140. data/rakelib/checks.rake +57 -0
  141. data/rakelib/doc.rake +92 -0
  142. data/rakelib/jekylltask.rb +120 -0
  143. data/rakelib/package.rake +73 -0
  144. data/rakelib/release.rake +149 -0
  145. data/rakelib/rspec.rake +73 -0
  146. data/rakelib/setup.rake +54 -0
  147. data/rakelib/stage.rake +213 -0
  148. data/rakelib/stage.rake~ +213 -0
  149. data/spec/addon/drb_spec.rb +328 -0
  150. data/spec/core/application_spec.rb +502 -0
  151. data/spec/core/build_spec.rb +677 -0
  152. data/spec/core/checks_spec.rb +519 -0
  153. data/spec/core/common_spec.rb +670 -0
  154. data/spec/core/compile_spec.rb +583 -0
  155. data/spec/core/extension_spec.rb +93 -0
  156. data/spec/core/generate_spec.rb +33 -0
  157. data/spec/core/project_spec.rb +762 -0
  158. data/spec/core/test_spec.rb +1098 -0
  159. data/spec/core/transport_spec.rb +537 -0
  160. data/spec/core/util_spec.rb +67 -0
  161. data/spec/groovy/bdd_spec.rb +80 -0
  162. data/spec/groovy/compiler_spec.rb +240 -0
  163. data/spec/ide/eclipse_spec.rb +501 -0
  164. data/spec/ide/idea7x_spec.rb +84 -0
  165. data/spec/java/ant_spec.rb +33 -0
  166. data/spec/java/bdd_spec.rb +382 -0
  167. data/spec/java/cobertura_spec.rb +85 -0
  168. data/spec/java/compiler_spec.rb +446 -0
  169. data/spec/java/emma_spec.rb +119 -0
  170. data/spec/java/java_spec.rb +124 -0
  171. data/spec/java/packaging_spec.rb +1134 -0
  172. data/spec/java/test_coverage_helper.rb +257 -0
  173. data/spec/java/tests_spec.rb +493 -0
  174. data/spec/packaging/archive_spec.rb +527 -0
  175. data/spec/packaging/artifact_namespace_spec.rb +654 -0
  176. data/spec/packaging/artifact_spec.rb +795 -0
  177. data/spec/packaging/packaging_helper.rb +63 -0
  178. data/spec/packaging/packaging_spec.rb +684 -0
  179. data/spec/sandbox.rb +142 -0
  180. data/spec/scala/bdd_spec.rb +119 -0
  181. data/spec/scala/compiler_spec.rb +284 -0
  182. data/spec/scala/scala.rb +38 -0
  183. data/spec/scala/tests_spec.rb +261 -0
  184. data/spec/spec_helpers.rb +340 -0
  185. data/spec/version_requirement_spec.rb +129 -0
  186. metadata +383 -0
Binary file
@@ -0,0 +1,25 @@
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
+ ENV['SCALA_HOME'] ||= '/opt/local/share/scala/' if File.exist?('/opt/local/share/scala/lib/scala-compiler.jar')
18
+ Buildr.repositories.remote << 'http://scala-tools.org/repo-releases'
19
+
20
+ require 'buildr/scala/compiler'
21
+ require 'buildr/scala/tests'
22
+ require 'buildr/scala/bdd'
23
+ require 'buildr/scala/shell'
24
+
25
+ Object::Scala = Buildr::Scala
@@ -0,0 +1,109 @@
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/core/build'
18
+ require 'buildr/core/compile'
19
+ require 'buildr/java/bdd'
20
+ require 'buildr/scala/tests'
21
+
22
+ module Buildr::Scala
23
+
24
+ # Specs is a Scala based BDD framework.
25
+ # To use in your project:
26
+ #
27
+ # test.using :specs
28
+ #
29
+ # This framework will search in your project for:
30
+ # src/spec/scala/**/*.scala
31
+ class Specs < Buildr::TestFramework::JavaBDD
32
+ @lang = :scala
33
+ @bdd_dir = :spec
34
+
35
+ VERSION = '1.5.0'
36
+
37
+ class << self
38
+ def version
39
+ Buildr.settings.build['scala.specs'] || VERSION
40
+ end
41
+
42
+ def dependencies
43
+ ["org.scala-tools.testing:specs:jar:#{version}"] + Check.dependencies + JUnit.dependencies
44
+ end
45
+
46
+ def applies_to?(project) #:nodoc:
47
+ !Dir[project.path_to(:source, bdd_dir, lang, '**/*.scala')].empty?
48
+ end
49
+
50
+ private
51
+ def const_missing(const)
52
+ return super unless const == :REQUIRES # TODO: remove in 1.5
53
+ Buildr.application.deprecated "Please use Scala::Specs.dependencies/.version instead of ScalaSpecs::REQUIRES/VERSION"
54
+ dependencies
55
+ end
56
+ end
57
+
58
+ def initialize(task, options) #:nodoc:
59
+ super
60
+
61
+ specs = task.project.path_to(:source, :spec, :scala)
62
+ task.compile.from specs if File.directory?(specs)
63
+
64
+ resources = task.project.path_to(:source, :spec, :resources)
65
+ task.resources.from resources if File.directory?(resources)
66
+ end
67
+
68
+ def tests(dependencies)
69
+ dependencies += [task.compile.target.to_s]
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
77
+ end
78
+
79
+ def run(specs, dependencies) #:nodoc:
80
+ dependencies += [task.compile.target.to_s, File.join(File.dirname(__FILE__))] + Scalac.dependencies
81
+
82
+ cmd_options = { :properties => options[:properties],
83
+ :java_args => options[:java_args],
84
+ :classpath => dependencies}
85
+
86
+ runner = 'org.apache.buildr.SpecsSingletonRunner'
87
+ specs.inject [] do |passed, spec|
88
+ begin
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
94
+ rescue => e
95
+ passed
96
+ else
97
+ passed << spec
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ # Backwards compatibility stuff. Remove in 1.5.
105
+ module Buildr
106
+ ScalaSpecs = Scala::Specs
107
+ end
108
+
109
+ Buildr::TestFramework << Buildr::Scala::Specs
@@ -0,0 +1,195 @@
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/project'
17
+ require 'buildr/core/common'
18
+ require 'buildr/core/compile'
19
+ require 'buildr/packaging'
20
+
21
+ module Buildr::Scala
22
+ DEFAULT_VERSION = '2.7.5' # currently the latest (Jun 19, 2009)
23
+
24
+ class << self
25
+
26
+ # Retrieves the Scala version string from the
27
+ # standard library or nil if Scala is not
28
+ # available.
29
+ 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
35
+ end
36
+ end
37
+
38
+ 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
44
+ else
45
+ DEFAULT_VERSION # TODO return the version installed from Maven repo
46
+ end
47
+ end
48
+ end
49
+
50
+ # Scalac compiler:
51
+ # compile.using(:scalac)
52
+ # Used by default if .scala files are found in the src/main/scala directory (or src/test/scala)
53
+ # and sets the target directory to target/classes (or target/test/classes).
54
+ #
55
+ # Accepts the following options:
56
+ # * :warnings -- Generate warnings if true (opposite of -nowarn).
57
+ # * :deprecation -- Output source locations where deprecated APIs are used.
58
+ # * :optimise -- Generates faster bytecode by applying optimisations to the program.
59
+ # * :target -- Class file compatibility with specified release.
60
+ # * :debug -- Generate debugging info.
61
+ # * :other -- Array of options to pass to the Scalac compiler as is, e.g. -Xprint-types
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
+
76
+ class << self
77
+ def 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?
89
+ end
90
+
91
+ def dependencies
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
97
+ end
98
+
99
+ def use_fsc
100
+ installed? && ENV["USE_FSC"] =~ /^(yes|on|true)$/i
101
+ end
102
+
103
+ def applies_to?(project, task) #:nodoc:
104
+ paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
105
+ paths.flatten!
106
+
107
+ # Just select if we find .scala files
108
+ paths.any? { |path| !Dir["#{path}/**/*.scala"].empty? }
109
+ end
110
+ end
111
+
112
+ Javac = Buildr::Compiler::Javac
113
+
114
+ OPTIONS = [:warnings, :deprecation, :optimise, :target, :debug, :other, :javac]
115
+
116
+ Java.classpath << dependencies
117
+
118
+ specify :language=>:scala, :sources => [:scala, :java], :source_ext => [:scala, :java],
119
+ :target=>'classes', :target_ext=>'class', :packaging=>:jar
120
+
121
+ def initialize(project, options) #:nodoc:
122
+ super
123
+ options[:debug] = Buildr.options.debug if options[:debug].nil?
124
+ options[:warnings] = verbose if options[:warnings].nil?
125
+ options[:deprecation] ||= false
126
+ options[:optimise] ||= false
127
+ options[:javac] ||= {}
128
+
129
+ @java = Javac.new(project, options[:javac])
130
+ end
131
+
132
+ def compile(sources, target, dependencies) #:nodoc:
133
+ check_options options, OPTIONS
134
+
135
+ cmd_args = []
136
+ cmd_args << '-classpath' << (dependencies + Scalac.dependencies).join(File::PATH_SEPARATOR)
137
+ source_paths = sources.select { |source| File.directory?(source) }
138
+ cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
139
+ cmd_args << '-d' << File.expand_path(target)
140
+ cmd_args += scalac_args
141
+ cmd_args += files_from_sources(sources)
142
+
143
+ unless Buildr.application.options.dryrun
144
+ trace((['scalac'] + cmd_args).join(' '))
145
+
146
+ if Scalac.use_fsc
147
+ system(([File.expand_path('bin/fsc', Scalac.scala_home)] + cmd_args).join(' ')) or
148
+ fail 'Failed to compile, see errors above'
149
+ else
150
+ Java.load
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
156
+ fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
157
+ end
158
+
159
+ java_sources = java_sources(sources)
160
+ unless java_sources.empty?
161
+ trace 'Compiling mixed Java/Scala sources'
162
+
163
+ # TODO includes scala-compiler.jar
164
+ deps = dependencies + Scalac.dependencies + [ File.expand_path(target) ]
165
+ @java.compile(java_sources, target, deps)
166
+ end
167
+ end
168
+ end
169
+
170
+ private
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
175
+ end
176
+
177
+ # Returns Scalac command line arguments from the set of options.
178
+ def scalac_args #:nodoc:
179
+ args = []
180
+ args << "-nowarn" unless options[:warnings]
181
+ args << "-verbose" if Buildr.application.options.trace
182
+ args << "-g" if options[:debug]
183
+ args << "-deprecation" if options[:deprecation]
184
+ args << "-optimise" if options[:optimise]
185
+ args << "-target:jvm-" + options[:target].to_s if options[:target]
186
+ args + Array(options[:other])
187
+ end
188
+
189
+ end
190
+
191
+ end
192
+
193
+ # Scala compiler comes first, ahead of Javac, this allows it to pick
194
+ # projects that mix Scala and Java code by spotting Scala code first.
195
+ Buildr::Compiler.compilers.unshift Buildr::Scala::Scalac
@@ -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
@@ -0,0 +1,157 @@
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/core/build'
18
+ require 'buildr/core/compile'
19
+ require 'buildr/java/ant'
20
+ require 'buildr/java/tests'
21
+
22
+
23
+ module Buildr::Scala
24
+ # Scala::Check is available when using Scala::Test or Scala::Specs
25
+ module Check
26
+ VERSION = '1.5'
27
+
28
+ class << self
29
+ def version
30
+ Buildr.settings.build['scala.check'] || VERSION
31
+ end
32
+
33
+ def dependencies
34
+ ["org.scala-tools.testing:scalacheck:jar:#{version}"]
35
+ end
36
+
37
+ private
38
+ def const_missing(const)
39
+ return super unless const == :REQUIRES # TODO: remove in 1.5
40
+ Buildr.application.deprecated "Please use Scala::Check.dependencies/.version instead of ScalaCheck::REQUIRES/VERSION"
41
+ dependencies
42
+ end
43
+ end
44
+ end
45
+
46
+
47
+ # ScalaTest framework, the default test framework for Scala tests.
48
+ #
49
+ # Support the following options:
50
+ # * :properties -- Hash of system properties available to the test case.
51
+ # * :environment -- Hash of environment variables available to the test case.
52
+ # * :java_args -- Arguments passed as is to the JVM.
53
+ class ScalaTest < Buildr::TestFramework::Java
54
+
55
+ VERSION = '0.9.5'
56
+
57
+ class << self
58
+ def version
59
+ Buildr.settings.build['scala.test'] || VERSION
60
+ end
61
+
62
+ def dependencies
63
+ ["org.scala-tools.testing:scalatest:jar:#{version}"] + Check.dependencies +
64
+ JMock.dependencies + JUnit.dependencies
65
+ end
66
+
67
+ def applies_to?(project) #:nodoc:
68
+ !Dir[project.path_to(:source, :test, :scala, '**/*.scala')].empty?
69
+ end
70
+
71
+ private
72
+ def const_missing(const)
73
+ return super unless const == :REQUIRES # TODO: remove in 1.5
74
+ Buildr.application.deprecated "Please use Scala::Test.dependencies/.version instead of ScalaTest::REQUIRES/VERSION"
75
+ dependencies
76
+ end
77
+ end
78
+
79
+ # annotation-based group inclusion
80
+ attr_accessor :group_includes
81
+
82
+ # annotation-based group exclusion
83
+ attr_accessor :group_excludes
84
+
85
+ def initialize(test_task, options)
86
+ super
87
+ @group_includes = []
88
+ @group_excludes = []
89
+ end
90
+
91
+ def tests(dependencies) #:nodoc:
92
+ filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite})
93
+ end
94
+
95
+ def run(scalatest, dependencies) #:nodoc:
96
+ mkpath task.report_to.to_s
97
+ success = []
98
+
99
+ reporter_options = 'TFGBSAR' # testSucceeded, testFailed, testIgnored, suiteAborted, runStopped, runAborted, runCompleted
100
+ scalatest.each do |suite|
101
+ info "ScalaTest #{suite.inspect}"
102
+ # Use Ant to execute the ScalaTest task, gives us performance and reporting.
103
+ reportFile = File.join(task.report_to.to_s, "TEST-#{suite}.txt")
104
+ taskdef = Buildr.artifacts(self.class.dependencies).each(&:invoke).map(&:to_s)
105
+ Buildr.ant('scalatest') do |ant|
106
+ ant.taskdef :name=>'scalatest', :classname=>'org.scalatest.tools.ScalaTestTask',
107
+ :classpath=>taskdef.join(File::PATH_SEPARATOR)
108
+ ant.scalatest :runpath=>dependencies.join(File::PATH_SEPARATOR) do
109
+ ant.suite :classname=>suite
110
+ ant.reporter :type=>'stdout', :config=>reporter_options
111
+ ant.reporter :type=>'file', :filename=> reportFile, :config=>reporter_options
112
+ # TODO: This should be name=>value pairs!
113
+ #ant.includes group_includes.join(" ") if group_includes
114
+ #ant.excludes group_excludes.join(" ") if group_excludes
115
+ (options[:properties] || []).each { |name, value| ant.property :name=>name, :value=>value }
116
+ end
117
+ end
118
+
119
+ # Parse for failures, errors, etc.
120
+ # 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.
123
+ failed = false
124
+ completed = false
125
+ wait = 0
126
+ while (!completed) do
127
+ File.open(reportFile, "r") do |input|
128
+ while (line = input.gets) do
129
+ failed = (line =~ /(TESTS? FAILED -)|(RUN STOPPED)|(RUN ABORTED)/) unless failed
130
+ completed |= (line =~ /Run completed\./)
131
+ break if (failed)
132
+ end
133
+ end
134
+ wait += 1
135
+ break if (failed || wait > 10)
136
+ unless completed
137
+ sleep(1)
138
+ end
139
+ end
140
+ success << suite if (completed && !failed)
141
+ end
142
+
143
+ success
144
+ end # run
145
+
146
+ end # ScalaTest
147
+
148
+ end
149
+
150
+
151
+ # Backwards compatibility stuff. Remove in 1.5.
152
+ module Buildr
153
+ ScalaCheck = Scala::Check
154
+ ScalaTest = Scala::ScalaTest
155
+ end
156
+
157
+ Buildr::TestFramework << Buildr::Scala::ScalaTest