ittayd-buildr 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/CHANGELOG +915 -0
  2. data/DISCLAIMER +7 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.rdoc +146 -0
  6. data/Rakefile +64 -0
  7. data/_buildr +28 -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/path.rb +136 -0
  27. data/addon/buildr/xmlbeans.rb +93 -0
  28. data/bin/buildr +19 -0
  29. data/buildr.buildfile +53 -0
  30. data/buildr.gemspec +58 -0
  31. data/doc/css/default.css +228 -0
  32. data/doc/css/print.css +100 -0
  33. data/doc/css/syntax.css +52 -0
  34. data/doc/images/apache-incubator-logo.png +0 -0
  35. data/doc/images/buildr-hires.png +0 -0
  36. data/doc/images/buildr.png +0 -0
  37. data/doc/images/favicon.png +0 -0
  38. data/doc/images/growl-icon.tiff +0 -0
  39. data/doc/images/note.png +0 -0
  40. data/doc/images/project-structure.png +0 -0
  41. data/doc/images/tip.png +0 -0
  42. data/doc/images/zbuildr.tif +0 -0
  43. data/doc/pages/artifacts.textile +207 -0
  44. data/doc/pages/building.textile +240 -0
  45. data/doc/pages/contributing.textile +208 -0
  46. data/doc/pages/download.textile +62 -0
  47. data/doc/pages/extending.textile +175 -0
  48. data/doc/pages/getting_started.textile +273 -0
  49. data/doc/pages/index.textile +42 -0
  50. data/doc/pages/languages.textile +407 -0
  51. data/doc/pages/mailing_lists.textile +17 -0
  52. data/doc/pages/more_stuff.textile +314 -0
  53. data/doc/pages/packaging.textile +427 -0
  54. data/doc/pages/projects.textile +274 -0
  55. data/doc/pages/recipes.textile +103 -0
  56. data/doc/pages/settings_profiles.textile +274 -0
  57. data/doc/pages/testing.textile +212 -0
  58. data/doc/pages/troubleshooting.textile +103 -0
  59. data/doc/pages/whats_new.textile +323 -0
  60. data/doc/print.haml +51 -0
  61. data/doc/print.toc.yaml +29 -0
  62. data/doc/scripts/buildr-git.rb +412 -0
  63. data/doc/scripts/install-jruby.sh +44 -0
  64. data/doc/scripts/install-linux.sh +64 -0
  65. data/doc/scripts/install-osx.sh +52 -0
  66. data/doc/site.haml +56 -0
  67. data/doc/site.toc.yaml +47 -0
  68. data/etc/KEYS +151 -0
  69. data/etc/git-svn-authors +16 -0
  70. data/lib/buildr/core/application.rb +665 -0
  71. data/lib/buildr/core/build.rb +311 -0
  72. data/lib/buildr/core/checks.rb +254 -0
  73. data/lib/buildr/core/common.rb +150 -0
  74. data/lib/buildr/core/compile.rb +590 -0
  75. data/lib/buildr/core/environment.rb +117 -0
  76. data/lib/buildr/core/filter.rb +366 -0
  77. data/lib/buildr/core/generate.rb +195 -0
  78. data/lib/buildr/core/help.rb +119 -0
  79. data/lib/buildr/core/osx.rb +49 -0
  80. data/lib/buildr/core/progressbar.rb +156 -0
  81. data/lib/buildr/core/project.rb +923 -0
  82. data/lib/buildr/core/test.rb +715 -0
  83. data/lib/buildr/core/transports.rb +560 -0
  84. data/lib/buildr/core/util.rb +294 -0
  85. data/lib/buildr/core.rb +29 -0
  86. data/lib/buildr/groovy/bdd.rb +106 -0
  87. data/lib/buildr/groovy/compiler.rb +138 -0
  88. data/lib/buildr/groovy.rb +18 -0
  89. data/lib/buildr/ide/eclipse.rb +222 -0
  90. data/lib/buildr/ide/idea.ipr.template +300 -0
  91. data/lib/buildr/ide/idea.rb +190 -0
  92. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  93. data/lib/buildr/ide/idea7x.rb +212 -0
  94. data/lib/buildr/ide.rb +19 -0
  95. data/lib/buildr/java/ant.rb +92 -0
  96. data/lib/buildr/java/bdd.rb +451 -0
  97. data/lib/buildr/java/cobertura.rb +236 -0
  98. data/lib/buildr/java/commands.rb +211 -0
  99. data/lib/buildr/java/compiler.rb +348 -0
  100. data/lib/buildr/java/deprecated.rb +141 -0
  101. data/lib/buildr/java/emma.rb +238 -0
  102. data/lib/buildr/java/jruby.rb +117 -0
  103. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  104. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  105. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +119 -0
  106. data/lib/buildr/java/packaging.rb +717 -0
  107. data/lib/buildr/java/pom.rb +174 -0
  108. data/lib/buildr/java/rjb.rb +155 -0
  109. data/lib/buildr/java/test_result.rb +307 -0
  110. data/lib/buildr/java/tests.rb +329 -0
  111. data/lib/buildr/java/version_requirement.rb +172 -0
  112. data/lib/buildr/java.rb +23 -0
  113. data/lib/buildr/packaging/archive.rb +488 -0
  114. data/lib/buildr/packaging/artifact.rb +759 -0
  115. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  116. data/lib/buildr/packaging/artifact_search.rb +140 -0
  117. data/lib/buildr/packaging/gems.rb +102 -0
  118. data/lib/buildr/packaging/package.rb +233 -0
  119. data/lib/buildr/packaging/tar.rb +186 -0
  120. data/lib/buildr/packaging/version_requirement.rb +172 -0
  121. data/lib/buildr/packaging/zip.rb +64 -0
  122. data/lib/buildr/packaging/ziptask.rb +313 -0
  123. data/lib/buildr/packaging.rb +24 -0
  124. data/lib/buildr/resources/buildr.icns +0 -0
  125. data/lib/buildr/scala/compiler.rb +109 -0
  126. data/lib/buildr/scala/tests.rb +203 -0
  127. data/lib/buildr/scala.rb +19 -0
  128. data/lib/buildr.rb +33 -0
  129. data/rakelib/apache.rake +191 -0
  130. data/rakelib/changelog.rake +57 -0
  131. data/rakelib/doc.rake +103 -0
  132. data/rakelib/package.rake +76 -0
  133. data/rakelib/release.rake +65 -0
  134. data/rakelib/rspec.rake +83 -0
  135. data/rakelib/rubyforge.rake +56 -0
  136. data/rakelib/scm.rake +49 -0
  137. data/rakelib/setup.rake +81 -0
  138. data/rakelib/stage.rake +48 -0
  139. data/spec/addon/drb_spec.rb +328 -0
  140. data/spec/core/application_spec.rb +419 -0
  141. data/spec/core/build_spec.rb +423 -0
  142. data/spec/core/checks_spec.rb +519 -0
  143. data/spec/core/common_spec.rb +670 -0
  144. data/spec/core/compile_spec.rb +582 -0
  145. data/spec/core/generate_spec.rb +33 -0
  146. data/spec/core/project_spec.rb +776 -0
  147. data/spec/core/test_spec.rb +1098 -0
  148. data/spec/core/transport_spec.rb +500 -0
  149. data/spec/groovy/bdd_spec.rb +80 -0
  150. data/spec/groovy/compiler_spec.rb +239 -0
  151. data/spec/ide/eclipse_spec.rb +311 -0
  152. data/spec/java/ant.rb +33 -0
  153. data/spec/java/bdd_spec.rb +358 -0
  154. data/spec/java/cobertura_spec.rb +77 -0
  155. data/spec/java/compiler_spec.rb +446 -0
  156. data/spec/java/emma_spec.rb +120 -0
  157. data/spec/java/java_spec.rb +96 -0
  158. data/spec/java/packaging_spec.rb +1120 -0
  159. data/spec/java/test_coverage_spec.rb +255 -0
  160. data/spec/java/tests_spec.rb +471 -0
  161. data/spec/packaging/archive_spec.rb +503 -0
  162. data/spec/packaging/artifact_namespace_spec.rb +646 -0
  163. data/spec/packaging/artifact_spec.rb +795 -0
  164. data/spec/packaging/packaging_helper.rb +63 -0
  165. data/spec/packaging/packaging_spec.rb +589 -0
  166. data/spec/sandbox.rb +139 -0
  167. data/spec/scala/compiler_spec.rb +228 -0
  168. data/spec/scala/tests_spec.rb +215 -0
  169. data/spec/spec_helpers.rb +327 -0
  170. data/spec/version_requirement_spec.rb +123 -0
  171. metadata +377 -0
