buildr 1.3.5-x86-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. data/CHANGELOG +998 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +45 -0
  6. data/_buildr +29 -0
  7. data/_jbuildr +29 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +22 -0
  10. data/addon/buildr/drb.rb +281 -0
  11. data/addon/buildr/emma.rb +22 -0
  12. data/addon/buildr/hibernate.rb +142 -0
  13. data/addon/buildr/javacc.rb +85 -0
  14. data/addon/buildr/jdepend.rb +60 -0
  15. data/addon/buildr/jetty.rb +248 -0
  16. data/addon/buildr/jibx.rb +86 -0
  17. data/addon/buildr/nailgun.rb +221 -0
  18. data/addon/buildr/openjpa.rb +90 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  26. data/addon/buildr/xmlbeans.rb +93 -0
  27. data/bin/buildr +19 -0
  28. data/buildr.buildfile +58 -0
  29. data/buildr.gemspec +65 -0
  30. data/doc/_config.yml +1 -0
  31. data/doc/_layouts/default.html +88 -0
  32. data/doc/_layouts/preface.html +22 -0
  33. data/doc/artifacts.textile +211 -0
  34. data/doc/building.textile +244 -0
  35. data/doc/contributing.textile +252 -0
  36. data/doc/css/default.css +236 -0
  37. data/doc/css/print.css +101 -0
  38. data/doc/css/syntax.css +23 -0
  39. data/doc/download.textile +79 -0
  40. data/doc/extending.textile +186 -0
  41. data/doc/images/1442160941-frontcover.jpg +0 -0
  42. data/doc/images/asf-logo.gif +0 -0
  43. data/doc/images/asf-logo.png +0 -0
  44. data/doc/images/buildr-hires.png +0 -0
  45. data/doc/images/buildr.png +0 -0
  46. data/doc/images/favicon.png +0 -0
  47. data/doc/images/growl-icon.tiff +0 -0
  48. data/doc/images/note.png +0 -0
  49. data/doc/images/project-structure.png +0 -0
  50. data/doc/images/tip.png +0 -0
  51. data/doc/images/zbuildr.png +0 -0
  52. data/doc/images/zbuildr.tif +0 -0
  53. data/doc/index.textile +69 -0
  54. data/doc/installing.textile +266 -0
  55. data/doc/languages.textile +459 -0
  56. data/doc/mailing_lists.textile +25 -0
  57. data/doc/more_stuff.textile +457 -0
  58. data/doc/packaging.textile +430 -0
  59. data/doc/preface.textile +54 -0
  60. data/doc/projects.textile +271 -0
  61. data/doc/quick_start.textile +210 -0
  62. data/doc/scripts/buildr-git.rb +512 -0
  63. data/doc/scripts/gitflow.rb +296 -0
  64. data/doc/scripts/install-jruby.sh +44 -0
  65. data/doc/scripts/install-linux.sh +72 -0
  66. data/doc/scripts/install-osx.sh +52 -0
  67. data/doc/settings_profiles.textile +280 -0
  68. data/doc/testing.textile +222 -0
  69. data/etc/KEYS +151 -0
  70. data/lib/buildr.rb +36 -0
  71. data/lib/buildr/core.rb +35 -0
  72. data/lib/buildr/core/application.rb +656 -0
  73. data/lib/buildr/core/build.rb +452 -0
  74. data/lib/buildr/core/checks.rb +254 -0
  75. data/lib/buildr/core/common.rb +150 -0
  76. data/lib/buildr/core/compile.rb +608 -0
  77. data/lib/buildr/core/environment.rb +129 -0
  78. data/lib/buildr/core/filter.rb +362 -0
  79. data/lib/buildr/core/generate.rb +195 -0
  80. data/lib/buildr/core/help.rb +119 -0
  81. data/lib/buildr/core/osx.rb +46 -0
  82. data/lib/buildr/core/progressbar.rb +156 -0
  83. data/lib/buildr/core/project.rb +866 -0
  84. data/lib/buildr/core/shell.rb +198 -0
  85. data/lib/buildr/core/test.rb +723 -0
  86. data/lib/buildr/core/transports.rb +559 -0
  87. data/lib/buildr/core/util.rb +449 -0
  88. data/lib/buildr/groovy.rb +19 -0
  89. data/lib/buildr/groovy/bdd.rb +106 -0
  90. data/lib/buildr/groovy/compiler.rb +138 -0
  91. data/lib/buildr/groovy/shell.rb +48 -0
  92. data/lib/buildr/ide.rb +19 -0
  93. data/lib/buildr/ide/eclipse.rb +334 -0
  94. data/lib/buildr/ide/eclipse/java.rb +53 -0
  95. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  96. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  97. data/lib/buildr/ide/idea.ipr.template +300 -0
  98. data/lib/buildr/ide/idea.rb +190 -0
  99. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  100. data/lib/buildr/ide/idea7x.rb +212 -0
  101. data/lib/buildr/java.rb +23 -0
  102. data/lib/buildr/java/ant.rb +94 -0
  103. data/lib/buildr/java/bdd.rb +459 -0
  104. data/lib/buildr/java/cobertura.rb +274 -0
  105. data/lib/buildr/java/commands.rb +213 -0
  106. data/lib/buildr/java/compiler.rb +349 -0
  107. data/lib/buildr/java/deprecated.rb +141 -0
  108. data/lib/buildr/java/emma.rb +244 -0
  109. data/lib/buildr/java/jruby.rb +117 -0
  110. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  111. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  112. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
  113. data/lib/buildr/java/packaging.rb +716 -0
  114. data/lib/buildr/java/pom.rb +174 -0
  115. data/lib/buildr/java/rjb.rb +155 -0
  116. data/lib/buildr/java/test_result.rb +353 -0
  117. data/lib/buildr/java/tests.rb +333 -0
  118. data/lib/buildr/java/version_requirement.rb +172 -0
  119. data/lib/buildr/packaging.rb +24 -0
  120. data/lib/buildr/packaging/archive.rb +488 -0
  121. data/lib/buildr/packaging/artifact.rb +749 -0
  122. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  123. data/lib/buildr/packaging/artifact_search.rb +140 -0
  124. data/lib/buildr/packaging/gems.rb +102 -0
  125. data/lib/buildr/packaging/package.rb +238 -0
  126. data/lib/buildr/packaging/tar.rb +186 -0
  127. data/lib/buildr/packaging/version_requirement.rb +172 -0
  128. data/lib/buildr/packaging/zip.rb +73 -0
  129. data/lib/buildr/packaging/ziptask.rb +316 -0
  130. data/lib/buildr/resources/buildr.icns +0 -0
  131. data/lib/buildr/scala.rb +25 -0
  132. data/lib/buildr/scala/bdd.rb +109 -0
  133. data/lib/buildr/scala/compiler.rb +195 -0
  134. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  135. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  136. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  137. data/lib/buildr/scala/shell.rb +55 -0
  138. data/lib/buildr/scala/tests.rb +157 -0
  139. data/lib/buildr/shell.rb +180 -0
  140. data/rakelib/checks.rake +57 -0
  141. data/rakelib/doc.rake +92 -0
  142. data/rakelib/jekylltask.rb +120 -0
  143. data/rakelib/package.rake +73 -0
  144. data/rakelib/release.rake +149 -0
  145. data/rakelib/rspec.rake +73 -0
  146. data/rakelib/setup.rake +54 -0
  147. data/rakelib/stage.rake +213 -0
  148. data/rakelib/stage.rake~ +213 -0
  149. data/spec/addon/drb_spec.rb +328 -0
  150. data/spec/core/application_spec.rb +502 -0
  151. data/spec/core/build_spec.rb +677 -0
  152. data/spec/core/checks_spec.rb +519 -0
  153. data/spec/core/common_spec.rb +670 -0
  154. data/spec/core/compile_spec.rb +583 -0
  155. data/spec/core/extension_spec.rb +93 -0
  156. data/spec/core/generate_spec.rb +33 -0
  157. data/spec/core/project_spec.rb +762 -0
  158. data/spec/core/test_spec.rb +1098 -0
  159. data/spec/core/transport_spec.rb +537 -0
  160. data/spec/core/util_spec.rb +67 -0
  161. data/spec/groovy/bdd_spec.rb +80 -0
  162. data/spec/groovy/compiler_spec.rb +240 -0
  163. data/spec/ide/eclipse_spec.rb +501 -0
  164. data/spec/ide/idea7x_spec.rb +84 -0
  165. data/spec/java/ant_spec.rb +33 -0
  166. data/spec/java/bdd_spec.rb +382 -0
  167. data/spec/java/cobertura_spec.rb +85 -0
  168. data/spec/java/compiler_spec.rb +446 -0
  169. data/spec/java/emma_spec.rb +119 -0
  170. data/spec/java/java_spec.rb +124 -0
  171. data/spec/java/packaging_spec.rb +1134 -0
  172. data/spec/java/test_coverage_helper.rb +257 -0
  173. data/spec/java/tests_spec.rb +493 -0
  174. data/spec/packaging/archive_spec.rb +527 -0
  175. data/spec/packaging/artifact_namespace_spec.rb +654 -0
  176. data/spec/packaging/artifact_spec.rb +795 -0
  177. data/spec/packaging/packaging_helper.rb +63 -0
  178. data/spec/packaging/packaging_spec.rb +684 -0
  179. data/spec/sandbox.rb +142 -0
  180. data/spec/scala/bdd_spec.rb +119 -0
  181. data/spec/scala/compiler_spec.rb +284 -0
  182. data/spec/scala/scala.rb +38 -0
  183. data/spec/scala/tests_spec.rb +261 -0
  184. data/spec/spec_helpers.rb +340 -0
  185. data/spec/version_requirement_spec.rb +129 -0
  186. metadata +383 -0
