buildr-gemjar 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/.braids +8 -0
  2. data/.gitignore +5 -0
  3. data/.rvmrc +1 -0
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +20 -0
  7. data/README.md +98 -0
  8. data/Rakefile +8 -0
  9. data/buildr-gemjar.gemspec +42 -0
  10. data/lib/buildr-gemjar.rb +162 -0
  11. data/lib/buildr-gemjar/version.rb +3 -0
  12. data/meta.rakefile +30 -0
  13. data/spec/buildr-gemjar/version_spec.rb +11 -0
  14. data/spec/buildr-gemjar_spec.rb +179 -0
  15. data/spec/repo_builder.rb +59 -0
  16. data/spec/spec_helper.rb +44 -0
  17. data/vendor/buildr/.gitignore +17 -0
  18. data/vendor/buildr/CHANGELOG +1283 -0
  19. data/vendor/buildr/Gemfile +4 -0
  20. data/vendor/buildr/LICENSE +176 -0
  21. data/vendor/buildr/NOTICE +26 -0
  22. data/vendor/buildr/README.rdoc +134 -0
  23. data/vendor/buildr/Rakefile +44 -0
  24. data/vendor/buildr/_buildr +35 -0
  25. data/vendor/buildr/_jbuildr +35 -0
  26. data/vendor/buildr/addon/buildr/antlr.rb +65 -0
  27. data/vendor/buildr/addon/buildr/bnd.rb +147 -0
  28. data/vendor/buildr/addon/buildr/cobertura.rb +22 -0
  29. data/vendor/buildr/addon/buildr/drb.rb +281 -0
  30. data/vendor/buildr/addon/buildr/emma.rb +22 -0
  31. data/vendor/buildr/addon/buildr/hibernate.rb +149 -0
  32. data/vendor/buildr/addon/buildr/javacc.rb +85 -0
  33. data/vendor/buildr/addon/buildr/jaxb_xjc.rb +72 -0
  34. data/vendor/buildr/addon/buildr/jdepend.rb +60 -0
  35. data/vendor/buildr/addon/buildr/jetty.rb +248 -0
  36. data/vendor/buildr/addon/buildr/jibx.rb +86 -0
  37. data/vendor/buildr/addon/buildr/nailgun.rb +221 -0
  38. data/vendor/buildr/addon/buildr/openjpa.rb +88 -0
  39. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  40. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  41. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  42. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  43. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  44. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  45. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  46. data/vendor/buildr/addon/buildr/protobuf.rb +88 -0
  47. data/vendor/buildr/addon/buildr/xmlbeans.rb +93 -0
  48. data/vendor/buildr/all-in-one/_buildr +19 -0
  49. data/vendor/buildr/all-in-one/buildr +368 -0
  50. data/vendor/buildr/all-in-one/buildr.cmd +1 -0
  51. data/vendor/buildr/bin/buildr +19 -0
  52. data/vendor/buildr/buildr.buildfile +58 -0
  53. data/vendor/buildr/buildr.gemspec +74 -0
  54. data/vendor/buildr/doc/_config.yml +1 -0
  55. data/vendor/buildr/doc/_layouts/default.html +90 -0
  56. data/vendor/buildr/doc/_layouts/preface.html +22 -0
  57. data/vendor/buildr/doc/artifacts.textile +217 -0
  58. data/vendor/buildr/doc/building.textile +276 -0
  59. data/vendor/buildr/doc/contributing.textile +268 -0
  60. data/vendor/buildr/doc/css/default.css +236 -0
  61. data/vendor/buildr/doc/css/print.css +101 -0
  62. data/vendor/buildr/doc/css/syntax.css +23 -0
  63. data/vendor/buildr/doc/download.textile +138 -0
  64. data/vendor/buildr/doc/extending.textile +212 -0
  65. data/vendor/buildr/doc/images/1442160941-frontcover.jpg +0 -0
  66. data/vendor/buildr/doc/images/asf-logo.gif +0 -0
  67. data/vendor/buildr/doc/images/asf-logo.png +0 -0
  68. data/vendor/buildr/doc/images/buildr-hires.png +0 -0
  69. data/vendor/buildr/doc/images/buildr.png +0 -0
  70. data/vendor/buildr/doc/images/favicon.png +0 -0
  71. data/vendor/buildr/doc/images/growl-icon.tiff +0 -0
  72. data/vendor/buildr/doc/images/note.png +0 -0
  73. data/vendor/buildr/doc/images/project-structure.png +0 -0
  74. data/vendor/buildr/doc/images/tip.png +0 -0
  75. data/vendor/buildr/doc/images/zbuildr.png +0 -0
  76. data/vendor/buildr/doc/images/zbuildr.tif +0 -0
  77. data/vendor/buildr/doc/index.textile +69 -0
  78. data/vendor/buildr/doc/installing.textile +284 -0
  79. data/vendor/buildr/doc/languages.textile +599 -0
  80. data/vendor/buildr/doc/mailing_lists.textile +29 -0
  81. data/vendor/buildr/doc/more_stuff.textile +845 -0
  82. data/vendor/buildr/doc/packaging.textile +618 -0
  83. data/vendor/buildr/doc/preface.textile +54 -0
  84. data/vendor/buildr/doc/projects.textile +276 -0
  85. data/vendor/buildr/doc/quick_start.textile +210 -0
  86. data/vendor/buildr/doc/releasing.textile +117 -0
  87. data/vendor/buildr/doc/scripts/buildr-git.rb +512 -0
  88. data/vendor/buildr/doc/scripts/gitflow.rb +296 -0
  89. data/vendor/buildr/doc/scripts/install-jruby.sh +44 -0
  90. data/vendor/buildr/doc/scripts/install-linux.sh +73 -0
  91. data/vendor/buildr/doc/scripts/install-osx.sh +52 -0
  92. data/vendor/buildr/doc/settings_profiles.textile +287 -0
  93. data/vendor/buildr/doc/testing.textile +247 -0
  94. data/vendor/buildr/etc/KEYS +189 -0
  95. data/vendor/buildr/lib/buildr.rb +44 -0
  96. data/vendor/buildr/lib/buildr/clojure.rb +34 -0
  97. data/vendor/buildr/lib/buildr/clojure/shell.rb +52 -0
  98. data/vendor/buildr/lib/buildr/core.rb +34 -0
  99. data/vendor/buildr/lib/buildr/core/application.rb +700 -0
  100. data/vendor/buildr/lib/buildr/core/build.rb +516 -0
  101. data/vendor/buildr/lib/buildr/core/cc.rb +166 -0
  102. data/vendor/buildr/lib/buildr/core/checks.rb +253 -0
  103. data/vendor/buildr/lib/buildr/core/common.rb +151 -0
  104. data/vendor/buildr/lib/buildr/core/compile.rb +622 -0
  105. data/vendor/buildr/lib/buildr/core/doc.rb +276 -0
  106. data/vendor/buildr/lib/buildr/core/environment.rb +129 -0
  107. data/vendor/buildr/lib/buildr/core/filter.rb +404 -0
  108. data/vendor/buildr/lib/buildr/core/generate.rb +197 -0
  109. data/vendor/buildr/lib/buildr/core/help.rb +119 -0
  110. data/vendor/buildr/lib/buildr/core/jrebel.rb +42 -0
  111. data/vendor/buildr/lib/buildr/core/linux.rb +30 -0
  112. data/vendor/buildr/lib/buildr/core/osx.rb +46 -0
  113. data/vendor/buildr/lib/buildr/core/progressbar.rb +161 -0
  114. data/vendor/buildr/lib/buildr/core/project.rb +975 -0
  115. data/vendor/buildr/lib/buildr/core/run.rb +43 -0
  116. data/vendor/buildr/lib/buildr/core/shell.rb +137 -0
  117. data/vendor/buildr/lib/buildr/core/test.rb +843 -0
  118. data/vendor/buildr/lib/buildr/core/transports.rb +565 -0
  119. data/vendor/buildr/lib/buildr/core/util.rb +537 -0
  120. data/vendor/buildr/lib/buildr/groovy.rb +20 -0
  121. data/vendor/buildr/lib/buildr/groovy/bdd.rb +106 -0
  122. data/vendor/buildr/lib/buildr/groovy/compiler.rb +153 -0
  123. data/vendor/buildr/lib/buildr/groovy/doc.rb +76 -0
  124. data/vendor/buildr/lib/buildr/groovy/shell.rb +57 -0
  125. data/vendor/buildr/lib/buildr/ide.rb +19 -0
  126. data/vendor/buildr/lib/buildr/ide/eclipse.rb +427 -0
  127. data/vendor/buildr/lib/buildr/ide/eclipse/java.rb +53 -0
  128. data/vendor/buildr/lib/buildr/ide/eclipse/plugin.rb +71 -0
  129. data/vendor/buildr/lib/buildr/ide/eclipse/scala.rb +68 -0
  130. data/vendor/buildr/lib/buildr/ide/idea.rb +576 -0
  131. data/vendor/buildr/lib/buildr/java.rb +25 -0
  132. data/vendor/buildr/lib/buildr/java/ant.rb +94 -0
  133. data/vendor/buildr/lib/buildr/java/bdd.rb +460 -0
  134. data/vendor/buildr/lib/buildr/java/cobertura.rb +297 -0
  135. data/vendor/buildr/lib/buildr/java/commands.rb +223 -0
  136. data/vendor/buildr/lib/buildr/java/compiler.rb +135 -0
  137. data/vendor/buildr/lib/buildr/java/deprecated.rb +141 -0
  138. data/vendor/buildr/lib/buildr/java/doc.rb +86 -0
  139. data/vendor/buildr/lib/buildr/java/ecj.rb +69 -0
  140. data/vendor/buildr/lib/buildr/java/emma.rb +244 -0
  141. data/vendor/buildr/lib/buildr/java/external.rb +73 -0
  142. data/vendor/buildr/lib/buildr/java/jruby.rb +122 -0
  143. data/vendor/buildr/lib/buildr/java/jtestr_result.rb +295 -0
  144. data/vendor/buildr/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  145. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  146. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  147. data/vendor/buildr/lib/buildr/java/packaging.rb +734 -0
  148. data/vendor/buildr/lib/buildr/java/pom.rb +178 -0
  149. data/vendor/buildr/lib/buildr/java/rjb.rb +154 -0
  150. data/vendor/buildr/lib/buildr/java/test_result.rb +101 -0
  151. data/vendor/buildr/lib/buildr/java/tests.rb +362 -0
  152. data/vendor/buildr/lib/buildr/java/version_requirement.rb +172 -0
  153. data/vendor/buildr/lib/buildr/packaging.rb +25 -0
  154. data/vendor/buildr/lib/buildr/packaging/archive.rb +535 -0
  155. data/vendor/buildr/lib/buildr/packaging/artifact.rb +903 -0
  156. data/vendor/buildr/lib/buildr/packaging/artifact_namespace.rb +984 -0
  157. data/vendor/buildr/lib/buildr/packaging/artifact_search.rb +140 -0
  158. data/vendor/buildr/lib/buildr/packaging/gems.rb +105 -0
  159. data/vendor/buildr/lib/buildr/packaging/package.rb +249 -0
  160. data/vendor/buildr/lib/buildr/packaging/tar.rb +189 -0
  161. data/vendor/buildr/lib/buildr/packaging/version_requirement.rb +192 -0
  162. data/vendor/buildr/lib/buildr/packaging/zip.rb +178 -0
  163. data/vendor/buildr/lib/buildr/packaging/ziptask.rb +356 -0
  164. data/vendor/buildr/lib/buildr/resources/buildr.icns +0 -0
  165. data/vendor/buildr/lib/buildr/resources/completed.png +0 -0
  166. data/vendor/buildr/lib/buildr/resources/failed.png +0 -0
  167. data/vendor/buildr/lib/buildr/resources/icons-license.txt +17 -0
  168. data/vendor/buildr/lib/buildr/run.rb +195 -0
  169. data/vendor/buildr/lib/buildr/scala.rb +26 -0
  170. data/vendor/buildr/lib/buildr/scala/bdd.rb +118 -0
  171. data/vendor/buildr/lib/buildr/scala/compiler.rb +242 -0
  172. data/vendor/buildr/lib/buildr/scala/doc.rb +142 -0
  173. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  174. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  175. data/vendor/buildr/lib/buildr/scala/shell.rb +52 -0
  176. data/vendor/buildr/lib/buildr/scala/tests.rb +171 -0
  177. data/vendor/buildr/lib/buildr/shell.rb +185 -0
  178. data/vendor/buildr/lib/buildr/version.rb +18 -0
  179. data/vendor/buildr/rakelib/all-in-one.rake +113 -0
  180. data/vendor/buildr/rakelib/checks.rake +57 -0
  181. data/vendor/buildr/rakelib/doc.rake +137 -0
  182. data/vendor/buildr/rakelib/metrics.rake +39 -0
  183. data/vendor/buildr/rakelib/package.rake +73 -0
  184. data/vendor/buildr/rakelib/release.rake +161 -0
  185. data/vendor/buildr/rakelib/rspec.rake +101 -0
  186. data/vendor/buildr/rakelib/setup.rake +66 -0
  187. data/vendor/buildr/rakelib/stage.rake +220 -0
  188. data/vendor/buildr/spec/addon/bnd_spec.rb +330 -0
  189. data/vendor/buildr/spec/addon/drb_spec.rb +328 -0
  190. data/vendor/buildr/spec/addon/jaxb_xjc_spec.rb +125 -0
  191. data/vendor/buildr/spec/core/application_spec.rb +631 -0
  192. data/vendor/buildr/spec/core/build_spec.rb +837 -0
  193. data/vendor/buildr/spec/core/cc_spec.rb +224 -0
  194. data/vendor/buildr/spec/core/checks_spec.rb +519 -0
  195. data/vendor/buildr/spec/core/common_spec.rb +725 -0
  196. data/vendor/buildr/spec/core/compile_spec.rb +658 -0
  197. data/vendor/buildr/spec/core/doc_spec.rb +195 -0
  198. data/vendor/buildr/spec/core/extension_spec.rb +201 -0
  199. data/vendor/buildr/spec/core/generate_spec.rb +33 -0
  200. data/vendor/buildr/spec/core/project_spec.rb +772 -0
  201. data/vendor/buildr/spec/core/run_spec.rb +93 -0
  202. data/vendor/buildr/spec/core/shell_spec.rb +146 -0
  203. data/vendor/buildr/spec/core/test_spec.rb +1320 -0
  204. data/vendor/buildr/spec/core/transport_spec.rb +544 -0
  205. data/vendor/buildr/spec/core/util_spec.rb +141 -0
  206. data/vendor/buildr/spec/groovy/bdd_spec.rb +80 -0
  207. data/vendor/buildr/spec/groovy/compiler_spec.rb +251 -0
  208. data/vendor/buildr/spec/groovy/doc_spec.rb +65 -0
  209. data/vendor/buildr/spec/ide/eclipse_spec.rb +739 -0
  210. data/vendor/buildr/spec/ide/idea_spec.rb +1144 -0
  211. data/vendor/buildr/spec/java/ant_spec.rb +37 -0
  212. data/vendor/buildr/spec/java/bdd_spec.rb +374 -0
  213. data/vendor/buildr/spec/java/cobertura_spec.rb +112 -0
  214. data/vendor/buildr/spec/java/commands_spec.rb +93 -0
  215. data/vendor/buildr/spec/java/compiler_spec.rb +252 -0
  216. data/vendor/buildr/spec/java/doc_spec.rb +56 -0
  217. data/vendor/buildr/spec/java/ecj_spec.rb +115 -0
  218. data/vendor/buildr/spec/java/emma_spec.rb +121 -0
  219. data/vendor/buildr/spec/java/external_spec.rb +56 -0
  220. data/vendor/buildr/spec/java/java_spec.rb +132 -0
  221. data/vendor/buildr/spec/java/packaging_spec.rb +1270 -0
  222. data/vendor/buildr/spec/java/run_spec.rb +78 -0
  223. data/vendor/buildr/spec/java/test_coverage_helper.rb +257 -0
  224. data/vendor/buildr/spec/java/tests_spec.rb +497 -0
  225. data/vendor/buildr/spec/packaging/archive_spec.rb +775 -0
  226. data/vendor/buildr/spec/packaging/artifact_namespace_spec.rb +743 -0
  227. data/vendor/buildr/spec/packaging/artifact_spec.rb +1066 -0
  228. data/vendor/buildr/spec/packaging/packaging_helper.rb +63 -0
  229. data/vendor/buildr/spec/packaging/packaging_spec.rb +719 -0
  230. data/vendor/buildr/spec/sandbox.rb +165 -0
  231. data/vendor/buildr/spec/scala/bdd_spec.rb +124 -0
  232. data/vendor/buildr/spec/scala/compiler_spec.rb +289 -0
  233. data/vendor/buildr/spec/scala/doc_spec.rb +88 -0
  234. data/vendor/buildr/spec/scala/scala.rb +38 -0
  235. data/vendor/buildr/spec/scala/tests_spec.rb +283 -0
  236. data/vendor/buildr/spec/spec_helpers.rb +369 -0
  237. data/vendor/buildr/spec/version_requirement_spec.rb +143 -0
  238. data/vendor/buildr/spec/xpath_matchers.rb +121 -0
  239. data/vendor/buildr/tests/BUILDR-320/Buildfile +29 -0
  240. data/vendor/buildr/tests/JavaSystemProperty/Buildfile +18 -0
  241. data/vendor/buildr/tests/JavaSystemProperty/src/test/java/FooTest.java +24 -0
  242. data/vendor/buildr/tests/compile_with_parent/Buildfile +18 -0
  243. data/vendor/buildr/tests/compile_with_parent/child/src/main/java/Foo.java +23 -0
  244. data/vendor/buildr/tests/helloWorld/Buildfile +20 -0
  245. data/vendor/buildr/tests/helloWorld/src/main/java/HelloWorld.java +23 -0
  246. data/vendor/buildr/tests/integration_testing.rb +56 -0
  247. data/vendor/buildr/tests/junit3/Buildfile +9 -0
  248. data/vendor/buildr/tests/junit3/src/main/java/Foo.java +23 -0
  249. data/vendor/buildr/tests/junit3/src/test/java/FooTest.java +28 -0
  250. data/vendor/buildr/tests/package_war_as_jar/Buildfile +15 -0
  251. data/vendor/buildr/tests/package_war_as_jar/src/main/java/Foo.java +19 -0
  252. metadata +524 -0
