buildr 1.3.4-java → 1.3.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/CHANGELOG +35 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +3 -3
  4. data/buildr.buildfile +6 -1
  5. data/buildr.gemspec +10 -9
  6. data/doc/_config.yml +1 -0
  7. data/doc/_layouts/default.html +25 -19
  8. data/doc/artifacts.textile +0 -36
  9. data/doc/building.textile +0 -38
  10. data/doc/contributing.textile +51 -15
  11. data/doc/css/default.css +11 -4
  12. data/doc/css/print.css +32 -24
  13. data/doc/download.textile +33 -22
  14. data/doc/extending.textile +10 -20
  15. data/doc/images/1442160941-frontcover.jpg +0 -0
  16. data/doc/images/asf-logo.png +0 -0
  17. data/doc/images/note.png +0 -0
  18. data/doc/images/project-structure.png +0 -0
  19. data/doc/images/tip.png +0 -0
  20. data/doc/images/zbuildr.png +0 -0
  21. data/doc/index.textile +39 -17
  22. data/doc/{getting_started.textile → installing.textile} +3 -80
  23. data/doc/languages.textile +50 -52
  24. data/doc/more_stuff.textile +154 -62
  25. data/doc/packaging.textile +0 -82
  26. data/doc/preface.textile +41 -15
  27. data/doc/projects.textile +0 -18
  28. data/doc/quick_start.textile +210 -0
  29. data/doc/scripts/install-linux.sh +10 -2
  30. data/doc/settings_profiles.textile +1 -33
  31. data/doc/testing.textile +6 -32
  32. data/lib/buildr.rb +2 -1
  33. data/lib/buildr/core.rb +6 -0
  34. data/lib/buildr/core/application.rb +2 -5
  35. data/lib/buildr/core/build.rb +29 -19
  36. data/lib/buildr/core/compile.rb +22 -4
  37. data/lib/buildr/core/filter.rb +2 -4
  38. data/lib/buildr/core/project.rb +5 -4
  39. data/lib/buildr/core/shell.rb +198 -0
  40. data/lib/buildr/core/test.rb +2 -0
  41. data/lib/buildr/core/transports.rb +18 -19
  42. data/lib/buildr/core/util.rb +178 -9
  43. data/lib/buildr/groovy.rb +1 -0
  44. data/lib/buildr/groovy/bdd.rb +5 -5
  45. data/lib/buildr/groovy/shell.rb +48 -0
  46. data/lib/buildr/ide/eclipse.rb +148 -36
  47. data/lib/buildr/ide/eclipse/java.rb +53 -0
  48. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  49. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  50. data/lib/buildr/java/bdd.rb +16 -8
  51. data/lib/buildr/java/cobertura.rb +44 -13
  52. data/lib/buildr/java/commands.rb +5 -3
  53. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  54. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +18 -0
  55. data/lib/buildr/java/packaging.rb +2 -2
  56. data/lib/buildr/java/rjb.rb +1 -1
  57. data/lib/buildr/java/test_result.rb +48 -1
  58. data/lib/buildr/java/tests.rb +8 -5
  59. data/lib/buildr/packaging/artifact_namespace.rb +1 -1
  60. data/lib/buildr/packaging/package.rb +6 -2
  61. data/lib/buildr/packaging/zip.rb +10 -1
  62. data/lib/buildr/packaging/ziptask.rb +5 -2
  63. data/lib/buildr/scala.rb +1 -0
  64. data/lib/buildr/scala/bdd.rb +17 -8
  65. data/lib/buildr/scala/compiler.rb +66 -21
  66. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  67. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  68. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  69. data/lib/buildr/scala/shell.rb +55 -0
  70. data/lib/buildr/scala/tests.rb +6 -5
  71. data/lib/buildr/shell.rb +180 -0
  72. data/rakelib/doc.rake +2 -3
  73. data/rakelib/jekylltask.rb +42 -32
  74. data/rakelib/package.rake +4 -2
  75. data/rakelib/release.rake +8 -8
  76. data/rakelib/rspec.rake +3 -3
  77. data/rakelib/setup.rake +7 -1
  78. data/rakelib/stage.rake +9 -2
  79. data/rakelib/stage.rake~ +213 -0
  80. data/spec/core/application_spec.rb +84 -1
  81. data/spec/core/build_spec.rb +54 -2
  82. data/spec/core/common_spec.rb +1 -1
  83. data/spec/core/compile_spec.rb +2 -1
  84. data/spec/core/extension_spec.rb +93 -0
  85. data/spec/core/test_spec.rb +2 -2
  86. data/spec/core/transport_spec.rb +1 -1
  87. data/spec/groovy/bdd_spec.rb +6 -6
  88. data/spec/groovy/compiler_spec.rb +1 -0
  89. data/spec/ide/eclipse_spec.rb +262 -72
  90. data/spec/java/{ant.rb → ant_spec.rb} +0 -0
  91. data/spec/java/bdd_spec.rb +15 -0
  92. data/spec/java/cobertura_spec.rb +9 -1
  93. data/spec/java/emma_spec.rb +1 -1
  94. data/spec/java/java_spec.rb +26 -0
  95. data/spec/java/packaging_spec.rb +9 -7
  96. data/spec/java/{test_coverage_spec.rb → test_coverage_helper.rb} +6 -4
  97. data/spec/java/tests_spec.rb +22 -0
  98. data/spec/packaging/archive_spec.rb +14 -0
  99. data/spec/packaging/artifact_spec.rb +2 -2
  100. data/spec/packaging/packaging_spec.rb +97 -2
  101. data/spec/sandbox.rb +3 -1
  102. data/spec/scala/bdd_spec.rb +17 -48
  103. data/spec/scala/compiler_spec.rb +31 -2
  104. data/spec/scala/tests_spec.rb +1 -0
  105. data/spec/spec_helpers.rb +12 -0
  106. metadata +145 -148