data/spec/sandbox.rb ADDED
@@ -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
+
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
+ # Add a 'require' here only for optional extensions, not for extensions that should be loaded by default.
25
+ require 'buildr/groovy'
26
+ require 'buildr/scala'
27
+
28
+ Java.load # Anything added to the classpath.
29
+ artifacts(TestFramework.frameworks.map(&:dependencies).flatten, JUnit.ant_taskdef).each do |path|
30
+ file(path).invoke
31
+ end
32
+ # JtestR currently requires JUnit 4.4
33
+ file(artifact("junit:junit:jar:4.4")).invoke
34
+
35
+ ENV['HOME'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'home'))
36
+
37
+ # We need to run all tests inside a _sandbox, tacking a snapshot of Buildr before the test,
38
+ # and restoring everything to its previous state after the test. Damn state changes.
39
+ module Sandbox
40
+
41
+ class << self
42
+ attr_reader :tasks, :rules
43
+
44
+ def included(spec)
45
+ spec.before(:each) { sandbox }
46
+ spec.after(:each) { reset }
47
+ end
48
+
49
+ # Require an optional extension without letting its callbacks pollute the Project class.
50
+ def require_optional_extension(extension_require_path)
51
+ project_callbacks_without_extension = Project.class_eval { @callbacks }.dup
52
+ begin
53
+ require extension_require_path
54
+ ensure
55
+ Project.class_eval { @callbacks = project_callbacks_without_extension }
56
+ end
57
+ end
58
+ end
59
+
60
+ @tasks = Buildr.application.tasks.collect do |original|
61
+ prerequisites = original.send(:prerequisites).map(&:to_s)
62
+ actions = original.instance_eval { @actions }.clone
63
+ lambda do
64
+ original.class.send(:define_task, original.name=>prerequisites).tap do |task|
65
+ task.comment = original.comment
66
+ actions.each { |action| task.enhance &action }
67
+ end
68
+ end
69
+ end
70
+ @rules = Buildr.application.instance_variable_get(:@rules)
71
+
72
+ def sandbox
73
+ @_sandbox = {}
74
+
75
+ # Create a temporary directory where we can create files, e.g,
76
+ # for projects, compilation. We need a place that does not depend
77
+ # on the current directory.
78
+ @_sandbox[:original_dir] = Dir.pwd
79
+ @temp = File.join(File.dirname(__FILE__), '../tmp')
80
+ FileUtils.mkpath @temp
81
+ Dir.chdir @temp
82
+
83
+ ARGV.clear
84
+ Buildr.application = Buildr::Application.new
85
+ Sandbox.tasks.each { |block| block.call }
86
+ Buildr.application.instance_variable_set :@rules, Sandbox.rules.clone
87
+ Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
88
+
89
+ @_sandbox[:load_path] = $LOAD_PATH.clone
90
+ #@_sandbox[:loaded_features] = $LOADED_FEATURES.clone
91
+
92
+ # Later on we'll want to lose all the on_define created during the test.
93
+ @_sandbox[:on_define] = Project.class_eval { (@on_define || []).dup }
94
+ @_sandbox[:callbacks] = Project.class_eval { (@callbacks || []).dup }
95
+ @_sandbox[:layout] = Layout.default.clone
96
+
97
+ # Create a local repository we can play with. However, our local repository will be void
98
+ # of some essential artifacts (e.g. JUnit artifacts required by build task), so we create
99
+ # these first (see above) and keep them across test cases.
100
+ @_sandbox[:artifacts] = Artifact.class_eval { @artifacts }.clone
101
+ Buildr.repositories.local = File.expand_path('repository')
102
+ ENV['HOME'] = File.expand_path('home')
103
+ ENV['BUILDR_ENV'] = 'development'
104
+
105
+ @_sandbox[:env_keys] = ENV.keys
106
+ ['DEBUG', 'TEST', 'HTTP_PROXY', 'HTTPS_PROXY', 'USER'].each { |k| ENV.delete(k) ; ENV.delete(k.downcase) }
107
+
108
+ # Remove testing local repository, and reset all repository settings.
109
+ Buildr.repositories.instance_eval do
110
+ @local = @remote = @release_to = nil
111
+ end
112
+ Buildr.options.proxy.http = nil
113
+
114
+ # Don't output crap to the console.
115
+ trace false
116
+ verbose false
117
+ end
118
+
119
+ # Call this from teardown.
120
+ def reset
121
+ # Get rid of all the projects and the on_define blocks we used.
122
+ Project.clear
123
+ on_define = @_sandbox[:on_define]
124
+ Project.class_eval { @on_define = on_define }
125
+ callbacks = @_sandbox[:callbacks]
126
+ Project.class_eval { @callbacks = callbacks }
127
+ Layout.default = @_sandbox[:layout].clone
128
+
129
+ $LOAD_PATH.replace @_sandbox[:load_path]
130
+ FileUtils.rm_rf @temp
131
+
132
+ # Get rid of all artifacts.
133
+ @_sandbox[:artifacts].tap { |artifacts| Artifact.class_eval { @artifacts = artifacts } }
134
+
135
+ # Restore options.
136
+ Buildr.options.test = nil
137
+ (ENV.keys - @_sandbox[:env_keys]).each { |key| ENV.delete key }
138
+
139
+ Dir.chdir @_sandbox[:original_dir]
140
+ end
141
+
142
+ end
@@ -0,0 +1,119 @@
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.join(File.dirname(__FILE__), '../spec_helpers')
18
+ require 'buildr/scala'
19
+
20
+ describe Buildr::Scala::Specs do
21
+ it 'should be the default when tests in src/spec/scala' do
22
+ write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
23
+ package com.example
24
+ object MySpecs extends org.specs.Specification {
25
+ "it" should {
26
+ "add" in {
27
+ val sum = 1 + 1
28
+ sum mustEqual 2
29
+ }
30
+ }
31
+ }
32
+ SCALA
33
+ define 'foo'
34
+ project('foo').test.framework.should eql(:specs)
35
+ end
36
+
37
+ it 'should include Specs dependencies' do
38
+ define('foo') { test.using(:specs) }
39
+ project('foo').test.compile.dependencies.should include(*artifacts(Scala::Specs.dependencies))
40
+ project('foo').test.dependencies.should include(*artifacts(Scala::Specs.dependencies))
41
+ end
42
+
43
+ it 'should include ScalaCheck dependencies' do
44
+ define('foo') { test.using(:specs) }
45
+ project('foo').test.compile.dependencies.should include(*artifacts(Scala::Check.dependencies))
46
+ project('foo').test.dependencies.should include(*artifacts(Scala::Check.dependencies))
47
+ end
48
+
49
+ it 'should include JMock dependencies' do
50
+ define('foo') { test.using(:scalatest) }
51
+ project('foo').test.compile.dependencies.should include(*artifacts(JMock.dependencies))
52
+ project('foo').test.dependencies.should include(*artifacts(JMock.dependencies))
53
+ end
54
+
55
+ it 'should include public objects extending org.specs.Specification' do
56
+ write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
57
+ package com.example
58
+ object MySpecs extends org.specs.Specification {
59
+ "it" should {
60
+ "add" in {
61
+ val sum = 1 + 1
62
+ sum mustEqual 2
63
+ }
64
+ }
65
+ }
66
+ SCALA
67
+ define('foo').test.invoke
68
+ project('foo').test.tests.should include('com.example.MySpecs$')
69
+ end
70
+
71
+ it 'should include public objects extending org.specs.Specification even with companion classes' do
72
+ write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
73
+ package com.example
74
+ object MySpecs extends org.specs.Specification {
75
+ "it" should {
76
+ "add" in {
77
+ val sum = 1 + 1
78
+ sum mustEqual 2
79
+ }
80
+ }
81
+ }
82
+ class MySpecs extends org.specs.runner.JUnit4(MySpecs)
83
+ SCALA
84
+ define('foo').test.invoke
85
+ project('foo').test.tests.should include('com.example.MySpecs$')
86
+ end
87
+
88
+ it 'should pass when spec passes' do
89
+ write 'src/spec/scala/PassingSpecs.scala', <<-SCALA
90
+ object PassingSpecs extends org.specs.Specification {
91
+ "it" should {
92
+ "add" in {
93
+ val sum = 1 + 1
94
+ sum mustEqual 2
95
+ }
96
+ }
97
+ }
98
+ SCALA
99
+ lambda { define('foo').test.invoke }.should_not raise_error
100
+ end
101
+
102
+ it 'should fail when spec fails' do
103
+ write 'src/spec/scala/StringSpecs.scala', <<-SCALA
104
+ import org.specs._
105
+ import org.specs.runner._
106
+
107
+ object StringSpecs extends Specification {
108
+ "empty string" should {
109
+ "have a zero length" in {
110
+ ("".length) mustEqual(1)
111
+ }
112
+ }
113
+ }
114
+ SCALA
115
+ define('foo')
116
+ project('foo').test.invoke rescue
117
+ project('foo').test.failed_tests.should include('StringSpecs$')
118
+ end
119
+ end
@@ -0,0 +1,284 @@
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.join(File.dirname(__FILE__), '../spec_helpers')
18
+ require 'buildr/scala'
19
+
20
+ # need to test both with and without SCALA_HOME
21
+ share_as :ScalacCompiler do
22
+ it 'should identify itself from source directories' do
23
+ write 'src/main/scala/com/example/Test.scala', 'package com.example; class Test { val i = 1 }'
24
+ define('foo').compile.compiler.should eql(:scalac)
25
+ end
26
+
27
+ it 'should report the language as :scala' do
28
+ define('foo').compile.using(:scalac).language.should eql(:scala)
29
+ end
30
+
31
+ it 'should set the target directory to target/classes' do
32
+ define 'foo' do
33
+ lambda { compile.using(:scalac) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
34
+ end
35
+ end
36
+
37
+ it 'should not override existing target directory' do
38
+ define 'foo' do
39
+ compile.into('classes')
40
+ lambda { compile.using(:scalac) }.should_not change { compile.target }
41
+ end
42
+ end
43
+
44
+ it 'should not change existing list of sources' do
45
+ define 'foo' do
46
+ compile.from('sources')
47
+ lambda { compile.using(:scalac) }.should_not change { compile.sources }
48
+ end
49
+ end
50
+
51
+ it 'should include as classpath dependency' do
52
+ write 'src/dependency/Dependency.scala', 'class Dependency {}'
53
+ define 'dependency', :version=>'1.0' do
54
+ compile.from('src/dependency').into('target/dependency')
55
+ package(:jar)
56
+ end
57
+ write 'src/test/DependencyTest.scala', 'class DependencyTest { var d: Dependency = _ }'
58
+ lambda { define('foo').compile.from('src/test').with(project('dependency')).invoke }.should run_task('foo:compile')
59
+ file('target/classes/DependencyTest.class').should exist
60
+ end
61
+
62
+ def define_test1_project
63
+ write 'src/main/scala/com/example/Test1.scala', 'package com.example; class Test1 { val i = 1 }'
64
+ define 'test1', :version=>'1.0' do
65
+ package(:jar)
66
+ end
67
+ end
68
+
69
+ it 'should compile a simple .scala file into a .class file' do
70
+ define_test1_project
71
+ task('test1:compile').invoke
72
+ file('target/classes/com/example/Test1.class').should exist
73
+ end
74
+
75
+ it 'should package .class into a .jar file' do
76
+ define_test1_project
77
+ task('test1:package').invoke
78
+ file('target/test1-1.0.jar').should exist
79
+ Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
80
+ zip.file.exist?('com/example/Test1.class').should be_true
81
+ end
82
+ end
83
+
84
+ it 'should compile scala class depending on java class in same project' do
85
+ write 'src/main/java/com/example/Foo.java', 'package com.example; public class Foo {}'
86
+ write 'src/main/scala/com/example/Bar.scala', 'package com.example; class Bar extends Foo'
87
+ define 'test1', :version=>'1.0' do
88
+ package(:jar)
89
+ end
90
+ task('test1:package').invoke
91
+ file('target/test1-1.0.jar').should exist
92
+ Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
93
+ zip.file.exist?('com/example/Foo.class').should be_true
94
+ zip.file.exist?('com/example/Bar.class').should be_true
95
+ end
96
+ end
97
+
98
+ it 'should compile java class depending on scala class in same project' do
99
+ write 'src/main/scala/com/example/Foo.scala', 'package com.example; class Foo'
100
+ write 'src/main/java/com/example/Bar.java', 'package com.example; public class Bar extends Foo {}'
101
+ define 'test1', :version=>'1.0' do
102
+ package(:jar)
103
+ end
104
+ task('test1:package').invoke
105
+ file('target/test1-1.0.jar').should exist
106
+ Zip::ZipFile.open(project('test1').package(:jar).to_s) do |zip|
107
+ zip.file.exist?('com/example/Foo.class').should be_true
108
+ zip.file.exist?('com/example/Bar.class').should be_true
109
+ end
110
+ end
111
+ end
112
+
113
+
114
+ describe 'scala compiler (installed in SCALA_HOME)' do
115
+ it 'requires present SCALA_HOME' do
116
+ ENV['SCALA_HOME'].should_not be_nil
117
+ end
118
+
119
+ it_should_behave_like ScalacCompiler
120
+ end
121
+
122
+
123
+ describe 'scala compiler (downloaded from repository)' do
124
+ old_home = ENV['SCALA_HOME']
125
+
126
+ before :all do
127
+ ENV['SCALA_HOME'] = nil
128
+ end
129
+
130
+ it 'requires absent SCALA_HOME' do
131
+ ENV['SCALA_HOME'].should be_nil
132
+ end
133
+
134
+ it_should_behave_like ScalacCompiler
135
+
136
+ after :all do
137
+ ENV['SCALA_HOME'] = old_home
138
+ end
139
+ end
140
+
141
+
142
+ describe 'scalac compiler options' do
143
+ def compile_task
144
+ @compile_task ||= define('foo').compile.using(:scalac)
145
+ end
146
+
147
+ def scalac_args
148
+ compile_task.instance_eval { @compiler }.send(:scalac_args)
149
+ end
150
+
151
+ it 'should set warnings option to false by default' do
152
+ compile_task.options.warnings.should be_false
153
+ end
154
+
155
+ it 'should set wranings option to true when running with --verbose option' do
156
+ verbose true
157
+ compile_task.options.warnings.should be_true
158
+ end
159
+
160
+ it 'should use -nowarn argument when warnings is false' do
161
+ compile_task.using(:warnings=>false)
162
+ scalac_args.should include('-nowarn')
163
+ end
164
+
165
+ it 'should not use -nowarn argument when warnings is true' do
166
+ compile_task.using(:warnings=>true)
167
+ scalac_args.should_not include('-nowarn')
168
+ end
169
+
170
+ it 'should not use -verbose argument by default' do
171
+ scalac_args.should_not include('-verbose')
172
+ end
173
+
174
+ it 'should use -verbose argument when running with --trace option' do
175
+ trace true
176
+ scalac_args.should include('-verbose')
177
+ end
178
+
179
+ it 'should set debug option to true by default' do
180
+ compile_task.options.debug.should be_true
181
+ end
182
+
183
+ it 'should set debug option to false based on Buildr.options' do
184
+ Buildr.options.debug = false
185
+ compile_task.options.debug.should be_false
186
+ end
187
+
188
+ it 'should set debug option to false based on debug environment variable' do
189
+ ENV['debug'] = 'no'
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 use -g argument when debug option is true' do
199
+ compile_task.using(:debug=>true)
200
+ scalac_args.should include('-g')
201
+ end
202
+
203
+ it 'should not use -g argument when debug option is false' do
204
+ compile_task.using(:debug=>false)
205
+ scalac_args.should_not include('-g')
206
+ end
207
+
208
+ it 'should set deprecation option to false by default' do
209
+ compile_task.options.deprecation.should be_false
210
+ end
211
+
212
+ it 'should use -deprecation argument when deprecation is true' do
213
+ compile_task.using(:deprecation=>true)
214
+ scalac_args.should include('-deprecation')
215
+ end
216
+
217
+ it 'should not use -deprecation argument when deprecation is false' do
218
+ compile_task.using(:deprecation=>false)
219
+ scalac_args.should_not include('-deprecation')
220
+ end
221
+
222
+ it 'should set optimise option to false by default' do
223
+ compile_task.options.optimise.should be_false
224
+ end
225
+
226
+ it 'should use -optimise argument when deprecation is true' do
227
+ compile_task.using(:optimise=>true)
228
+ scalac_args.should include('-optimise')
229
+ end
230
+
231
+ it 'should not use -optimise argument when deprecation is false' do
232
+ compile_task.using(:optimise=>false)
233
+ scalac_args.should_not include('-optimise')
234
+ end
235
+
236
+ it 'should not set target option by default' do
237
+ compile_task.options.target.should be_nil
238
+ scalac_args.should_not include('-target')
239
+ end
240
+
241
+ it 'should use -target:xxx argument if target option set' do
242
+ compile_task.using(:target=>'1.5')
243
+ scalac_args.should include('-target:jvm-1.5')
244
+ end
245
+
246
+ it 'should not set other option by default' do
247
+ compile_task.options.other.should be_nil
248
+ end
249
+
250
+ it 'should pass other argument if other option is string' do
251
+ compile_task.using(:other=>'-unchecked')
252
+ scalac_args.should include('-unchecked')
253
+ end
254
+
255
+ it 'should pass other argument if other option is array' do
256
+ compile_task.using(:other=>['-unchecked', '-Xprint-types'])
257
+ scalac_args.should include('-unchecked', '-Xprint-types')
258
+ end
259
+
260
+ it 'should complain about options it doesn\'t know' do
261
+ write 'source/Test.scala', 'class Test {}'
262
+ compile_task.using(:unknown=>'option')
263
+ lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
264
+ end
265
+
266
+ it 'should inherit options from parent' do
267
+ define 'foo' do
268
+ compile.using(:warnings=>true, :debug=>true, :deprecation=>true, :target=>'1.4')
269
+ define 'bar' do
270
+ compile.using(:scalac)
271
+ compile.options.warnings.should be_true
272
+ compile.options.debug.should be_true
273
+ compile.options.deprecation.should be_true
274
+ compile.options.target.should eql('1.4')
275
+ end
276
+ end
277
+ end
278
+
279
+ after do
280
+ Buildr.options.debug = nil
281
+ ENV.delete "debug"
282
+ ENV.delete "DEBUG"
283
+ end
284
+ end