mguymon-buildr 1.4.5-java

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 (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 +600 -0
@@ -0,0 +1,142 @@
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
+
22
+ module ScaladocDefaults
23
+ include Extension
24
+
25
+ # Default scaladoc -doc-title to project's comment or name
26
+ after_define(:scaladoc => :doc) do |project|
27
+ if project.doc.engine? Scaladoc
28
+ options = project.doc.options
29
+ key = Scala.compatible_28? ? "doc-title".to_sym : :windowtitle
30
+ options[key] = (project.comment || project.name) unless options[key]
31
+ end
32
+ end
33
+ end
34
+
35
+ class Scaladoc < Base
36
+ specify :language => :scala, :source_ext => 'scala'
37
+
38
+ def generate(sources, target, options = {})
39
+ cmd_args = [ '-d', target, trace?(:scaladoc) ? '-verbose' : '' ]
40
+ options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
41
+ each { |key, value| value.invoke if value.respond_to?(:invoke) }.
42
+ each do |key, value|
43
+ case value
44
+ when true, nil
45
+ cmd_args << "-#{key}"
46
+ when false
47
+ cmd_args << "-no#{key}"
48
+ when Hash
49
+ value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
50
+ else
51
+ cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
52
+ end
53
+ end
54
+ [:sourcepath, :classpath].each do |option|
55
+ Array(options[option]).flatten.tap do |paths|
56
+ cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
57
+ end
58
+ end
59
+ cmd_args += sources.flatten.uniq
60
+ unless Buildr.application.options.dryrun
61
+ info "Generating Scaladoc for #{project.name}"
62
+ trace (['scaladoc'] + cmd_args).join(' ')
63
+ Java.load
64
+ begin
65
+ Java.scala.tools.nsc.ScalaDoc.process(cmd_args.to_java(Java.java.lang.String))
66
+ rescue => e
67
+ fail 'Failed to generate Scaladocs, see errors above: ' + e
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ class VScaladoc < Base
74
+ VERSION = '1.2-m1'
75
+ Buildr.repositories.remote << 'http://scala-tools.org/repo-snapshots'
76
+
77
+ class << self
78
+ def dependencies
79
+ [ "org.scala-tools:vscaladoc:jar:#{VERSION}" ]
80
+ end
81
+ end
82
+
83
+ Java.classpath << dependencies
84
+
85
+ specify :language => :scala, :source_ext => 'scala'
86
+
87
+ def generate(sources, target, options = {})
88
+ cmd_args = [ '-d', target, (trace?(:vscaladoc) ? '-verbose' : ''),
89
+ '-sourcepath', project.compile.sources.join(File::PATH_SEPARATOR) ]
90
+ options.reject { |key, value| [:sourcepath, :classpath].include?(key) }.
91
+ each { |key, value| value.invoke if value.respond_to?(:invoke) }.
92
+ each do |key, value|
93
+ case value
94
+ when true, nil
95
+ cmd_args << "-#{key}"
96
+ when false
97
+ cmd_args << "-no#{key}"
98
+ when Hash
99
+ value.each { |k,v| cmd_args << "-#{key}" << k.to_s << v.to_s }
100
+ else
101
+ cmd_args += Array(value).map { |item| ["-#{key}", item.to_s] }.flatten
102
+ end
103
+ end
104
+ [:sourcepath, :classpath].each do |option|
105
+ Array(options[option]).flatten.tap do |paths|
106
+ cmd_args << "-#{option}" << paths.flatten.map(&:to_s).join(File::PATH_SEPARATOR) unless paths.empty?
107
+ end
108
+ end
109
+ cmd_args += sources.flatten.uniq
110
+ unless Buildr.application.options.dryrun
111
+ info "Generating VScaladoc for #{project.name}"
112
+ trace (['vscaladoc'] + cmd_args).join(' ')
113
+ Java.load
114
+ Java.org.scala_tools.vscaladoc.Main.main(cmd_args.to_java(Java.java.lang.String)) == 0 or
115
+ fail 'Failed to generate VScaladocs, see errors above'
116
+ end
117
+ end
118
+ end
119
+ end
120
+
121
+ module Packaging
122
+ module Scala
123
+ def package_as_scaladoc_spec(spec) #:nodoc:
124
+ spec.merge(:type=>:jar, :classifier=>'scaladoc')
125
+ end
126
+
127
+ def package_as_scaladoc(file_name) #:nodoc:
128
+ ZipTask.define_task(file_name).tap do |zip|
129
+ zip.include :from=>doc.target
130
+ end
131
+ end
132
+ end
133
+ end
134
+
135
+ class Project
136
+ include ScaladocDefaults
137
+ include Packaging::Scala
138
+ end
139
+ end
140
+
141
+ Buildr::Doc.engines << Buildr::Doc::Scaladoc
142
+ 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
+ }
@@ -0,0 +1,52 @@
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::JRebel
24
+
25
+ specify :name => :scala, :languages => [:scala]
26
+
27
+ def launch(task)
28
+ jline = [File.expand_path("lib/jline.jar", Scalac.scala_home)].find_all { |f| File.exist? f }
29
+ jline = ['jline:jline:jar:0.9.94'] if jline.empty?
30
+
31
+ cp = project.compile.dependencies +
32
+ Scalac.dependencies +
33
+ project.test.dependencies +
34
+ task.classpath
35
+
36
+ java_args = jrebel_args + task.java_args
37
+
38
+ props = jrebel_props(project).merge(task.properties)
39
+
40
+ Java::Commands.java 'scala.tools.nsc.MainGenericRunner',
41
+ '-cp', cp.join(File::PATH_SEPARATOR),
42
+ {
43
+ :properties => props,
44
+ :classpath => cp + jline,
45
+ :java_args => java_args
46
+ }
47
+ end
48
+ end
49
+ end
50
+ end
51
+
52
+ Buildr::Shell.providers << Buildr::Scala::ScalaShell
@@ -0,0 +1,171 @@
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.8'
27
+
28
+ class << self
29
+ def version
30
+ Buildr.settings.build['scala.check'] || VERSION
31
+ end
32
+
33
+ def classifier
34
+ Buildr.settings.build['scala.check.classifier'] || ""
35
+ end
36
+
37
+ def artifact
38
+ Buildr.settings.build['scala.check.artifact'] || "scalacheck_#{Buildr::Scala.version}"
39
+ end
40
+
41
+ def dependencies
42
+ (version =~ /:/) ? [version] : ["org.scala-tools.testing:#{artifact}:jar:#{classifier}:#{version}"]
43
+ end
44
+
45
+ private
46
+ def const_missing(const)
47
+ return super unless const == :REQUIRES # TODO: remove in 1.5
48
+ Buildr.application.deprecated "Please use Scala::Check.dependencies/.version instead of ScalaCheck::REQUIRES/VERSION"
49
+ dependencies
50
+ end
51
+ end
52
+ end
53
+
54
+
55
+ # ScalaTest framework, the default test framework for Scala tests.
56
+ #
57
+ # Support the following options:
58
+ # * :properties -- Hash of system properties available to the test case.
59
+ # * :environment -- Hash of environment variables available to the test case.
60
+ # * :java_args -- Arguments passed as is to the JVM.
61
+ class ScalaTest < Buildr::TestFramework::Java
62
+
63
+ VERSION = '1.3'
64
+
65
+ class << self
66
+ def version
67
+ Buildr.settings.build['scala.test'] || VERSION
68
+ end
69
+
70
+ def dependencies
71
+ ["org.scalatest:scalatest:jar:#{version}"] + Check.dependencies +
72
+ JMock.dependencies + JUnit.dependencies
73
+ end
74
+
75
+ def applies_to?(project) #:nodoc:
76
+ !Dir[project.path_to(:source, :test, :scala, '**/*.scala')].empty?
77
+ end
78
+
79
+ private
80
+ def const_missing(const)
81
+ return super unless const == :REQUIRES # TODO: remove in 1.5
82
+ Buildr.application.deprecated "Please use Scala::Test.dependencies/.version instead of ScalaTest::REQUIRES/VERSION"
83
+ dependencies
84
+ end
85
+ end
86
+
87
+ # annotation-based group inclusion
88
+ attr_accessor :group_includes
89
+
90
+ # annotation-based group exclusion
91
+ attr_accessor :group_excludes
92
+
93
+ def initialize(test_task, options)
94
+ super
95
+ @group_includes = []
96
+ @group_excludes = []
97
+ end
98
+
99
+ def tests(dependencies) #:nodoc:
100
+ filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite})
101
+ end
102
+
103
+ def run(scalatest, dependencies) #:nodoc:
104
+ mkpath task.report_to.to_s
105
+ success = []
106
+
107
+ reporter_options = 'TFGBSAR' # testSucceeded, testFailed, testIgnored, suiteAborted, runStopped, runAborted, runCompleted
108
+ scalatest.each do |suite|
109
+ info "ScalaTest #{suite.inspect}"
110
+ # Use Ant to execute the ScalaTest task, gives us performance and reporting.
111
+ reportDir = task.report_to.to_s
112
+ reportFile = File.join(reportDir, "TEST-#{suite}.txt")
113
+ taskdef = Buildr.artifacts(self.class.dependencies).each(&:invoke).map(&:to_s)
114
+ Buildr.ant('scalatest') do |ant|
115
+ # ScalaTestTask was deprecated in 1.2, in favor of ScalaTestAntTask
116
+ classname = (ScalaTest.version =~ /1\.[01]/) ? \
117
+ 'org.scalatest.tools.ScalaTestTask' : 'org.scalatest.tools.ScalaTestAntTask'
118
+ ant.taskdef :name=>'scalatest', :classname=>'org.scalatest.tools.ScalaTestTask',
119
+ :classpath=>taskdef.join(File::PATH_SEPARATOR)
120
+ ant.scalatest :runpath=>dependencies.join(File::PATH_SEPARATOR) do
121
+ ant.suite :classname=>suite
122
+ ant.reporter :type=>'stdout', :config=>reporter_options
123
+ ant.reporter :type=>'file', :filename=> reportFile, :config=>reporter_options
124
+ ant.reporter :type=>(ScalaTest.version == "1.0") ? "xml" : "junitxml",
125
+ :directory=> reportDir, :config=>reporter_options
126
+ # TODO: This should be name=>value pairs!
127
+ #ant.includes group_includes.join(" ") if group_includes
128
+ #ant.excludes group_excludes.join(" ") if group_excludes
129
+ (options[:properties] || []).each { |name, value| ant.config :name=>name, :value=>value }
130
+ end
131
+ end
132
+
133
+ # Parse for failures, errors, etc.
134
+ # This is a bit of a pain right now because ScalaTest doesn't flush its
135
+ # output synchronously before the Ant test finishes so we have to loop
136
+ # and wait for an indication that the test run was completed.
137
+ failed = false
138
+ completed = false
139
+ wait = 0
140
+ while (!completed) do
141
+ File.open(reportFile, "r") do |input|
142
+ while (line = input.gets) do
143
+ failed = (line =~ /(TESTS? FAILED)|(RUN STOPPED)|(RUN ABORTED)/) unless failed
144
+ completed |= (line =~ /Run completed/)
145
+ break if (failed)
146
+ end
147
+ end
148
+ wait += 1
149
+ break if (failed || wait > 10)
150
+ unless completed
151
+ sleep(1)
152
+ end
153
+ end
154
+ success << suite if (completed && !failed)
155
+ end
156
+
157
+ success
158
+ end # run
159
+
160
+ end # ScalaTest
161
+
162
+ end
163
+
164
+
165
+ # Backwards compatibility stuff. Remove in 1.5.
166
+ module Buildr
167
+ ScalaCheck = Scala::Check
168
+ ScalaTest = Scala::ScalaTest
169
+ end
170
+
171
+ Buildr::TestFramework << Buildr::Scala::ScalaTest
@@ -0,0 +1,185 @@
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 Shell
19
+ include Extension
20
+
21
+ class << self
22
+ def providers
23
+ @providers ||= []
24
+ end
25
+
26
+ def select_by_lang(lang)
27
+ fail 'Unable to define shell task for nil language' if lang.nil?
28
+ providers.detect { |e| e.languages.nil? ? false : e.languages.include?(lang.to_sym) }
29
+ end
30
+
31
+ alias_method :select, :select_by_lang
32
+
33
+ def select_by_name(name)
34
+ fail 'Unable to define run task for nil' if name.nil?
35
+ providers.detect { |e| e.to_sym == name.to_sym }
36
+ end
37
+
38
+ def define_task(project, name, provider = nil)
39
+ ShellTask.define_task(name).tap do |t|
40
+ t.send(:associate_with, project)
41
+ t.enhance([project.compile]) do |t|
42
+ # double-enhance to execute the provider last
43
+ t.enhance { |t| t.run }
44
+ end
45
+ t.using provider.to_sym if provider
46
+ end
47
+ end
48
+ end
49
+
50
+ first_time do
51
+ Project.local_task 'shell'
52
+
53
+ providers.each { |provider| Project.local_task "shell:#{provider.to_sym}" }
54
+ end
55
+
56
+ before_define(:shell => :compile) do |project|
57
+ define_task(project, "shell")
58
+ providers.each { |provider| define_task(project, "shell:#{provider.to_sym}", provider) }
59
+ end
60
+
61
+ after_define(:shell => :compile) do |project|
62
+ unless project.shell.provider
63
+ provider = providers.find { |p| p.languages.include? project.compile.language if p.languages }
64
+ if provider
65
+ project.shell.using provider.to_sym
66
+ project.shell.with project.test.compile.dependencies
67
+ end
68
+ end
69
+ end
70
+
71
+ # Base class for any shell provider.
72
+ class Base
73
+ attr_reader :project # :nodoc:
74
+
75
+ class << self
76
+ attr_accessor :shell_name, :languages
77
+
78
+ def specify(options)
79
+ @shell_name ||= options[:name]
80
+ @languages ||= options[:languages]
81
+ end
82
+
83
+ def to_sym
84
+ @shell_name || name.split('::').last.downcase.to_sym
85
+ end
86
+ end
87
+
88
+ def initialize(project)
89
+ @project = project
90
+ end
91
+
92
+ def launch(task)
93
+ fail 'Not implemented'
94
+ end
95
+
96
+ end
97
+
98
+ class ShellTask < Rake::Task
99
+ attr_reader :project # :nodoc:
100
+
101
+ # Classpath dependencies.
102
+ attr_accessor :classpath
103
+
104
+ # Returns the run options.
105
+ attr_reader :options
106
+
107
+ # Underlying shell provider
108
+ attr_reader :provider
109
+
110
+ def initialize(*args) # :nodoc:
111
+ super
112
+ @options = {}
113
+ @classpath = []
114
+ end
115
+
116
+ # :call-seq:
117
+ # with(*artifacts) => self
118
+ #
119
+ # Adds files and artifacts as classpath dependencies, and returns self.
120
+ def with(*specs)
121
+ @classpath |= Buildr.artifacts(specs.flatten).uniq
122
+ self
123
+ end
124
+
125
+ # :call-seq:
126
+ # using(options) => self
127
+ #
128
+ # Sets the run options from a hash and returns self.
129
+ #
130
+ # For example:
131
+ # shell.using :properties => {'foo' => 'bar'}
132
+ # shell.using :bsh
133
+ def using(*args)
134
+ if Hash === args.last
135
+ args.pop.each { |key, value| @options[key.to_sym] = value }
136
+ end
137
+
138
+ until args.empty?
139
+ new_shell = Shell.select_by_name(args.pop)
140
+ @provider = new_shell.new(project) unless new_shell.nil?
141
+ end
142
+
143
+ self
144
+ end
145
+
146
+ def run
147
+ fail "No shell provider defined in project '#{project.name}' for language '#{project.compile.language.inspect}'" unless provider
148
+ provider.launch(self)
149
+ end
150
+
151
+ def prerequisites #:nodoc:
152
+ super + classpath
153
+ end
154
+
155
+ def java_args
156
+ @options[:java_args] || (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split
157
+ end
158
+
159
+ def properties
160
+ @options[:properties] || {}
161
+ end
162
+
163
+ private
164
+ def associate_with(project)
165
+ @project ||= project
166
+ end
167
+
168
+ end
169
+
170
+ # :call-seq:
171
+ # shell(&block) => ShellTask
172
+ #
173
+ # This method returns the project's shell task. It also accepts a block to be executed
174
+ # when the shell task is invoked.
175
+ def shell(&block)
176
+ task('shell').tap do |t|
177
+ t.enhance &block if block
178
+ end
179
+ end
180
+ end
181
+
182
+ class Project
183
+ include Shell
184
+ end
185
+ end