@@ -0,0 +1,93 @@
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 Extension do
21
+
22
+ it 'should call Extension.first_time during include' do
23
+ TestExtension.should_receive(:first_time_called).once
24
+ class Buildr::Project
25
+ include TestExtension
26
+ end
27
+ end
28
+
29
+ it 'should call before_define and after_define in order when project is defined' do
30
+ begin
31
+ TestExtension.initialized do |extension|
32
+ extension.should_receive(:before_define_called).once.ordered
33
+ extension.should_receive(:after_define_called).once.ordered
34
+ end
35
+ class Buildr::Project
36
+ include TestExtension
37
+ end
38
+ define('foo')
39
+ ensure
40
+ TestExtension.initialized { |ignore| }
41
+ end
42
+ end
43
+
44
+ it 'should call before_define and after_define for each project defined' do
45
+ begin
46
+ extensions = 0
47
+ TestExtension.initialized do |extension|
48
+ extensions += 1
49
+ extension.should_receive(:before_define_called).once.ordered
50
+ extension.should_receive(:after_define_called).once.ordered
51
+ end
52
+ class Buildr::Project
53
+ include TestExtension
54
+ end
55
+ define('foo')
56
+ define('bar')
57
+ extensions.should equal(2)
58
+ ensure
59
+ TestExtension.initialized { |ignore| }
60
+ end
61
+ end
62
+ end
63
+
64
+ module TestExtension
65
+ include Extension
66
+
67
+ def initialize(*args)
68
+ # callback is used to obtain extension instance created by buildr
69
+ @@initialized.call(self) if @@initialized
70
+ super
71
+ end
72
+
73
+ def TestExtension.initialized(&block)
74
+ @@initialized = block
75
+ end
76
+
77
+ first_time do
78
+ TestExtension.first_time_called()
79
+ end
80
+
81
+ before_define do |project|
82
+ project.before_define_called()
83
+ end
84
+
85
+ after_define do |project|
86
+ project.after_define_called()
87
+ end
88
+
89
+ def TestExtension.first_time_called()
90
+ end
91
+
92
+ end
93
+
@@ -333,10 +333,10 @@ describe Buildr::TestTask, 'with passing tests' do
333
333
  it 'should execute teardown task' do
334
334
  lambda { test_task.invoke }.should run_task('foo:test:teardown')
335
335
  end
336
-
336
+
337
337
  it 'should update the last successful run timestamp' do
338
338
  before = Time.now ; test_task.invoke ; after = Time.now
339
- (before-1..after+1).should include(test_task.timestamp)
339
+ (before-1..after+1).should cover(test_task.timestamp)
340
340
  end