@@ -0,0 +1,239 @@
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
+
19
+ describe 'groovyc compiler' do
20
+
21
+ it 'should identify itself from groovy source directories' do
22
+ write 'src/main/groovy/some/Hello.groovy', 'println "Hello Groovy"'
23
+ write 'src/test/groovy/some/Hello.groovy', 'println "Hello Groovy"'
24
+ define('foo') do
25
+ compile.compiler.should eql(:groovyc)
26
+ test.compile.compiler.should eql(:groovyc)
27
+ end
28
+ end
29
+
30
+ it 'should identify if groovy sources are found on java directories' do
31
+ write 'src/main/java/some/Hello.groovy', 'println "Hello Groovy"'
32
+ write 'src/test/java/some/Hello.groovy', 'println "Hello Groovy"'
33
+ define('foo') do
34
+ compile.compiler.should eql(:groovyc)
35
+ test.compile.compiler.should eql(:groovyc)
36
+ end
37
+ end
38
+
39
+ it 'should identify itself even if groovy and java sources are found' do
40
+ write 'src/main/java/some/Empty.java', 'package some; public interface Empty {}'
41
+ write 'src/main/groovy/some/Hello.groovy', 'println "Hello Groovy"'
42
+ write 'src/test/java/some/Empty.java', 'package some; public interface Empty {}'
43
+ write 'src/test/groovy/some/Hello.groovy', 'println "Hello Groovy"'
44
+ define('foo') do
45
+ compile.compiler.should eql(:groovyc)
46
+ test.compile.compiler.should eql(:groovyc)
47
+ end
48
+ end
49
+
50
+ it 'should identify from custom layout' do
51
+ write 'groovy/Hello.groovy', 'println "Hello world"'
52
+ write 'testing/Hello.groovy', 'println "Hello world"'
53
+ custom = Layout.new
54
+ custom[:source, :main, :groovy] = 'groovy'
55
+ custom[:source, :test, :groovy] = 'testing'
56
+ define 'foo', :layout=>custom do
57
+ compile.compiler.should eql(:groovyc)
58
+ test.compile.compiler.should eql(:groovyc)
59
+ end
60
+ end
61
+
62
+ it 'should identify from compile source directories' do
63
+ write 'src/com/example/Code.groovy', 'println "monkey code"'
64
+ write 'testing/com/example/Test.groovy', 'println "some test"'
65
+ define 'foo' do
66
+ lambda { compile.from 'src' }.should change { compile.compiler }.to(:groovyc)
67
+ lambda { test.compile.from 'testing' }.should change { test.compile.compiler }.to(:groovyc)
68
+ end
69
+ end
70
+
71
+ it 'should report the multi-language as :groovy, :java' do
72
+ define('foo').compile.using(:groovyc).language.should == :groovy
73
+ end
74
+
75
+ it 'should set the target directory to target/classes' do
76
+ define 'foo' do
77
+ lambda { compile.using(:groovyc) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
78
+ end
79
+ end
80
+
81
+ it 'should not override existing target directory' do
82
+ define 'foo' do
83
+ compile.into('classes')
84
+ lambda { compile.using(:groovyc) }.should_not change { compile.target }
85
+ end
86
+ end
87
+
88
+ it 'should not change existing list of sources' do
89
+ define 'foo' do
90
+ compile.from('sources')
91
+ lambda { compile.using(:groovyc) }.should_not change { compile.sources }
92
+ end
93
+ end
94
+
95
+ it 'should compile groovy sources' do
96
+ write 'src/main/groovy/some/Example.groovy', 'package some; class Example { static main(args) { println "Hello" } }'
97
+ define('foo').compile.invoke
98
+ file('target/classes/some/Example.class').should exist
99
+ end
100
+
101
+ it 'should include as classpath dependency' do
102
+ write 'src/bar/groovy/some/Foo.groovy', 'package some; interface Foo {}'
103
+ write 'src/main/groovy/some/Example.groovy', 'package some; class Example implements Foo { }'
104
+ define('bar', :version => '1.0') do
105
+ compile.from('src/bar/groovy').into('target/bar')
106
+ package(:jar)
107
+ end
108
+ lambda { define('foo').compile.with(project('bar').package(:jar)).invoke }.should run_task('foo:compile')
109
+ file('target/classes/some/Example.class').should exist
110
+ end
111
+
112
+ it 'should cross compile java sources' do
113
+ write 'src/main/java/some/Foo.java', 'package some; public interface Foo { public void hello(); }'
114
+ write 'src/main/java/some/Baz.java', 'package some; public class Baz extends Bar { }'
115
+ write 'src/main/groovy/some/Bar.groovy', 'package some; class Bar implements Foo { def void hello() { } }'
116
+ define('foo').compile.invoke
117
+ %w{Foo Bar Baz}.each { |f| file("target/classes/some/#{f}.class").should exist }
118
+ end
119
+
120
+ it 'should cross compile test java sources' do
121
+ write 'src/test/java/some/Foo.java', 'package some; public interface Foo { public void hello(); }'
122
+ write 'src/test/java/some/Baz.java', 'package some; public class Baz extends Bar { }'
123
+ write 'src/test/groovy/some/Bar.groovy', 'package some; class Bar implements Foo { def void hello() { } }'
124
+ define('foo').test.compile.invoke
125
+ %w{Foo Bar Baz}.each { |f| file("target/test/classes/some/#{f}.class").should exist }
126
+ end
127
+
128
+ it 'should package classes into a jar file' do
129
+ write 'src/main/groovy/some/Example.groovy', 'package some; class Example { }'
130
+ define('foo', :version => '1.0').package.invoke
131
+ file('target/foo-1.0.jar').should exist
132
+ Zip::ZipFile.open(project('foo').package(:jar).to_s) do |jar|
133
+ jar.file.exist?('some/Example.class').should be_true
134
+ end
135
+ end
136
+
137
+ end
138
+
139
+ describe 'groovyc compiler options' do
140
+
141
+ def groovyc(&prc)
142
+ define('foo') do
143
+ compile.using(:groovyc)
144
+ @compiler = compile.instance_eval { @compiler }
145
+ class << @compiler
146
+ public :groovyc_options, :javac_options
147
+ end
148
+ if block_given?
149
+ instance_eval(&prc)
150
+ else
151
+ return compile
152
+ end
153
+ end
154
+ end
155
+
156
+ it 'should set warning option to false by default' do
157
+ groovyc do
158
+ compile.options.warnings.should be_false
159
+ @compiler.javac_options[:nowarn].should be_true
160
+ end
161
+ end
162
+
163
+ it 'should set warning option to true when running with --verbose option' do
164
+ verbose true
165
+ groovyc do
166
+ compile.options.warnings.should be_true
167
+ @compiler.javac_options[:nowarn].should be_false
168
+ end
169
+ end
170
+
171
+ it 'should not set verbose option by default' do
172
+ groovyc.options.verbose.should be_false
173
+ end
174
+
175
+ it 'should set verbose option when running with --trace option' do
176
+ trace true
177
+ groovyc.options.verbose.should be_true
178
+ end
179
+
180
+ it 'should set debug option to false based on Buildr.options' do
181
+ Buildr.options.debug = false
182
+ groovyc.options.debug.should be_false
183
+ end
184
+
185
+ it 'should set debug option to false based on debug environment variable' do
186
+ ENV['debug'] = 'no'
187
+ groovyc.options.debug.should be_false
188
+ end
189
+
190
+ it 'should set debug option to false based on DEBUG environment variable' do
191
+ ENV['DEBUG'] = 'no'
192
+ groovyc.options.debug.should be_false
193
+ end
194
+
195
+ it 'should set deprecation option to false by default' do
196
+ groovyc.options.deprecation.should be_false
197
+ end
198
+
199
+ it 'should use deprecation argument when deprecation is true' do
200
+ groovyc do
201
+ compile.using(:deprecation=>true)
202
+ compile.options.deprecation.should be_true
203
+ @compiler.javac_options[:deprecation].should be_true
204
+ end
205
+ end
206
+
207
+ it 'should not use deprecation argument when deprecation is false' do
208
+ groovyc do
209
+ compile.using(:deprecation=>false)
210
+ compile.options.deprecation.should be_false
211
+ @compiler.javac_options[:deprecation].should_not be_true
212
+ end
213
+ end
214
+
215
+ it 'should set optimise option to false by default' do
216
+ groovyc.options.optimise.should be_false
217
+ end
218
+
219
+ it 'should use optimize argument when deprecation is true' do
220
+ groovyc do
221
+ compile.using(:optimise=>true)
222
+ @compiler.javac_options[:optimize].should be_true
223
+ end
224
+ end
225
+
226
+ it 'should not use optimize argument when deprecation is false' do
227
+ groovyc do
228
+ compile.using(:optimise=>false)
229
+ @compiler.javac_options[:optimize].should be_false
230
+ end
231
+ end
232
+
233
+ after do
234
+ Buildr.options.debug = nil
235
+ ENV.delete "debug"
236
+ ENV.delete "DEBUG"
237
+ end
238
+
239
+ end
@@ -0,0 +1,311 @@
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
+
19
+
20
+ module EclipseHelper
21
+ def classpath_xml_elements
22
+ task('eclipse').invoke
23
+ REXML::Document.new(File.open('.classpath')).root.elements
24
+ end
25
+
26
+ def classpath_sources attribute='path'
27
+ classpath_xml_elements.collect("classpathentry[@kind='src']") { |n| n.attributes[attribute] }
28
+ end
29
+
30
+ # <classpathentry path="PATH" output="RETURNED_VALUE"/>
31
+ def classpath_specific_output path
32
+ specific_output = classpath_xml_elements.collect("classpathentry[@path='#{path}']") { |n| n.attributes['output'] }
33
+ raise "expected: one output attribute for path '#{path}, got: #{specific_output.inspect}" if specific_output.length > 1
34
+ specific_output[0]
35
+ end
36
+
37
+ # <classpathentry path="RETURNED_VALUE" kind="output"/>
38
+ def classpath_default_output
39
+ default_output = classpath_xml_elements.collect("classpathentry[@kind='output']") { |n| n.attributes['path'] }
40
+ raise "expected: one path attribute for kind='output', got: #{default_output.inspect}" if default_output.length > 1
41
+ default_output[0]
42
+ end
43
+
44
+ # <classpathentry path="PATH" sourcepath="RETURNED_VALUE" kind="var"/>
45
+ def sourcepath_for_path path
46
+ classpath_xml_elements.collect("classpathentry[@kind='var',@path='#{path}']") do |n|
47
+ n.attributes['sourcepath'] || 'no source artifact'
48
+ end
49
+ end
50
+
51
+ def project_xml_elements
52
+ task('eclipse').invoke
53
+ REXML::Document.new(File.open('.project')).root.elements
54
+ end
55
+ end
56
+
57
+
58
+ describe Buildr::Eclipse do
59
+ include EclipseHelper
60
+
61
+ describe "eclipse's .project file" do
62
+
63
+ JAVA_CONTAINER = 'org.eclipse.jdt.launching.JRE_CONTAINER'
64
+ SCALA_CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
65
+
66
+ SCALA_NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
67
+ JAVA_NATURE = 'org.eclipse.jdt.core.javanature'
68
+
69
+ SCALA_BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
70
+ JAVA_BUILDER = 'org.eclipse.jdt.core.javabuilder'
71
+
72
+ def project_natures
73
+ project_xml_elements.collect("natures/nature") { |n| n.text }
74
+ end
75
+
76
+ def build_commands
77
+ project_xml_elements.collect("buildSpec/buildCommand/name") { |n| n.text }
78
+ end
79
+
80
+ describe 'java project' do
81
+ before do
82
+ write 'buildfile'
83
+ write 'src/main/java/Main.java'
84
+ end
85
+
86
+ it 'should have Java nature' do
87
+ define('foo')
88
+ project_natures.should include(JAVA_NATURE)
89
+ end
90
+
91
+ it 'should have Java build command' do
92
+ define('foo')
93
+ build_commands.should include(JAVA_BUILDER)
94
+ end
95
+ end
96
+
97
+ describe 'nested java project' do
98
+
99
+ it 'should have name corresponding to its project definition' do
100
+ mkdir 'foo'
101
+ define('myproject') {
102
+ project.version = '1.0'
103
+ define('foo') { compile.using(:javac); package :jar }
104
+ }
105
+ task('eclipse').invoke
106
+ REXML::Document.new(File.open(File.join('foo', '.project'))).root.
107
+ elements.collect("name") { |e| e.text }.should == ['myproject-foo']
108
+ end
109
+
110
+ end
111
+
112
+ describe 'scala project' do
113
+
114
+ before do
115
+ write 'buildfile'
116
+ write 'src/main/scala/Main.scala'
117
+ end
118
+
119
+ it 'should have Scala nature before Java nature' do
120
+ define('foo')
121
+ project_natures.should include(SCALA_NATURE)
122
+ project_natures.should include(JAVA_NATURE)
123
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
124
+ end
125
+
126
+ it 'should have Scala build command and no Java build command' do
127
+ define('foo')
128
+ build_commands.should include(SCALA_BUILDER)
129
+ build_commands.should_not include(JAVA_BUILDER)
130
+ end
131
+ end
132
+ end
133
+
134
+ describe "eclipse's .classpath file" do
135
+
136
+ describe 'scala project' do
137
+
138
+ def classpath_containers attribute='path'
139
+ classpath_xml_elements.collect("classpathentry[@kind='con']") { |n| n.attributes[attribute] }
140
+ end
141
+
142
+ before do
143
+ write 'buildfile'
144
+ write 'src/main/scala/Main.scala'
145
+ end
146
+
147
+ it 'should have SCALA_CONTAINER before JAVA_CONTAINER' do
148
+ define('foo')
149
+ classpath_containers.should include(SCALA_CONTAINER)
150
+ classpath_containers.should include(JAVA_CONTAINER)
151
+ classpath_containers.index(SCALA_CONTAINER).should < classpath_containers.index(JAVA_CONTAINER)
152
+ end
153
+ end
154
+
155
+ describe 'source folders' do
156
+
157
+ before do
158
+ write 'buildfile'
159
+ write 'src/main/java/Main.java'
160
+ write 'src/test/java/Test.java'
161
+ end
162
+
163
+ describe 'source', :shared=>true do
164
+ it 'should ignore CVS and SVN files' do
165
+ define('foo')
166
+ classpath_sources('excluding').each do |excluding_attribute|
167
+ excluding = excluding_attribute.split('|')
168
+ excluding.should include('**/.svn/')
169
+ excluding.should include('**/CVS/')
170
+ end
171
+ end
172
+ end
173
+
174
+ describe 'main code' do
175
+ it_should_behave_like 'source'
176
+
177
+ it 'should accept to come from the default directory' do
178
+ define('foo')
179
+ classpath_sources.should include('src/main/java')
180
+ end
181
+
182
+ it 'should accept to come from a user-defined directory' do
183
+ define('foo') { compile path_to('src/java') }
184
+ classpath_sources.should include('src/java')
185
+ end
186
+
187
+ it 'should accept a file task as a main source folder' do
188
+ define('foo') { compile apt }
189
+ classpath_sources.should include('target/generated/apt')
190
+ end
191
+
192
+ it 'should go to the default target directory' do
193
+ define('foo')
194
+ classpath_specific_output('src/main/java').should be(nil)
195
+ classpath_default_output.should == 'target/classes'
196
+ end
197
+ end
198
+
199
+ describe 'test code' do
200
+ it_should_behave_like 'source'
201
+
202
+ it 'should accept to come from the default directory' do
203
+ define('foo')
204
+ classpath_sources.should include('src/test/java')
205
+ end
206
+
207
+ it 'should accept to come from a user-defined directory' do
208
+ define('foo') { test.compile path_to('src/test') }
209
+ classpath_sources.should include('src/test')
210
+ end
211
+
212
+ it 'should go to the default target directory' do
213
+ define('foo')
214
+ classpath_specific_output('src/test/java').should == 'target/test/classes'
215
+ end
216
+
217
+ it 'should accept to be the only code in the project' do
218
+ rm 'src/main/java/Main.java'
219
+ define('foo')
220
+ classpath_sources.should include('src/test/java')
221
+ end
222
+ end
223
+
224
+ describe 'main resources' do
225
+ it_should_behave_like 'source'
226
+
227
+ before do
228
+ write 'src/main/resources/config.xml'
229
+ end
230
+
231
+ it 'should accept to come from the default directory' do
232
+ define('foo')
233
+ classpath_sources.should include('src/main/resources')
234
+ end
235
+
236
+ it 'should share a classpath entry if it comes from a directory with code' do
237
+ write 'src/main/java/config.properties'
238
+ define('foo') { resources.from('src/main/java').exclude('**/*.java') }
239
+ classpath_sources.select { |path| path == 'src/main/java'}.length.should == 1
240
+ end
241
+
242
+ it 'should go to the default target directory' do
243
+ define('foo')
244
+ classpath_specific_output('src/main/resources').should == 'target/resources'
245
+ end
246
+ end
247
+
248
+ describe 'test resources' do
249
+ it_should_behave_like 'source'
250
+
251
+ before do
252
+ write 'src/test/resources/config-test.xml'
253
+ end
254
+
255
+ it 'should accept to come from the default directory' do
256
+ define('foo')
257
+ classpath_sources.should include('src/test/resources')
258
+ end
259
+
260
+ it 'should share a classpath entry if it comes from a directory with code' do
261
+ write 'src/test/java/config-test.properties'
262
+ define('foo') { test.resources.from('src/test/java').exclude('**/*.java') }
263
+ classpath_sources.select { |path| path == 'src/test/java'}.length.should == 1
264
+ end
265
+
266
+ it 'should go to the default target directory' do
267
+ define('foo')
268
+ classpath_specific_output('src/test/resources').should == 'target/test/resources'
269
+ end
270
+ end
271
+ end
272
+
273
+ describe 'project depending on another project' do
274
+ it 'should have the underlying project in its classpath' do
275
+ mkdir 'foo'
276
+ mkdir 'bar'
277
+ define('myproject') {
278
+ project.version = '1.0'
279
+ define('foo') { package :jar }
280
+ define('bar') { compile.using(:javac).with project('foo'); }
281
+ }
282
+ task('eclipse').invoke
283
+ REXML::Document.new(File.open(File.join('bar', '.classpath'))).root.
284
+ elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should include('/myproject-foo')
285
+ end
286
+ end
287
+ end
288
+
289
+ describe 'maven2 artifact dependency' do
290
+ before do
291
+ define('foo') { compile.using(:javac).with('com.example:library:jar:2.0') }
292
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
293
+ task('eclipse').invoke
294
+ end
295
+
296
+ it 'should have a reference in the .classpath file relative to the local M2 repo' do
297
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
298
+ should include('M2_REPO/com/example/library/2.0/library-2.0.jar')
299
+ end
300
+
301
+ it 'should be downloaded' do
302
+ file(artifact('com.example:library:jar:2.0').name).should exist
303
+ end
304
+
305
+ it 'should have a source artifact reference in the .classpath file' do
306
+ sourcepath_for_path('M2_REPO/com/example/library/2.0/library-2.0.jar').
307
+ should == ['M2_REPO/com/example/library/2.0/library-2.0-sources.jar']
308
+ end
309
+ end
310
+
311
+ end
data/spec/java/ant.rb ADDED
@@ -0,0 +1,33 @@
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
+
19
+
20
+ describe Buildr::Ant do
21
+
22
+ it 'should pick Ant version from ant build settings' do
23
+ Buildr::Ant.instance_eval { @dependencies = nil }
24
+ write 'build.yaml', 'ant: 1.2.3'
25
+ Buildr::Ant.dependencies.should include("org.apache.ant:ant:jar:1.2.3")
26
+ end
27
+
28
+ it 'should have REQUIRES up to version 1.5 since it was deprecated in version 1.3.3' do
29
+ Buildr::VERSION.should < '1.5'
30
+ lambda { Ant::REQUIRES }.should_not raise_error
31
+ end
32
+
33
+ end