mguymon-buildr 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data/CHANGELOG +1291 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +44 -0
  6. data/_buildr +35 -0
  7. data/_jbuildr +35 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/bnd.rb +147 -0
  10. data/addon/buildr/cobertura.rb +22 -0
  11. data/addon/buildr/drb.rb +281 -0
  12. data/addon/buildr/emma.rb +22 -0
  13. data/addon/buildr/hibernate.rb +149 -0
  14. data/addon/buildr/javacc.rb +85 -0
  15. data/addon/buildr/jaxb_xjc.rb +72 -0
  16. data/addon/buildr/jdepend.rb +60 -0
  17. data/addon/buildr/jetty.rb +248 -0
  18. data/addon/buildr/jibx.rb +86 -0
  19. data/addon/buildr/nailgun.rb +221 -0
  20. data/addon/buildr/openjpa.rb +88 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  23. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  27. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  28. data/addon/buildr/protobuf.rb +88 -0
  29. data/addon/buildr/xmlbeans.rb +93 -0
  30. data/bin/buildr +19 -0
  31. data/buildr.buildfile +58 -0
  32. data/buildr.gemspec +78 -0
  33. data/doc/_config.yml +1 -0
  34. data/doc/_layouts/default.html +90 -0
  35. data/doc/_layouts/preface.html +22 -0
  36. data/doc/artifacts.textile +217 -0
  37. data/doc/building.textile +276 -0
  38. data/doc/contributing.textile +268 -0
  39. data/doc/css/default.css +236 -0
  40. data/doc/css/print.css +101 -0
  41. data/doc/css/syntax.css +23 -0
  42. data/doc/download.textile +151 -0
  43. data/doc/extending.textile +212 -0
  44. data/doc/images/1442160941-frontcover.jpg +0 -0
  45. data/doc/images/asf-logo.gif +0 -0
  46. data/doc/images/asf-logo.png +0 -0
  47. data/doc/images/buildr-hires.png +0 -0
  48. data/doc/images/buildr.png +0 -0
  49. data/doc/images/favicon.png +0 -0
  50. data/doc/images/growl-icon.tiff +0 -0
  51. data/doc/images/note.png +0 -0
  52. data/doc/images/project-structure.png +0 -0
  53. data/doc/images/tip.png +0 -0
  54. data/doc/images/zbuildr.png +0 -0
  55. data/doc/images/zbuildr.tif +0 -0
  56. data/doc/index.textile +109 -0
  57. data/doc/installing.textile +284 -0
  58. data/doc/languages.textile +599 -0
  59. data/doc/mailing_lists.textile +29 -0
  60. data/doc/more_stuff.textile +845 -0
  61. data/doc/packaging.textile +618 -0
  62. data/doc/preface.textile +54 -0
  63. data/doc/projects.textile +276 -0
  64. data/doc/quick_start.textile +210 -0
  65. data/doc/releasing.textile +117 -0
  66. data/doc/scripts/buildr-git.rb +512 -0
  67. data/doc/scripts/gitflow.rb +296 -0
  68. data/doc/scripts/install-jruby.sh +44 -0
  69. data/doc/scripts/install-linux.sh +73 -0
  70. data/doc/scripts/install-osx.sh +52 -0
  71. data/doc/settings_profiles.textile +287 -0
  72. data/doc/testing.textile +247 -0
  73. data/etc/KEYS +189 -0
  74. data/lib/buildr.rb +44 -0
  75. data/lib/buildr/clojure.rb +34 -0
  76. data/lib/buildr/clojure/shell.rb +52 -0
  77. data/lib/buildr/core.rb +34 -0
  78. data/lib/buildr/core/application.rb +700 -0
  79. data/lib/buildr/core/build.rb +516 -0
  80. data/lib/buildr/core/cc.rb +166 -0
  81. data/lib/buildr/core/checks.rb +253 -0
  82. data/lib/buildr/core/common.rb +151 -0
  83. data/lib/buildr/core/compile.rb +622 -0
  84. data/lib/buildr/core/doc.rb +276 -0
  85. data/lib/buildr/core/environment.rb +129 -0
  86. data/lib/buildr/core/filter.rb +404 -0
  87. data/lib/buildr/core/generate.rb +197 -0
  88. data/lib/buildr/core/help.rb +119 -0
  89. data/lib/buildr/core/jrebel.rb +42 -0
  90. data/lib/buildr/core/linux.rb +30 -0
  91. data/lib/buildr/core/osx.rb +46 -0
  92. data/lib/buildr/core/progressbar.rb +161 -0
  93. data/lib/buildr/core/project.rb +975 -0
  94. data/lib/buildr/core/run.rb +43 -0
  95. data/lib/buildr/core/shell.rb +137 -0
  96. data/lib/buildr/core/test.rb +843 -0
  97. data/lib/buildr/core/transports.rb +575 -0
  98. data/lib/buildr/core/util.rb +537 -0
  99. data/lib/buildr/groovy.rb +20 -0
  100. data/lib/buildr/groovy/bdd.rb +106 -0
  101. data/lib/buildr/groovy/compiler.rb +153 -0
  102. data/lib/buildr/groovy/doc.rb +76 -0
  103. data/lib/buildr/groovy/shell.rb +57 -0
  104. data/lib/buildr/ide.rb +19 -0
  105. data/lib/buildr/ide/eclipse.rb +427 -0
  106. data/lib/buildr/ide/eclipse/java.rb +53 -0
  107. data/lib/buildr/ide/eclipse/plugin.rb +71 -0
  108. data/lib/buildr/ide/eclipse/scala.rb +68 -0
  109. data/lib/buildr/ide/idea.rb +576 -0
  110. data/lib/buildr/java.rb +25 -0
  111. data/lib/buildr/java/ant.rb +94 -0
  112. data/lib/buildr/java/bdd.rb +460 -0
  113. data/lib/buildr/java/cobertura.rb +297 -0
  114. data/lib/buildr/java/commands.rb +223 -0
  115. data/lib/buildr/java/compiler.rb +135 -0
  116. data/lib/buildr/java/deprecated.rb +141 -0
  117. data/lib/buildr/java/doc.rb +86 -0
  118. data/lib/buildr/java/ecj.rb +69 -0
  119. data/lib/buildr/java/emma.rb +244 -0
  120. data/lib/buildr/java/external.rb +73 -0
  121. data/lib/buildr/java/jruby.rb +122 -0
  122. data/lib/buildr/java/jtestr_result.rb +295 -0
  123. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  124. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  125. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  126. data/lib/buildr/java/packaging.rb +734 -0
  127. data/lib/buildr/java/pom.rb +178 -0
  128. data/lib/buildr/java/rjb.rb +154 -0
  129. data/lib/buildr/java/test_result.rb +101 -0
  130. data/lib/buildr/java/tests.rb +362 -0
  131. data/lib/buildr/java/version_requirement.rb +172 -0
  132. data/lib/buildr/packaging.rb +25 -0
  133. data/lib/buildr/packaging/archive.rb +535 -0
  134. data/lib/buildr/packaging/artifact.rb +904 -0
  135. data/lib/buildr/packaging/artifact_namespace.rb +984 -0
  136. data/lib/buildr/packaging/artifact_search.rb +140 -0
  137. data/lib/buildr/packaging/gems.rb +105 -0
  138. data/lib/buildr/packaging/package.rb +249 -0
  139. data/lib/buildr/packaging/repository_array.rb +108 -0
  140. data/lib/buildr/packaging/tar.rb +189 -0
  141. data/lib/buildr/packaging/version_requirement.rb +192 -0
  142. data/lib/buildr/packaging/zip.rb +178 -0
  143. data/lib/buildr/packaging/ziptask.rb +356 -0
  144. data/lib/buildr/resources/buildr.icns +0 -0
  145. data/lib/buildr/resources/completed.png +0 -0
  146. data/lib/buildr/resources/failed.png +0 -0
  147. data/lib/buildr/resources/icons-license.txt +17 -0
  148. data/lib/buildr/run.rb +195 -0
  149. data/lib/buildr/scala.rb +26 -0
  150. data/lib/buildr/scala/bdd.rb +118 -0
  151. data/lib/buildr/scala/compiler.rb +242 -0
  152. data/lib/buildr/scala/doc.rb +142 -0
  153. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  154. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  155. data/lib/buildr/scala/shell.rb +52 -0
  156. data/lib/buildr/scala/tests.rb +171 -0
  157. data/lib/buildr/shell.rb +185 -0
  158. data/lib/buildr/version.rb +18 -0
  159. data/rakelib/all-in-one.rake +113 -0
  160. data/rakelib/checks.rake +57 -0
  161. data/rakelib/doc.rake +137 -0
  162. data/rakelib/metrics.rake +39 -0
  163. data/rakelib/package.rake +73 -0
  164. data/rakelib/release.rake +160 -0
  165. data/rakelib/rspec.rake +91 -0
  166. data/rakelib/setup.rake +66 -0
  167. data/rakelib/stage.rake +220 -0
  168. data/spec/addon/bnd_spec.rb +330 -0
  169. data/spec/addon/drb_spec.rb +328 -0
  170. data/spec/addon/jaxb_xjc_spec.rb +125 -0
  171. data/spec/core/application_spec.rb +631 -0
  172. data/spec/core/build_spec.rb +837 -0
  173. data/spec/core/cc_spec.rb +224 -0
  174. data/spec/core/checks_spec.rb +519 -0
  175. data/spec/core/common_spec.rb +725 -0
  176. data/spec/core/compile_spec.rb +658 -0
  177. data/spec/core/doc_spec.rb +195 -0
  178. data/spec/core/extension_spec.rb +201 -0
  179. data/spec/core/generate_spec.rb +33 -0
  180. data/spec/core/project_spec.rb +772 -0
  181. data/spec/core/run_spec.rb +93 -0
  182. data/spec/core/shell_spec.rb +146 -0
  183. data/spec/core/test_spec.rb +1320 -0
  184. data/spec/core/transport_spec.rb +544 -0
  185. data/spec/core/util_spec.rb +141 -0
  186. data/spec/groovy/bdd_spec.rb +80 -0
  187. data/spec/groovy/compiler_spec.rb +251 -0
  188. data/spec/groovy/doc_spec.rb +65 -0
  189. data/spec/ide/eclipse_spec.rb +739 -0
  190. data/spec/ide/idea_spec.rb +1145 -0
  191. data/spec/java/ant_spec.rb +37 -0
  192. data/spec/java/bdd_spec.rb +374 -0
  193. data/spec/java/cobertura_spec.rb +112 -0
  194. data/spec/java/commands_spec.rb +93 -0
  195. data/spec/java/compiler_spec.rb +252 -0
  196. data/spec/java/doc_spec.rb +56 -0
  197. data/spec/java/ecj_spec.rb +115 -0
  198. data/spec/java/emma_spec.rb +121 -0
  199. data/spec/java/external_spec.rb +56 -0
  200. data/spec/java/java_spec.rb +132 -0
  201. data/spec/java/packaging_spec.rb +1266 -0
  202. data/spec/java/run_spec.rb +78 -0
  203. data/spec/java/test_coverage_helper.rb +257 -0
  204. data/spec/java/tests_spec.rb +497 -0
  205. data/spec/packaging/archive_spec.rb +775 -0
  206. data/spec/packaging/artifact_namespace_spec.rb +743 -0
  207. data/spec/packaging/artifact_spec.rb +1074 -0
  208. data/spec/packaging/packaging_helper.rb +63 -0
  209. data/spec/packaging/packaging_spec.rb +719 -0
  210. data/spec/packaging/repository_array_spec.rb +109 -0
  211. data/spec/sandbox.rb +165 -0
  212. data/spec/scala/bdd_spec.rb +124 -0
  213. data/spec/scala/compiler_spec.rb +289 -0
  214. data/spec/scala/doc_spec.rb +88 -0
  215. data/spec/scala/scala.rb +38 -0
  216. data/spec/scala/tests_spec.rb +283 -0
  217. data/spec/spec_helpers.rb +369 -0
  218. data/spec/version_requirement_spec.rb +143 -0
  219. data/spec/xpath_matchers.rb +121 -0
  220. metadata +649 -0