@@ -0,0 +1,165 @@
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
+ # The local repository we use for testing is void of any artifacts, which will break given
18
+ # that the code requires several artifacts. So we establish them first using the real local
19
+ # repository and cache these across test cases.
20
+ Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
21
+ repositories.remote << 'http://repo1.maven.org/maven2'
22
+ repositories.remote << 'http://scala-tools.org/repo-releases'
23
+
24
+ # Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
25
+ Buildr.settings.build['scala.version'] = "2.8.1"
26
+
27
+ # Add a 'require' here only for optional extensions, not for extensions that should be loaded by default.
28
+ require 'buildr/clojure'
29
+ require 'buildr/groovy'
30
+ require 'buildr/scala'
31
+ require 'buildr/bnd'
32
+ require 'buildr/jaxb_xjc'
33
+
34
+ Java.load # Anything added to the classpath.
35
+ artifacts(
36
+ TestFramework.frameworks.map(&:dependencies).flatten,
37
+ JUnit.ant_taskdef,
38
+ Buildr::Groovy.dependencies,
39
+ Buildr::JaxbXjc.dependencies,
40
+ Buildr::Bnd.dependencies,
41
+ Buildr::Scala::Specs.dependencies,
42
+ Buildr::Shell::BeanShell.artifact,
43
+ Buildr::Clojure.dependencies
44
+ ).each do |path|
45
+ file(path).invoke
46
+ end
47
+
48
+ ENV['HOME'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'home'))
49
+ mkpath ENV['HOME']
50
+
51
+ # We need to run all tests inside a _sandbox, tacking a snapshot of Buildr before the test,
52
+ # and restoring everything to its previous state after the test. Damn state changes.
53
+ module Sandbox
54
+
55
+ class << self
56
+ attr_reader :tasks, :rules
57
+
58
+ def included(spec)
59
+ spec.before(:each) { sandbox }
60
+ spec.after(:each) { reset }
61
+ end
62
+
63
+ # Require an optional extension without letting its callbacks pollute the Project class.
64
+ def require_optional_extension(extension_require_path)
65
+ project_callbacks_without_extension = Project.class_eval { @global_callbacks }.dup
66
+ begin
67
+ require extension_require_path
68
+ ensure
69
+ Project.class_eval { @global_callbacks = project_callbacks_without_extension }
70
+ end
71
+ end
72
+ end
73
+
74
+ @tasks = Buildr.application.tasks.collect do |original|
75
+ prerequisites = original.send(:prerequisites).map(&:to_s)
76
+ actions = original.instance_eval { @actions }.clone
77
+ lambda do
78
+ original.class.send(:define_task, original.name=>prerequisites).tap do |task|
79
+ task.comment = original.comment
80
+ actions.each { |action| task.enhance &action }
81
+ end
82
+ end
83
+ end
84
+ @rules = Buildr.application.instance_variable_get(:@rules)
85
+
86
+ def sandbox
87
+ @_sandbox = {}
88
+
89
+ # Create a temporary directory where we can create files, e.g,
90
+ # for projects, compilation. We need a place that does not depend
91
+ # on the current directory.
92
+ @_sandbox[:original_dir] = Dir.pwd
93
+ @temp = File.join(File.dirname(__FILE__), '../tmp')
94
+ FileUtils.mkpath @temp
95
+ Dir.chdir @temp
96
+
97
+ ARGV.clear
98
+ Buildr.application = Buildr::Application.new
99
+ Sandbox.tasks.each { |block| block.call }
100
+ Buildr.application.instance_variable_set :@rules, Sandbox.rules.clone
101
+ Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
102
+
103
+ @_sandbox[:load_path] = $LOAD_PATH.clone
104
+ #@_sandbox[:loaded_features] = $LOADED_FEATURES.clone
105
+
106
+ # Later on we'll want to lose all the on_define created during the test.
107
+ @_sandbox[:on_define] = Project.class_eval { (@on_define || []).dup }
108
+ @_sandbox[:extension_modules] = Project.class_eval { (@extension_modules || []).dup }
109
+ @_sandbox[:global_callbacks] = Project.class_eval { (@global_callbacks || []).dup }
110
+ @_sandbox[:layout] = Layout.default.clone
111
+
112
+ # Create a local repository we can play with. However, our local repository will be void
113
+ # of some essential artifacts (e.g. JUnit artifacts required by build task), so we create
114
+ # these first (see above) and keep them across test cases.
115
+ @_sandbox[:artifacts] = Artifact.class_eval { @artifacts }.clone
116
+ Buildr.repositories.local = File.expand_path('repository')
117
+ ENV['HOME'] = File.expand_path('home')
118
+ ENV['BUILDR_ENV'] = 'development'
119
+
120
+ @_sandbox[:env_keys] = ENV.keys
121
+ ['DEBUG', 'TEST', 'HTTP_PROXY', 'HTTPS_PROXY', 'USER'].each { |k| ENV.delete(k) ; ENV.delete(k.downcase) }
122
+
123
+ # Remove testing local repository, and reset all repository settings.
124
+ Buildr.repositories.instance_eval do
125
+ @local = @remote = @release_to = nil
126
+ end
127
+ Buildr.options.proxy.http = nil
128
+
129
+ # Don't output crap to the console.
130
+ trace false
131
+ verbose false
132
+ end
133
+
134
+ # Call this from teardown.
135
+ def reset
136
+ # Get rid of all the projects and the on_define blocks we used.
137
+ Project.clear
138
+
139
+ on_define = @_sandbox[:on_define]
140
+ extension_modules = @_sandbox[:extension_modules]
141
+ global_callbacks = @_sandbox[:global_callbacks]
142
+
143
+ Project.class_eval do
144
+ @on_define = on_define
145
+ @global_callbacks = global_callbacks
146
+ @extension_modules = extension_modules
147
+ end
148
+
149
+ Layout.default = @_sandbox[:layout].clone
150
+
151
+ $LOAD_PATH.replace @_sandbox[:load_path]
152
+ FileUtils.rm_rf @temp
153
+ mkpath ENV['HOME']
154
+
155
+ # Get rid of all artifacts.
156
+ @_sandbox[:artifacts].tap { |artifacts| Artifact.class_eval { @artifacts = artifacts } }
157
+
158
+ # Restore options.
159
+ Buildr.options.test = nil
160
+ (ENV.keys - @_sandbox[:env_keys]).each { |key| ENV.delete key }
161
+
162
+ Dir.chdir @_sandbox[:original_dir]
163
+ end
164
+
165
+ end
@@ -0,0 +1,124 @@
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 File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+
19
+ describe Buildr::Scala::Specs do
20
+
21
+ before(:each) do
22
+ # Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
23
+ Buildr.settings.build['scala.version'] = "2.8.1"
24
+ end
25
+
26
+ it 'should be the default when tests in src/spec/scala' do
27
+ write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
28
+ package com.example
29
+ object MySpecs extends org.specs.Specification {
30
+ "it" should {
31
+ "add" in {
32
+ val sum = 1 + 1
33
+ sum mustEqual 2
34
+ }
35
+ }
36
+ }
37
+ SCALA
38
+ define 'foo'
39
+ project('foo').test.framework.should eql(:specs)
40
+ end
41
+
42
+ it 'should include Specs dependencies' do
43
+ define('foo') { test.using(:specs) }
44
+ project('foo').test.compile.dependencies.should include(*artifacts(Scala::Specs.dependencies))
45
+ project('foo').test.dependencies.should include(*artifacts(Scala::Specs.dependencies))
46
+ end
47
+
48
+ it 'should include ScalaCheck dependencies' do
49
+ define('foo') { test.using(:specs) }
50
+ project('foo').test.compile.dependencies.should include(*artifacts(Scala::Check.dependencies))
51
+ project('foo').test.dependencies.should include(*artifacts(Scala::Check.dependencies))
52
+ end
53
+
54
+ it 'should include JMock dependencies' do
55
+ define('foo') { test.using(:scalatest) }
56
+ project('foo').test.compile.dependencies.should include(*artifacts(JMock.dependencies))
57
+ project('foo').test.dependencies.should include(*artifacts(JMock.dependencies))
58
+ end
59
+
60
+ it 'should include public objects extending org.specs.Specification' do
61
+ write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
62
+ package com.example
63
+ object MySpecs extends org.specs.Specification {
64
+ "it" should {
65
+ "add" in {
66
+ val sum = 1 + 1
67
+ sum mustEqual 2
68
+ }
69
+ }
70
+ }
71
+ SCALA
72
+ define('foo').test.invoke
73
+ project('foo').test.tests.should include('com.example.MySpecs')
74
+ end
75
+
76
+ it 'should include public objects extending org.specs.Specification even with companion classes' do
77
+ write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
78
+ package com.example
79
+ object MySpecs extends org.specs.Specification {
80
+ "it" should {
81
+ "add" in {
82
+ val sum = 1 + 1
83
+ sum mustEqual 2
84
+ }
85
+ }
86
+ }
87
+ class MySpecs extends org.specs.runner.JUnit4(MySpecs)
88
+ SCALA
89
+ define('foo').test.invoke
90
+ project('foo').test.tests.should include('com.example.MySpecs')
91
+ end
92
+
93
+ it 'should pass when spec passes' do
94
+ write 'src/spec/scala/PassingSpecs.scala', <<-SCALA
95
+ object PassingSpecs extends org.specs.Specification {
96
+ "it" should {
97
+ "add" in {
98
+ val sum = 1 + 1
99
+ sum mustEqual 2
100
+ }
101
+ }
102
+ }
103
+ SCALA
104
+ lambda { define('foo').test.invoke }.should_not raise_error
105
+ end
106
+
107
+ it 'should fail when spec fails' do
108
+ write 'src/spec/scala/StringSpecs.scala', <<-SCALA
109
+ import org.specs._
110
+ import org.specs.runner._
111
+
112
+ object StringSpecs extends Specification {
113
+ "empty string" should {
114
+ "have a zero length" in {
115
+ ("".length) mustEqual(1)
116
+ }
117
+ }
118
+ }
119
+ SCALA
120
+ define('foo')
121
+ project('foo').test.invoke rescue
122
+ project('foo').test.failed_tests.should include('StringSpecs')
123
+ end
124
+ end
@@ -0,0 +1,289 @@
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 File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+
19
+ # need to test both with and without SCALA_HOME
20
+ share_as :ScalacCompiler do
21
+
22
+ before(:each) do
23
+ # Force Scala 2.8.1 for specs; don't want to rely on SCALA_HOME
24
+ Buildr.settings.build['scala.version'] = "2.8.1"
25
+ end
26
+
27
+ it 'should identify itself from source directories' do
28
+ write 'src/main/scala/com/example/Test.scala', 'package com.example; class Test { val i = 1 }'
29
+ define('foo').compile.compiler.should eql(:scalac)
30
+ end
31
+
32
+ it 'should report the language as :scala' do
33
+ define('foo').compile.using(:scalac).language.should eql(:scala)
34
+ end
35
+
36
+ it 'should set the target directory to target/classes' do
37
+ define 'foo' do
38
+ lambda { compile.using(:scalac) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
39
+ end
40
+ end
41
+
42
+ it 'should not override existing target directory' do
43
+ define 'foo' do
44
+ compile.into('classes')
45
+ lambda { compile.using(:scalac) }.should_not change { compile.target }
46
+ end
47
+ end
48
+
49
+ it 'should not change existing list of sources' do
50
+ define 'foo' do
51
+ compile.from('sources')
52
+ lambda { compile.using(:scalac) }.should_not change { compile.sources }
53
+ end
54
+ end
55
+
56
+ it 'should include as classpath dependency' do
57
+ write 'src/dependency/Dependency.scala', 'class Dependency {}'
58
+ define 'dependency', :version=>'1.0' do
59
+ compile.from('src/dependency').into('target/dependency')
60
+ package(:jar)
61
+ end
62
+ write 'src/test/DependencyTest.scala', 'class DependencyTest { var d: Dependency = _ }'
63
+ lambda { define('foo').compile.from('src/test').with(project('dependency')).invoke }.should run_task('foo:compile')
64
+ file('target/classes/DependencyTest.class').should exist
65
+ end
66
+
67
+ def define_test1_project
68
+ write 'src/main/scala/com/example/Test1.scala', 'package com.example; class Test1 { val i = 1 }'
69
+ define 'test1', :version=>'1.0' do
70
+ package(:jar)
71
+ end
72
+ end
73
+
74
+ it 'should compile a simple .scala file into a .class file' do
75
+ define_test1_project
76
+ task('test1:compile').invoke
77
+ file('target/classes/com/example/Test1.class').should exist
78
+ end
79
+
80
+ it 'should package .class into a .jar file' do
81
+ define_test1_project
82
+ task('test1:package').invoke
83
+ file('target/test1-1.0.jar').should exist
84
+ Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
85
+ zip.file.exist?('com/example/Test1.class').should be_true
86
+ end
87
+ end
88
+
89
+ it 'should compile scala class depending on java class in same project' do
90
+ write 'src/main/java/com/example/Foo.java', 'package com.example; public class Foo {}'
91
+ write 'src/main/scala/com/example/Bar.scala', 'package com.example; class Bar extends Foo'
92
+ define 'test1', :version=>'1.0' do
93
+ package(:jar)
94
+ end
95
+ task('test1:package').invoke
96
+ file('target/test1-1.0.jar').should exist
97
+ Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
98
+ zip.file.exist?('com/example/Foo.class').should be_true
99
+ zip.file.exist?('com/example/Bar.class').should be_true
100
+ end
101
+ end
102
+
103
+ it 'should compile java class depending on scala class in same project' do
104
+ write 'src/main/scala/com/example/Foo.scala', 'package com.example; class Foo'
105
+ write 'src/main/java/com/example/Bar.java', 'package com.example; public class Bar extends Foo {}'
106
+ define 'test1', :version=>'1.0' do
107
+ package(:jar)
108
+ end
109
+ task('test1:package').invoke
110
+ file('target/test1-1.0.jar').should exist
111
+ Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
112
+ zip.file.exist?('com/example/Foo.class').should be_true
113
+ zip.file.exist?('com/example/Bar.class').should be_true
114
+ end
115
+ end
116
+ end
117
+
118
+
119
+ describe 'scala compiler (installed in SCALA_HOME)' do
120
+ it 'requires present SCALA_HOME' do
121
+ ENV['SCALA_HOME'].should_not be_nil
122
+ end
123
+
124
+ it_should_behave_like ScalacCompiler
125
+ end
126
+
127
+
128
+ describe 'scala compiler (downloaded from repository)' do
129
+ old_home = ENV['SCALA_HOME']
130
+
131
+ before :all do
132
+ ENV['SCALA_HOME'] = nil
133
+ end
134
+
135
+ it 'requires absent SCALA_HOME' do
136
+ ENV['SCALA_HOME'].should be_nil
137
+ end
138
+
139
+ it_should_behave_like ScalacCompiler
140
+
141
+ after :all do
142
+ ENV['SCALA_HOME'] = old_home
143
+ end
144
+ end
145
+
146
+
147
+ describe 'scalac compiler options' do
148
+ def compile_task
149
+ @compile_task ||= define('foo').compile.using(:scalac)
150
+ end
151
+
152
+ def scalac_args
153
+ compile_task.instance_eval { @compiler }.send(:scalac_args)
154
+ end
155
+
156
+ it 'should set warnings option to false by default' do
157
+ compile_task.options.warnings.should be_false
158
+ end
159
+
160
+ it 'should set warnings option to true when running with --verbose option' do
161
+ verbose true
162
+ compile_task.options.warnings.should be_true
163
+ end
164
+
165
+ it 'should use -nowarn argument when warnings is false' do
166
+ compile_task.using(:warnings=>false)
167
+ scalac_args.should include('-nowarn')
168
+ end
169
+
170
+ it 'should not use -nowarn argument when warnings is true' do
171
+ compile_task.using(:warnings=>true)
172
+ scalac_args.should_not include('-nowarn')
173
+ end
174
+
175
+ it 'should not use -verbose argument by default' do
176
+ scalac_args.should_not include('-verbose')
177
+ end
178
+
179
+ it 'should use -verbose argument when running with --trace=scalac option' do
180
+ Buildr.application.options.trace_categories = [:scalac]
181
+ scalac_args.should include('-verbose')
182
+ end
183
+
184
+ it 'should set debug option to true by default' do
185
+ compile_task.options.debug.should be_true
186
+ end
187
+
188
+ it 'should set debug option to false based on Buildr.options' do
189
+ Buildr.options.debug = false
190
+ compile_task.options.debug.should be_false
191
+ end
192
+
193
+ it 'should set debug option to false based on debug environment variable' do
194
+ ENV['debug'] = 'no'
195
+ compile_task.options.debug.should be_false
196
+ end
197
+
198
+ it 'should set debug option to false based on DEBUG environment variable' do
199
+ ENV['DEBUG'] = 'no'
200
+ compile_task.options.debug.should be_false
201
+ end
202
+
203
+ it 'should use -g argument when debug option is true' do
204
+ compile_task.using(:debug=>true)
205
+ scalac_args.should include('-g')
206
+ end
207
+
208
+ it 'should not use -g argument when debug option is false' do
209
+ compile_task.using(:debug=>false)
210
+ scalac_args.should_not include('-g')
211
+ end
212
+
213
+ it 'should set deprecation option to false by default' do
214
+ compile_task.options.deprecation.should be_false
215
+ end
216
+
217
+ it 'should use -deprecation argument when deprecation is true' do
218
+ compile_task.using(:deprecation=>true)
219
+ scalac_args.should include('-deprecation')
220
+ end
221
+
222
+ it 'should not use -deprecation argument when deprecation is false' do
223
+ compile_task.using(:deprecation=>false)
224
+ scalac_args.should_not include('-deprecation')
225
+ end
226
+
227
+ it 'should set optimise option to false by default' do
228
+ compile_task.options.optimise.should be_false
229
+ end
230
+
231
+ it 'should use -optimise argument when deprecation is true' do
232
+ compile_task.using(:optimise=>true)
233
+ scalac_args.should include('-optimise')
234
+ end
235
+
236
+ it 'should not use -optimise argument when deprecation is false' do
237
+ compile_task.using(:optimise=>false)
238
+ scalac_args.should_not include('-optimise')
239
+ end
240
+
241
+ it 'should not set target option by default' do
242
+ compile_task.options.target.should be_nil
243
+ scalac_args.should_not include('-target')
244
+ end
245
+
246
+ it 'should use -target:xxx argument if target option set' do
247
+ compile_task.using(:target=>'1.5')
248
+ scalac_args.should include('-target:jvm-1.5')
249
+ end
250
+
251
+ it 'should not set other option by default' do
252
+ compile_task.options.other.should be_nil
253
+ end
254
+
255
+ it 'should pass other argument if other option is string' do
256
+ compile_task.using(:other=>'-unchecked')
257
+ scalac_args.should include('-unchecked')
258
+ end
259
+
260
+ it 'should pass other argument if other option is array' do
261
+ compile_task.using(:other=>['-unchecked', '-Xprint-types'])
262
+ scalac_args.should include('-unchecked', '-Xprint-types')
263
+ end
264
+
265
+ it 'should complain about options it doesn\'t know' do
266
+ write 'source/Test.scala', 'class Test {}'
267
+ compile_task.using(:unknown=>'option')
268
+ lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
269
+ end
270
+
271
+ it 'should inherit options from parent' do
272
+ define 'foo' do
273
+ compile.using(:warnings=>true, :debug=>true, :deprecation=>true, :target=>'1.4')
274
+ define 'bar' do
275
+ compile.using(:scalac)
276
+ compile.options.warnings.should be_true
277
+ compile.options.debug.should be_true
278
+ compile.options.deprecation.should be_true
279
+ compile.options.target.should eql('1.4')
280
+ end
281
+ end
282
+ end
283
+
284
+ after do
285
+ Buildr.options.debug = nil
286
+ ENV.delete "debug"
287
+ ENV.delete "DEBUG"
288
+ end
289
+ end