341
341
  end
342
342
 
@@ -511,7 +511,7 @@ describe URI::SFTP, '#write' do
511
511
  end
512
512
 
513
513
  it 'should create missing paths on server' do
514
- @sftp_session.should_receive(:opendir!).twice { |path| fail unless path == '/root' }
514
+ @sftp_session.should_receive(:opendir!) { |path| fail unless path == '/root' }
515
515
  @sftp_session.should_receive(:mkdir!).once.with('/root/path', {})
516
516
  @uri.write @content
517
517
  end
@@ -31,11 +31,11 @@ describe Buildr::Groovy::EasyB do
31
31
 
32
32
  it 'should apply to a project having EasyB sources' do
33
33
  define('one', :base_dir => 'one') do
34
- write _('src/spec/groovy/SomeBehaviour.groovy'), 'true;'
34
+ write _('src/spec/groovy/SomeSpecification.groovy'), 'true;'
35
35
  Buildr::Groovy::EasyB.applies_to?(self).should be_true
36
36
  end
37
37
  define('two', :base_dir => 'two') do
38
- write _('src/test/groovy/SomeBehaviour.groovy'), 'true;'
38
+ write _('src/test/groovy/SomeSpecification.groovy'), 'true;'
39
39
  Buildr::Groovy::EasyB.applies_to?(self).should be_false
40
40
  end
41
41
  define('three', :base_dir => 'three') do
@@ -54,14 +54,14 @@ describe Buildr::Groovy::EasyB do
54
54
 
55
55
  it 'should select a java compiler if java sources are found' do
56
56
  foo do
57
- write _('src/spec/java/SomeBehavior.java'), 'public class SomeBehavior {}'
57
+ write _('src/spec/java/SomeSpecification.java'), 'public class SomeSpecification {}'
58
58
  test.compile.language.should eql(:java)
59
59
  end
60
60
  end
61
61
 
62
- it 'should include src/spec/groovy/*Behavior.groovy' do
62
+ it 'should include src/spec/groovy/*Specification.groovy' do
63
63
  foo do
64
- spec = _('src/spec/groovy/SomeBehavior.groovy')
64
+ spec = _('src/spec/groovy/SomeSpecification.groovy')
65
65
  write spec, 'true'
66
66
  test.invoke
67
67
  test.tests.should include(spec)
@@ -77,4 +77,4 @@ describe Buildr::Groovy::EasyB do
77
77
  end
78
78
  end
79
79
 
80
- end # EasyB
80
+ end # EasyB
@@ -151,6 +151,7 @@ describe 'groovyc compiler options' do
151
151
  return compile
152
152
  end
153
153
  end
154
+ project('foo').compile
154
155
  end
155
156
 
156
157
  it 'should set warning option to false by default' do
@@ -17,85 +17,93 @@
17
17
  require File.join(File.dirname(__FILE__), '../spec_helpers')
18
18
 
19
19
 
20
+ JAVA_CONTAINER = Buildr::Eclipse::Java::CONTAINER
21
+ SCALA_CONTAINER = Buildr::Eclipse::Scala::CONTAINER
22
+ PLUGIN_CONTAINER = Buildr::Eclipse::Plugin::CONTAINER
23
+
24
+ JAVA_NATURE = Buildr::Eclipse::Java::NATURE
25
+ SCALA_NATURE = Buildr::Eclipse::Scala::NATURE
26
+ PLUGIN_NATURE = Buildr::Eclipse::Plugin::NATURE
27
+
28
+ JAVA_BUILDER = Buildr::Eclipse::Java::BUILDER
29
+ SCALA_BUILDER = Buildr::Eclipse::Scala::BUILDER
30
+ PLUGIN_BUILDERS = Buildr::Eclipse::Plugin::BUILDERS
31
+
32
+
20
33
  module EclipseHelper
21
34
  def classpath_xml_elements
22
35
  task('eclipse').invoke
23
36
  REXML::Document.new(File.open('.classpath')).root.elements
24
37
  end
25
-
26
- def classpath_sources attribute='path'
38
+
39
+ def classpath_sources(attribute='path')
27
40
  classpath_xml_elements.collect("classpathentry[@kind='src']") { |n| n.attributes[attribute] }