@@ -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
+
@@ -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
+
17
+ module Buildr
18
+ module Run
19
+ include Extension
20
+
21
+ class << self
22
+ def runners
23
+ @runners ||= []
24
+ end
25
+
26
+ def select_by_lang(lang)
27
+ fail 'Unable to define run task for nil language' if lang.nil?
28
+ runners.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
+ runners.detect { |e| e.to_sym == name.to_sym }
36
+ end
37
+
38
+ end
39
+
40
+ # Base class for any run provider. Defines most
41
+ # common functionality (things like @lang@, @build?@ and friends).
42
+ class Base
43
+ attr_reader :project
44
+
45
+ class << self
46
+ attr_accessor :runner_name, :languages
47
+
48
+ def specify(options)
49
+ @runner_name ||= options[:name]
50
+ @languages ||= options[:languages]
51
+ end
52
+
53
+ def to_sym
54
+ @runner_name || name.split('::').last.downcase.to_sym
55
+ end
56
+ end
57
+
58
+ def initialize(project)
59
+ @project = project
60
+ end
61
+
62
+ def build?
63
+ true
64
+ end
65
+
66
+ def launch
67
+ fail 'Not implemented'
68
+ end
69
+ end
70
+
71
+ class RunTask < Rake::Task
72
+ # Classpath dependencies.
73
+ attr_accessor :classpath
74
+
75
+ # Returns the run options.
76
+ attr_reader :options
77
+
78
+ # Returns file dependencies
79
+ attr_reader :files
80
+
81
+ attr_reader :project # :nodoc:
82
+
83
+ def initialize(*args) # :nodoc:
84
+ super
85
+ @options = {}
86
+ @classpath = []
87
+ @files = FileList[]
88
+ end
89
+
90
+ # :call-seq:
91
+ # with(*artifacts) => self
92
+ #
93
+ # Adds files and artifacts as classpath dependencies, and returns self.
94
+ def with(*specs)
95
+ @classpath |= Buildr.artifacts(specs.flatten).uniq
96
+ self
97
+ end
98
+
99
+ # :call-seq:
100
+ # using(options) => self
101
+ #
102
+ # Sets the run options from a hash and returns self.
103
+ #
104
+ # For example:
105
+ # run.using :main=>'org.example.Main'
106
+ def using(*args)
107
+ args.pop.each { |key, value| @options[key.to_sym] = value } if Hash === args.last
108
+
109
+ until args.empty?
110
+ new_runner = Run.select_by_name(args.pop)
111
+ @runner = new_runner.new(project) unless new_runner.nil?
112
+ end
113
+
114
+ self
115
+ end
116
+
117
+ # :call-seq:
118
+ # requires(*files) => self
119
+ #
120
+ # Adds additional files and directories as dependencies to the task and returns self.
121
+ # When specifying a directory, includes all files in that directory.
122
+ def requires(*files)
123
+ @files.include *files.flatten.compact
124
+ self
125
+ end
126
+
127
+ def runner
128
+ @runner ||= guess_runner
129
+ end
130
+
131
+ def runner?
132
+ @runner ||= begin
133
+ guess_runner if project.compile.language
134
+ rescue
135
+ nil
136
+ end
137
+ end
138
+
139
+ def run
140
+ runner.run(self) if runner?
141
+ end
142
+
143
+ def prerequisites #:nodoc:
144
+ super + @files + classpath
145
+ end
146
+
147
+ private
148
+
149
+ def guess_runner
150
+ runner = Run.select project.compile.language
151
+ fail 'Unable to guess runner for project.' unless runner
152
+ runner.new project
153
+ end
154
+
155
+ def associate_with(project)
156
+ @project ||= project
157
+ end
158
+ end
159
+
160
+ first_time do
161
+ Project.local_task 'run'
162
+ end
163
+
164
+ before_define(:run => :test) do |project|
165
+ RunTask.define_task('run').tap do |run|
166
+ run.send(:associate_with, project)
167
+ run.enhance([project.compile, project.test]) do |t|
168
+ # double-enhance to execute the runner last
169
+ run.enhance { |t| t.run }
170
+ end
171
+ end
172
+ end
173
+
174
+ after_define(:run => :test) do |project|
175
+ project.run.with project.test.compile.dependencies
176
+ project.run.with project.test.compile.target if project.test.compile.target
177
+ end
178
+
179
+ # :call-seq:
180
+ # run(&block) => RunTask
181
+ #
182
+ # This method returns the project's run task. It also accepts a block to be executed
183
+ # when the run task is invoked.
184
+ def run(&block)
185
+ task('run').tap do |t|
186
+ t.enhance &block if block
187
+ end
188
+ end
189
+
190
+ end
191
+
192
+ class Project
193
+ include Run
194
+ end
195
+ end
@@ -0,0 +1,26 @@
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/doc'
24
+ require 'buildr/scala/shell'
25
+
26
+ Object::Scala = Buildr::Scala
@@ -0,0 +1,118 @@
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.6.6'
36
+
37
+ class << self
38
+ def version
39
+ Buildr.settings.build['scala.specs'] || VERSION
40
+ end
41
+
42
+ def artifact
43
+ Buildr.settings.build['scala.specs.artifact'] || "specs_#{Buildr::Scala.version}"
44
+ end
45
+
46
+ def dependencies
47
+ unless @dependencies
48
+ super
49
+ specs = (version =~ /:/) ? [version] : ["org.scala-tools.testing:#{artifact}:jar:#{version}"]
50
+ # Add utility classes (e.g. SpecsSingletonRunner) and other dependencies
51
+ @dependencies |= [ File.join(File.dirname(__FILE__)) ] + specs +
52
+ Check.dependencies + JUnit.dependencies + Scalac.dependencies
53
+ end
54
+ @dependencies
55
+ end
56
+
57
+ def applies_to?(project) #:nodoc:
58
+ !Dir[project.path_to(:source, bdd_dir, lang, '**/*.scala')].empty?
59
+ end
60
+
61
+ private
62
+ def const_missing(const)
63
+ return super unless const == :REQUIRES # TODO: remove in 1.5
64
+ Buildr.application.deprecated "Please use Scala::Specs.dependencies/.version instead of ScalaSpecs::REQUIRES/VERSION"
65
+ dependencies
66
+ end
67
+ end
68
+
69
+ def initialize(task, options) #:nodoc:
70
+ super
71
+
72
+ specs = task.project.path_to(:source, :spec, :scala)
73
+ task.compile.from specs if File.directory?(specs)
74
+
75
+ resources = task.project.path_to(:source, :spec, :resources)
76
+ task.resources.from resources if File.directory?(resources)
77
+ end
78
+
79
+ def tests(dependencies)
80
+ candidates = filter_classes(dependencies, :interfaces => ['org.specs.Specification'])
81
+
82
+ Java.load # Java is already loaded, but just in case
83
+
84
+ filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
85
+ filter.add_fields ['MODULE$'].to_java(Java.java.lang.String)
86
+ filter.filter(candidates.to_java(Java.java.lang.String)).map { |s| s[0..(s.size - 2)] }
87
+ end
88
+
89
+ def run(specs, dependencies) #:nodoc:
90
+ cmd_options = { :properties => options[:properties],
91
+ :java_args => options[:java_args],
92
+ :classpath => dependencies,
93
+ :name => false }
94
+
95
+ runner = 'org.apache.buildr.SpecsSingletonRunner'
96
+ specs.inject [] do |passed, spec|
97
+ begin
98
+ unless Util.win_os?
99
+ Java::Commands.java(runner, task.compile.target.to_s, '-c', spec + '$', cmd_options)
100
+ else
101
+ Java::Commands.java(runner, task.compile.target.to_s, spec + '$', cmd_options)
102
+ end
103
+ rescue => e
104
+ passed
105
+ else
106
+ passed << spec
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ # Backwards compatibility stuff. Remove in 1.5.
114
+ module Buildr
115
+ ScalaSpecs = Scala::Specs
116
+ end
117
+
118
+ Buildr::TestFramework << Buildr::Scala::Specs
@@ -0,0 +1,242 @@
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.8.1'
23
+
24
+ class << self
25
+
26
+ def version_str
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
53
+ end
54
+
55
+ @installed_version
56
+ end
57
+
58
+ def version
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)
66
+ else
67
+ false
68
+ end
69
+ end
70
+ end
71
+
72
+ # Scalac compiler:
73
+ # compile.using(:scalac)
74
+ # Used by default if .scala files are found in the src/main/scala directory (or src/test/scala)
75
+ # and sets the target directory to target/classes (or target/test/classes).
76
+ #
77
+ # Accepts the following options:
78
+ # * :warnings -- Generate warnings if true (opposite of -nowarn).
79
+ # * :deprecation -- Output source locations where deprecated APIs are used.
80
+ # * :optimise -- Generates faster bytecode by applying optimisations to the program.
81
+ # * :target -- Class file compatibility with specified release.
82
+ # * :debug -- Generate debugging info.
83
+ # * :other -- Array of options to pass to the Scalac compiler as is, e.g. -Xprint-types
84
+ class Scalac < Buildr::Compiler::Base
85
+
86
+ # The scalac compiler jars are added to classpath at load time,
87
+ # if you want to customize artifact versions, you must set them on the
88
+ #
89
+ # artifact_ns['Buildr::Compiler::Scalac'].library = '2.7.5'
90
+ #
91
+ # namespace before this file is required. This is of course, only
92
+ # if SCALA_HOME is not set or invalid.
93
+ REQUIRES = ArtifactNamespace.for(self) do |ns|
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
97
+ end
98
+
99
+ class << self
100
+ def scala_home
101
+ env_home = ENV['SCALA_HOME']
102
+
103
+ @home ||= (if !env_home.nil? && File.exists?(env_home + '/lib/scala-library.jar') && File.exists?(env_home + '/lib/scala-compiler.jar')
104
+ env_home
105
+ else
106
+ nil
107
+ end)
108
+ end
109
+
110
+ def installed?
111
+ !scala_home.nil?
112
+ end
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
+
122
+ def dependencies
123
+ if use_installed?
124
+ ['scala-library', 'scala-compiler'].map { |s| File.expand_path("lib/#{s}.jar", scala_home) }
125
+ else
126
+ REQUIRES.artifacts.map(&:to_s)
127
+ end
128
+ end
129
+
130
+ def use_fsc
131
+ use_installed? && ENV["USE_FSC"] =~ /^(yes|on|true)$/i
132
+ end
133
+
134
+ def applies_to?(project, task) #:nodoc:
135
+ paths = task.sources + [sources].flatten.map { |src| Array(project.path_to(:source, task.usage, src.to_sym)) }
136
+ paths.flatten!
137
+
138
+ # Just select if we find .scala files
139
+ paths.any? { |path| !Dir["#{path}/**/*.scala"].empty? }
140
+ end
141
+ end
142
+
143
+ Javac = Buildr::Compiler::Javac
144
+
145
+ OPTIONS = [:warnings, :deprecation, :optimise, :target, :debug, :other, :javac]
146
+
147
+ # Lazy evaluation to allow change in buildfile
148
+ Java.classpath << lambda { dependencies }
149
+
150
+ specify :language=>:scala, :sources => [:scala, :java], :source_ext => [:scala, :java],
151
+ :target=>'classes', :target_ext=>'class', :packaging=>:jar
152
+
153
+ def initialize(project, options) #:nodoc:
154
+ super
155
+ options[:debug] = Buildr.options.debug if options[:debug].nil?
156
+ options[:warnings] = verbose if options[:warnings].nil?
157
+ options[:deprecation] ||= false
158
+ options[:optimise] ||= false
159
+ options[:make] ||= :transitivenocp if Scala.compatible_28?
160
+ options[:javac] ||= {}
161
+
162
+ @java = Javac.new(project, options[:javac])
163
+ end
164
+
165
+ def compile(sources, target, dependencies) #:nodoc:
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
172
+
173
+ cmd_args = []
174
+ cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR)
175
+ source_paths = sources.select { |source| File.directory?(source) }
176
+ cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
177
+ cmd_args << '-d' << File.expand_path(target)
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
+
189
+ cmd_args += files_from_sources(sources)
190
+
191
+ unless Buildr.application.options.dryrun
192
+ trace((['scalac'] + cmd_args).join(' '))
193
+
194
+ if Scalac.use_fsc
195
+ system(([File.expand_path('bin/fsc', Scalac.scala_home)] + cmd_args).join(' ')) or
196
+ fail 'Failed to compile, see errors above'
197
+ else
198
+ Java.load
199
+ begin
200
+ Java.scala.tools.nsc.Main.process(cmd_args.to_java(Java.java.lang.String))
201
+ rescue => e
202
+ fail "Scala compiler crashed:\n#{e.inspect}"
203
+ end
204
+ fail 'Failed to compile, see errors above' if Java.scala.tools.nsc.Main.reporter.hasErrors
205
+ end
206
+
207
+ unless java_sources.empty?
208
+ trace 'Compiling mixed Java/Scala sources'
209
+
210
+ # TODO includes scala-compiler.jar
211
+ deps = dependencies + Scalac.dependencies + [ File.expand_path(target) ]
212
+ @java.compile(java_sources, target, deps)
213
+ end
214
+ end
215
+ end
216
+
217
+ private
218
+
219
+ def java_sources(sources)
220
+ sources.flatten.map { |source| File.directory?(source) ? FileList["#{source}/**/*.java"] : source } .
221
+ flatten.reject { |file| File.directory?(file) || File.extname(file) != '.java' }.map { |file| File.expand_path(file) }.uniq
222
+ end
223
+
224
+ # Returns Scalac command line arguments from the set of options.
225
+ def scalac_args #:nodoc:
226
+ args = []
227
+ args << "-nowarn" unless options[:warnings]
228
+ args << "-verbose" if trace?(:scalac)
229
+ args << "-g" if options[:debug]
230
+ args << "-deprecation" if options[:deprecation]
231
+ args << "-optimise" if options[:optimise]
232
+ args << "-target:jvm-" + options[:target].to_s if options[:target]
233
+ args + Array(options[:other])
234
+ end
235
+
236
+ end
237
+
238
+ end
239
+
240
+ # Scala compiler comes first, ahead of Javac, this allows it to pick
241
+ # projects that mix Scala and Java code by spotting Scala code first.
242
+ Buildr::Compiler.compilers.unshift Buildr::Scala::Scalac