28
41
  end
29
-
42
+
30
43
  # <classpathentry path="PATH" output="RETURNED_VALUE"/>
31
- def classpath_specific_output path
44
+ def classpath_specific_output(path)
32
45
  specific_output = classpath_xml_elements.collect("classpathentry[@path='#{path}']") { |n| n.attributes['output'] }
33
46
  raise "expected: one output attribute for path '#{path}, got: #{specific_output.inspect}" if specific_output.length > 1
34
47
  specific_output[0]
35
48
  end
36
-
49
+
37
50
  # <classpathentry path="RETURNED_VALUE" kind="output"/>
38
51
  def classpath_default_output
39
52
  default_output = classpath_xml_elements.collect("classpathentry[@kind='output']") { |n| n.attributes['path'] }
40
53
  raise "expected: one path attribute for kind='output', got: #{default_output.inspect}" if default_output.length > 1
41
54
  default_output[0]
42
55
  end
43
-
56
+
44
57
  # <classpathentry path="PATH" sourcepath="RETURNED_VALUE" kind="var"/>
45
- def sourcepath_for_path path
58
+ def sourcepath_for_path(path)
46
59
  classpath_xml_elements.collect("classpathentry[@kind='var',@path='#{path}']") do |n|
47
60
  n.attributes['sourcepath'] || 'no source artifact'
48
61
  end
49
62
  end
50
-
63
+
51
64
  def project_xml_elements
52
65
  task('eclipse').invoke
53
66
  REXML::Document.new(File.open('.project')).root.elements
54
67
  end
68
+
69
+ def project_natures
70
+ project_xml_elements.collect("natures/nature") { |n| n.text }
71
+ end
72
+
73
+ def build_commands
74
+ project_xml_elements.collect("buildSpec/buildCommand/name") { |n| n.text }
75
+ end
76
+
77
+ def classpath_containers(attribute='path')
78
+ classpath_xml_elements.collect("classpathentry[@kind='con']") { |n| n.attributes[attribute] }
79
+ end
55
80
  end
56
81
 
57
82
 
58
83
  describe Buildr::Eclipse do
59
84
  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
85
 
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'
86
+ describe "eclipse's .project file" do
71
87
 
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
88
  describe 'java project' do
81
89
  before do
82
90
  write 'buildfile'
83
91
  write 'src/main/java/Main.java'
84
92
  end
85
-
93
+
86
94
  it 'should have Java nature' do
87
95
  define('foo')
88
96
  project_natures.should include(JAVA_NATURE)
89
97
  end
90
-
98
+
91
99
  it 'should have Java build command' do
92
100
  define('foo')
93
101
  build_commands.should include(JAVA_BUILDER)
94
102
  end
95
103
  end
96
-
104
+
97
105
  describe 'nested java project' do
98
-
106
+
99
107
  it 'should have name corresponding to its project definition' do
100
108
  mkdir 'foo'
101
109
  define('myproject') {
@@ -108,42 +116,102 @@ describe Buildr::Eclipse do
108
116
  end
109
117
 
110
118
  end
111
-
119
+
112
120
  describe 'scala project' do
113
-
121
+
122
+ before do
123
+ define 'foo' do
124
+ eclipse.natures :scala
125
+ end
126
+ end
127
+
128
+ it 'should have Scala nature before Java nature' do
129
+ project_natures.should include(SCALA_NATURE)
130
+ project_natures.should include(JAVA_NATURE)
131
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
132
+ end
133
+
134
+ it 'should have Scala build command and no Java build command' do
135
+ build_commands.should include(SCALA_BUILDER)
136
+ build_commands.should_not include(JAVA_BUILDER)
137
+ end
138
+ end
139
+
140
+ describe 'standard scala project' do
141
+
114
142
  before do
115
143
  write 'buildfile'
116
144
  write 'src/main/scala/Main.scala'
145
+ define 'foo'
117
146
  end
118
-
147
+
119
148
  it 'should have Scala nature before Java nature' do
120
- define('foo')
121
149
  project_natures.should include(SCALA_NATURE)
122
150
  project_natures.should include(JAVA_NATURE)
123
151
  project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
124
152
  end
125
-
153
+
154
+ it 'should have Scala build command and no Java build command' do
155
+ build_commands.should include(SCALA_BUILDER)
156
+ build_commands.should_not include(JAVA_BUILDER)
157
+ end
158
+ end
159
+
160
+ describe 'non-standard scala project' do
161
+
162
+ before do
163
+ write 'buildfile'
164
+ write 'src/main/foo/Main.scala'
165
+ define 'foo' do
166
+ eclipse.natures = :scala
167
+ end
168
+ end
169
+
170
+ it 'should have Scala nature before Java nature' do
171
+ project_natures.should include(SCALA_NATURE)
172
+ project_natures.should include(JAVA_NATURE)
173
+ project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
174
+ end
175
+
126
176
  it 'should have Scala build command and no Java build command' do
127
- define('foo')
128
177
  build_commands.should include(SCALA_BUILDER)
129
178
  build_commands.should_not include(JAVA_BUILDER)
130
179
  end
131
180
  end
181
+
182
+ describe 'Plugin project' do
183
+
184
+ before do
185
+ write 'buildfile'
186
+ write 'src/main/java/Activator.java'
187
+ write 'plugin.xml'
188
+ end
189
+
190
+ it 'should have plugin nature before Java nature' do
191
+ define('foo')
192
+ project_natures.should include(PLUGIN_NATURE)
193
+ project_natures.should include(JAVA_NATURE)
194
+ project_natures.index(PLUGIN_NATURE).should < project_natures.index(JAVA_NATURE)
195
+ end
196
+
197
+ it 'should have plugin build commands and the Java build command' do
198
+ define('foo')
199
+ build_commands.should include(PLUGIN_BUILDERS[0])
200
+ build_commands.should include(PLUGIN_BUILDERS[1])
201
+ build_commands.should include(JAVA_BUILDER)
202
+ end
203
+ end
132
204
  end
133
-
205
+
134
206
  describe "eclipse's .classpath file" do
135
-
207
+
136
208
  describe 'scala project' do
137
209
 
138
- def classpath_containers attribute='path'
139
- classpath_xml_elements.collect("classpathentry[@kind='con']") { |n| n.attributes[attribute] }
140
- end
141
-
142
210
  before do
143
211
  write 'buildfile'
144
212
  write 'src/main/scala/Main.scala'
145
213
  end
146
-
214
+
147
215
  it 'should have SCALA_CONTAINER before JAVA_CONTAINER' do
148
216
  define('foo')
149
217
  classpath_containers.should include(SCALA_CONTAINER)
@@ -151,15 +219,15 @@ describe Buildr::Eclipse do
151
219
  classpath_containers.index(SCALA_CONTAINER).should < classpath_containers.index(JAVA_CONTAINER)
152
220
  end
153
221
  end
154
-
222
+
155
223
  describe 'source folders' do
156
-
224
+
157
225
  before do
158
226
  write 'buildfile'
159
227
  write 'src/main/java/Main.java'
160
228
  write 'src/test/java/Test.java'
161
229
  end
162
-
230
+
163
231
  describe 'source', :shared=>true do
164
232
  it 'should ignore CVS and SVN files' do
165
233
  define('foo')
@@ -170,106 +238,106 @@ describe Buildr::Eclipse do
170
238
  end
171
239
  end
172
240
  end
173
-
241
+
174
242
  describe 'main code' do
175
243
  it_should_behave_like 'source'
176
-
244
+
177
245
  it 'should accept to come from the default directory' do
178
246
  define('foo')
179
247
  classpath_sources.should include('src/main/java')
180
248
  end
181
-
249
+
182
250
  it 'should accept to come from a user-defined directory' do
183
251
  define('foo') { compile path_to('src/java') }
184
252
  classpath_sources.should include('src/java')
185
253
  end
186
-
254
+
187
255
  it 'should accept a file task as a main source folder' do
188
256
  define('foo') { compile apt }
189
257
  classpath_sources.should include('target/generated/apt')
190
258
  end
191
-
259
+
192
260
  it 'should go to the default target directory' do
193
261
  define('foo')
194
262
  classpath_specific_output('src/main/java').should be(nil)
195
263
  classpath_default_output.should == 'target/classes'
196
264
  end
197
265
  end
198
-
266
+
199
267
  describe 'test code' do
200
268
  it_should_behave_like 'source'
201
-
269
+
202
270
  it 'should accept to come from the default directory' do
203
271
  define('foo')
204
272
  classpath_sources.should include('src/test/java')
205
273
  end
206
-
274
+
207
275
  it 'should accept to come from a user-defined directory' do
208
276
  define('foo') { test.compile path_to('src/test') }
209
277
  classpath_sources.should include('src/test')
210
278
  end
211
-
279
+
212
280
  it 'should go to the default target directory' do
213
281
  define('foo')
214
282
  classpath_specific_output('src/test/java').should == 'target/test/classes'
215
283
  end
216
-
284
+
217
285
  it 'should accept to be the only code in the project' do
218
286
  rm 'src/main/java/Main.java'
219
287
  define('foo')
220
288
  classpath_sources.should include('src/test/java')
221
289
  end
222
290
  end
223
-
291
+
224
292
  describe 'main resources' do
225
293
  it_should_behave_like 'source'
226
-
294
+
227
295
  before do
228
296
  write 'src/main/resources/config.xml'
229
297
  end
230
-
298
+
231
299
  it 'should accept to come from the default directory' do
232
300
  define('foo')
233
301
  classpath_sources.should include('src/main/resources')
234
302
  end
235
-
303
+
236
304
  it 'should share a classpath entry if it comes from a directory with code' do
237
305
  write 'src/main/java/config.properties'
238
306
  define('foo') { resources.from('src/main/java').exclude('**/*.java') }
239
307
  classpath_sources.select { |path| path == 'src/main/java'}.length.should == 1
240
308
  end
241
-
309
+
242
310
  it 'should go to the default target directory' do
243
311
  define('foo')
244
312
  classpath_specific_output('src/main/resources').should == 'target/resources'
245
313
  end
246
314
  end
247
-
315
+
248
316
  describe 'test resources' do
249
317
  it_should_behave_like 'source'
250
-
318
+
251
319
  before do
252
320
  write 'src/test/resources/config-test.xml'
253
321
  end
254
-
322
+
255
323
  it 'should accept to come from the default directory' do
256
324
  define('foo')
257
325
  classpath_sources.should include('src/test/resources')
258
326
  end
259
-
327
+
260
328
  it 'should share a classpath entry if it comes from a directory with code' do
261
329
  write 'src/test/java/config-test.properties'
262
330
  define('foo') { test.resources.from('src/test/java').exclude('**/*.java') }
263
331
  classpath_sources.select { |path| path == 'src/test/java'}.length.should == 1
264
332
  end
265
-
333
+
266
334
  it 'should go to the default target directory' do
267
335
  define('foo')
268
336
  classpath_specific_output('src/test/resources').should == 'target/test/resources'
269
337
  end
270
338
  end
271
339
  end
272
-
340
+
273
341
  describe 'project depending on another project' do
274
342
  it 'should have the underlying project in its classpath' do
275
343
  mkdir 'foo'
@@ -285,27 +353,149 @@ describe Buildr::Eclipse do
285
353
  end
286
354
  end
287
355
  end
288
-
356
+
357
+ describe 'local dependency' do
358
+ before do
359
+ write 'lib/some-local.jar'
360
+ define('foo') { compile.using(:javac).with(_('lib/some-local.jar')) }
361
+ end
362
+
363
+ it 'should have a lib artifact reference in the .classpath file' do
364
+ classpath_xml_elements.collect("classpathentry[@kind='lib']") { |n| n.attributes['path'] }.
365
+ should include(File.expand_path 'lib/some-local.jar')
366
+ end
367
+ end
368
+
369
+ describe 'generated .classes' do
370
+ before do
371
+ write 'lib/some.class'
372
+ define('foo') { compile.using(:javac).with(_('lib')) }
373
+ end
374
+
375
+ it 'should have src reference in the .classpath file' do
376
+ classpath_xml_elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.
377
+ should include('lib')
378
+ end
379
+ end
380
+
289
381
  describe 'maven2 artifact dependency' do
290
382
  before do
291
383
  define('foo') { compile.using(:javac).with('com.example:library:jar:2.0') }
292
384
  artifact('com.example:library:jar:2.0') { |task| write task.name }
293
385
  task('eclipse').invoke
294
386
  end
295
-
387
+
296
388
  it 'should have a reference in the .classpath file relative to the local M2 repo' do
297
389
  classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
298
390
  should include('M2_REPO/com/example/library/2.0/library-2.0.jar')
299
391
  end
300
-
392
+
301
393
  it 'should be downloaded' do
302
394
  file(artifact('com.example:library:jar:2.0').name).should exist
303
395
  end
304
-
396
+
305
397
  it 'should have a source artifact reference in the .classpath file' do
306
398
  sourcepath_for_path('M2_REPO/com/example/library/2.0/library-2.0.jar').
307
399
  should == ['M2_REPO/com/example/library/2.0/library-2.0-sources.jar']
308
400
  end
309
401
  end
310
-
402
+
403
+ describe 'maven2 repository variable' do
404
+ it 'should be configurable' do
405
+ define('foo') do
406
+ eclipse.options.m2_repo_var = 'PROJ_REPO'
407
+ compile.using(:javac).with('com.example:library:jar:2.0')
408
+ end
409
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
410
+
411
+ task('eclipse').invoke
412
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
413
+ should include('PROJ_REPO/com/example/library/2.0/library-2.0.jar')
414
+ end
415
+
416
+ it 'should pick the parent value by default' do
417
+ define('foo') do
418
+ eclipse.options.m2_repo_var = 'FOO_REPO'
419
+ define('bar')
420
+
421
+ define('bar2') do
422
+ eclipse.options.m2_repo_var = 'BAR2_REPO'
423
+ end
424
+ end
425
+ project('foo:bar').eclipse.options.m2_repo_var.should eql('FOO_REPO')
426
+ project('foo:bar2').eclipse.options.m2_repo_var.should eql('BAR2_REPO')
427
+ end
428
+ end
429
+
430
+ describe 'natures variable' do
431
+ it 'should be configurable' do
432
+ define('foo') do
433
+ eclipse.natures = 'dummyNature'
434
+ compile.using(:javac).with('com.example:library:jar:2.0')
435
+ end
436
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
437
+ project_natures.should include('dummyNature')
438
+ end
439
+
440
+ it 'should pick the parent value by default' do
441
+ define('foo') do
442
+ eclipse.natures = 'foo_nature'
443
+ define('bar')
444
+
445
+ define('bar2') do
446
+ eclipse.natures = 'bar2_nature'
447
+ end
448
+ end
449
+ project('foo:bar').eclipse.natures.should include('foo_nature')
450
+ project('foo:bar2').eclipse.natures.should include('bar2_nature')
451
+ end
452
+ end
453
+
454
+ describe 'builders variable' do
455
+ it 'should be configurable' do
456
+ define('foo') do
457
+ eclipse.builders 'dummyBuilder'
458
+ compile.using(:javac).with('com.example:library:jar:2.0')
459
+ end
460
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
461
+ build_commands.should include('dummyBuilder')
462
+ end
463
+
464
+ it 'should pick the parent value by default' do
465
+ define('foo') do
466
+ eclipse.builders = 'foo_builder'
467
+ define('bar')
468
+
469
+ define('bar2') do
470
+ eclipse.builders = 'bar2_builder'
471
+ end
472
+ end
473
+ project('foo:bar').eclipse.builders.should include('foo_builder')
474
+ project('foo:bar2').eclipse.builders.should include('bar2_builder')
475
+ end
476
+ end
477
+
478
+ describe 'classpath_containers variable' do
479
+ it 'should be configurable' do
480
+ define('foo') do
481
+ eclipse.classpath_containers = 'myOlGoodContainer'
482
+ compile.using(:javac).with('com.example:library:jar:2.0')
483
+ end
484
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
485
+ classpath_containers.should include('myOlGoodContainer')
486
+ end
487
+
488
+ it 'should pick the parent value by default' do
489
+ define('foo') do
490
+ eclipse.classpath_containers = 'foo_classpath_containers'
491
+ define('bar')
492
+
493
+ define('bar2') do
494
+ eclipse.classpath_containers = 'bar2_classpath_containers'
495
+ end
496
+ end
497
+ project('foo:bar').eclipse.classpath_containers.should include('foo_classpath_containers')
498
+ project('foo:bar2').eclipse.classpath_containers.should include('bar2_classpath_containers')
499
+ end
500
+ end
311
501
  end