buildr 1.2.10 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/CHANGELOG +566 -268
  2. data/DISCLAIMER +7 -1
  3. data/KEYS +151 -0
  4. data/NOTICE +23 -8
  5. data/README +122 -22
  6. data/Rakefile +49 -229
  7. data/{lib → addon}/buildr/antlr.rb +23 -10
  8. data/addon/buildr/cobertura.rb +232 -0
  9. data/{lib → addon}/buildr/hibernate.rb +20 -4
  10. data/{lib → addon}/buildr/javacc.rb +27 -12
  11. data/addon/buildr/jdepend.rb +60 -0
  12. data/{lib → addon}/buildr/jetty.rb +34 -18
  13. data/addon/buildr/nailgun.rb +892 -0
  14. data/{lib → addon}/buildr/openjpa.rb +23 -6
  15. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  18. data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
  19. data/{lib → addon}/buildr/xmlbeans.rb +39 -14
  20. data/bin/buildr +21 -7
  21. data/buildr.gemspec +50 -0
  22. data/doc/css/default.css +225 -0
  23. data/doc/css/print.css +95 -0
  24. data/doc/css/syntax.css +43 -0
  25. data/doc/images/apache-incubator-logo.png +0 -0
  26. data/doc/images/buildr-hires.png +0 -0
  27. data/doc/images/buildr.png +0 -0
  28. data/doc/images/note.png +0 -0
  29. data/doc/images/tip.png +0 -0
  30. data/doc/images/zbuildr.tif +0 -0
  31. data/doc/pages/artifacts.textile +317 -0
  32. data/doc/pages/building.textile +501 -0
  33. data/doc/pages/contributing.textile +178 -0
  34. data/doc/pages/download.textile +25 -0
  35. data/doc/pages/extending.textile +229 -0
  36. data/doc/pages/getting_started.textile +337 -0
  37. data/doc/pages/index.textile +63 -0
  38. data/doc/pages/mailing_lists.textile +17 -0
  39. data/doc/pages/more_stuff.textile +367 -0
  40. data/doc/pages/packaging.textile +592 -0
  41. data/doc/pages/projects.textile +449 -0
  42. data/doc/pages/recipes.textile +127 -0
  43. data/doc/pages/settings_profiles.textile +339 -0
  44. data/doc/pages/testing.textile +475 -0
  45. data/doc/pages/troubleshooting.textile +121 -0
  46. data/doc/pages/whats_new.textile +389 -0
  47. data/doc/print.haml +52 -0
  48. data/doc/print.toc.yaml +28 -0
  49. data/doc/scripts/buildr-git.rb +411 -0
  50. data/doc/scripts/install-jruby.sh +44 -0
  51. data/doc/scripts/install-linux.sh +64 -0
  52. data/doc/scripts/install-osx.sh +52 -0
  53. data/doc/site.haml +55 -0
  54. data/doc/site.toc.yaml +44 -0
  55. data/lib/buildr.rb +28 -45
  56. data/lib/buildr/core.rb +27 -0
  57. data/lib/buildr/core/application.rb +373 -0
  58. data/lib/buildr/core/application_cli.rb +134 -0
  59. data/lib/{core → buildr/core}/build.rb +91 -77
  60. data/lib/{core → buildr/core}/checks.rb +116 -95
  61. data/lib/buildr/core/common.rb +155 -0
  62. data/lib/buildr/core/compile.rb +594 -0
  63. data/lib/buildr/core/environment.rb +120 -0
  64. data/lib/buildr/core/filter.rb +258 -0
  65. data/lib/{core → buildr/core}/generate.rb +22 -5
  66. data/lib/buildr/core/help.rb +118 -0
  67. data/lib/buildr/core/progressbar.rb +156 -0
  68. data/lib/{core → buildr/core}/project.rb +468 -213
  69. data/lib/buildr/core/test.rb +690 -0
  70. data/lib/{core → buildr/core}/transports.rb +107 -127
  71. data/lib/buildr/core/util.rb +235 -0
  72. data/lib/buildr/ide.rb +19 -0
  73. data/lib/{java → buildr/ide}/eclipse.rb +86 -60
  74. data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
  75. data/lib/buildr/ide/idea.rb +194 -0
  76. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  77. data/lib/buildr/ide/idea7x.rb +210 -0
  78. data/lib/buildr/java.rb +26 -0
  79. data/lib/buildr/java/ant.rb +71 -0
  80. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  81. data/lib/buildr/java/commands.rb +210 -0
  82. data/lib/buildr/java/compilers.rb +432 -0
  83. data/lib/buildr/java/deprecated.rb +141 -0
  84. data/lib/buildr/java/groovyc.rb +137 -0
  85. data/lib/buildr/java/jruby.rb +99 -0
  86. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  89. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  91. data/lib/buildr/java/packaging.rb +706 -0
  92. data/lib/{java → buildr/java}/pom.rb +20 -4
  93. data/lib/buildr/java/rjb.rb +142 -0
  94. data/lib/buildr/java/test_frameworks.rb +290 -0
  95. data/lib/buildr/java/version_requirement.rb +172 -0
  96. data/lib/buildr/packaging.rb +21 -0
  97. data/lib/{java → buildr/packaging}/artifact.rb +170 -179
  98. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  99. data/lib/buildr/packaging/artifact_search.rb +140 -0
  100. data/lib/buildr/packaging/gems.rb +102 -0
  101. data/lib/buildr/packaging/package.rb +233 -0
  102. data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
  103. data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
  104. data/rakelib/apache.rake +126 -0
  105. data/rakelib/changelog.rake +56 -0
  106. data/rakelib/doc.rake +103 -0
  107. data/rakelib/package.rake +44 -0
  108. data/rakelib/release.rake +53 -0
  109. data/rakelib/rspec.rake +81 -0
  110. data/rakelib/rubyforge.rake +45 -0
  111. data/rakelib/scm.rake +49 -0
  112. data/rakelib/setup.rake +59 -0
  113. data/rakelib/stage.rake +45 -0
  114. data/spec/application_spec.rb +316 -0
  115. data/spec/archive_spec.rb +494 -0
  116. data/spec/artifact_namespace_spec.rb +635 -0
  117. data/spec/artifact_spec.rb +738 -0
  118. data/spec/build_spec.rb +193 -0
  119. data/spec/checks_spec.rb +537 -0
  120. data/spec/common_spec.rb +579 -0
  121. data/spec/compile_spec.rb +561 -0
  122. data/spec/groovy_compilers_spec.rb +239 -0
  123. data/spec/java_bdd_frameworks_spec.rb +238 -0
  124. data/spec/java_compilers_spec.rb +446 -0
  125. data/spec/java_packaging_spec.rb +1042 -0
  126. data/spec/java_test_frameworks_spec.rb +414 -0
  127. data/spec/packaging_helper.rb +63 -0
  128. data/spec/packaging_spec.rb +589 -0
  129. data/spec/project_spec.rb +739 -0
  130. data/spec/sandbox.rb +116 -0
  131. data/spec/scala_compilers_spec.rb +239 -0
  132. data/spec/spec.opts +6 -0
  133. data/spec/spec_helpers.rb +283 -0
  134. data/spec/test_spec.rb +871 -0
  135. data/spec/transport_spec.rb +300 -0
  136. data/spec/version_requirement_spec.rb +115 -0
  137. metadata +188 -77
  138. data/lib/buildr/cobertura.rb +0 -89
  139. data/lib/buildr/jdepend.rb +0 -40
  140. data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
  141. data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
  142. data/lib/buildr/jetty/JettyWrapper.class +0 -0
  143. data/lib/buildr/scala.rb +0 -368
  144. data/lib/core/application.rb +0 -188
  145. data/lib/core/common.rb +0 -562
  146. data/lib/core/help.rb +0 -72
  147. data/lib/core/rake_ext.rb +0 -81
  148. data/lib/java/ant.rb +0 -71
  149. data/lib/java/compile.rb +0 -589
  150. data/lib/java/idea.rb +0 -159
  151. data/lib/java/java.rb +0 -432
  152. data/lib/java/packaging.rb +0 -581
  153. data/lib/java/test.rb +0 -795
  154. data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,589 @@
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 File.join(File.dirname(__FILE__), 'packaging_helper')
19
+
20
+
21
+ describe Project, '#group' do
22
+ it 'should default to project name' do
23
+ desc 'My Project'
24
+ define('foo').group.should eql('foo')
25
+ end
26
+
27
+ it 'should be settable' do
28
+ define('foo', :group=>'bar').group.should eql('bar')
29
+ end
30
+
31
+ it 'should inherit from parent project' do
32
+ define('foo', :group=>'groupie') { define 'bar' }
33
+ project('foo:bar').group.should eql('groupie')
34
+ end
35
+ end
36
+
37
+
38
+ describe Project, '#version' do
39
+ it 'should default to nil' do
40
+ define('foo').version.should be_nil
41
+ end
42
+
43
+ it 'should be settable' do
44
+ define('foo', :version=>'2.1').version.should eql('2.1')
45
+ end
46
+
47
+ it 'should inherit from parent project' do
48
+ define('foo', :version=>'2.1') { define 'bar' }
49
+ project('foo:bar').version.should eql('2.1')
50
+ end
51
+
52
+ end
53
+
54
+
55
+ describe Project, '#id' do
56
+ it 'should be same as project name' do
57
+ define('foo').id.should eql('foo')
58
+ end
59
+
60
+ it 'should replace colons with dashes' do
61
+ define('foo', :version=>'2.1') { define 'bar' }
62
+ project('foo:bar').id.should eql('foo-bar')
63
+ end
64
+
65
+ it 'should not be settable' do
66
+ lambda { define 'foo', :id=>'bar' }.should raise_error(NoMethodError)
67
+ end
68
+ end
69
+
70
+
71
+ describe Project, '#package' do
72
+ it 'should default to id from project' do
73
+ define('foo', :version=>'1.0') do
74
+ package(:jar).id.should eql('foo')
75
+ end
76
+ end
77
+
78
+ it 'should default to composed it for nested projects' do
79
+ define('foo', :version=>'1.0') do
80
+ define 'bar' do
81
+ package(:jar).id.should eql('foo-bar')
82
+ end
83
+ end
84
+ end
85
+
86
+ it 'should take id from option if specified' do
87
+ define 'foo', :version=>'1.0' do
88
+ package(:jar, :id=>'bar').id.should eql('bar')
89
+ define 'bar' do
90
+ package(:jar, :id=>'baz').id.should eql('baz')
91
+ end
92
+ end
93
+ end
94
+
95
+ it 'should default to group from project' do
96
+ define 'foo', :version=>'1.0' do
97
+ package(:jar).group.should eql('foo')
98
+ define 'bar' do
99
+ package(:jar).group.should eql('foo')
100
+ end
101
+ end
102
+ end
103
+
104
+ it 'should take group from option if specified' do
105
+ define 'foo', :version=>'1.0' do
106
+ package(:jar, :group=>'foos').group.should eql('foos')
107
+ define 'bar' do
108
+ package(:jar, :group=>'bars').group.should eql('bars')
109
+ end
110
+ end
111
+ end
112
+
113
+ it 'should default to version from project' do
114
+ define 'foo', :version=>'1.0' do
115
+ package(:jar).version.should eql('1.0')
116
+ define 'bar' do
117
+ package(:jar).version.should eql('1.0')
118
+ end
119
+ end
120
+ end
121
+
122
+ it 'should take version from option if specified' do
123
+ define 'foo', :version=>'1.0' do
124
+ package(:jar, :version=>'1.1').version.should eql('1.1')
125
+ define 'bar' do
126
+ package(:jar, :version=>'1.2').version.should eql('1.2')
127
+ end
128
+ end
129
+ end
130
+
131
+ it 'should accept package type as first argument' do
132
+ define 'foo', :version=>'1.0' do
133
+ package(:war).type.should eql(:war)
134
+ define 'bar' do
135
+ package(:jar).type.should eql(:jar)
136
+ end
137
+ end
138
+ end
139
+
140
+ it 'should support optional type' do
141
+ define 'foo', :version=>'1.0' do
142
+ package.type.should eql(:zip)
143
+ package(:classifier=>'srcs').type.should eql(:zip)
144
+ end
145
+ define 'bar', :version=>'1.0' do
146
+ compile.using :javac
147
+ package(:classifier=>'srcs').type.should eql(:jar)
148
+ end
149
+ end
150
+
151
+ it 'should assume :zip package type unless specified' do
152
+ define 'foo', :version=>'1.0' do
153
+ package.type.should eql(:zip)
154
+ define 'bar' do
155
+ package.type.should eql(:zip)
156
+ end
157
+ end
158
+ end
159
+
160
+ it 'should infer packaging type from compiler' do
161
+ define 'foo', :version=>'1.0' do
162
+ compile.using :javac
163
+ package.type.should eql(:jar)
164
+ end
165
+ end
166
+
167
+ it 'should fail if packaging not supported' do
168
+ lambda { define('foo') { package(:weirdo) } }.should raise_error(RuntimeError, /Don't know how to create a package/)
169
+ end
170
+
171
+ it 'should default to no classifier' do
172
+ define 'foo', :version=>'1.0' do
173
+ package.classifier.should be_nil
174
+ define 'bar' do
175
+ package.classifier.should be_nil
176
+ end
177
+ end
178
+ end
179
+
180
+ it 'should accept classifier from option' do
181
+ define 'foo', :version=>'1.0' do
182
+ package(:classifier=>'srcs').classifier.should eql('srcs')
183
+ define 'bar' do
184
+ package(:classifier=>'docs').classifier.should eql('docs')
185
+ end
186
+ end
187
+ end
188
+
189
+ it 'should return a file task' do
190
+ define('foo', :version=>'1.0') { package(:jar) }
191
+ project('foo').package(:jar).should be_kind_of(Rake::FileTask)
192
+ end
193
+
194
+ it 'should return a task that acts as artifact' do
195
+ define('foo', :version=>'1.0') { package(:jar) }
196
+ project('foo').package(:jar).should respond_to(:to_spec)
197
+ project('foo').package(:jar).to_spec.should eql('foo:foo:jar:1.0')
198
+ end
199
+
200
+ it 'should create different tasks for each spec' do
201
+ define 'foo', :version=>'1.0' do
202
+ package(:jar)
203
+ package(:war)
204
+ package(:jar, :id=>'bar')
205
+ package(:jar, :classifier=>'srcs')
206
+ end
207
+ project('foo').packages.uniq.size.should be(4)
208
+ end
209
+
210
+ it 'should not create multiple packages for the same spec' do
211
+ define 'foo', :version=>'1.0' do
212
+ package(:war)
213
+ package(:war)
214
+ package(:jar, :id=>'bar')
215
+ package(:jar, :id=>'bar')
216
+ end
217
+ project('foo').packages.uniq.size.should be(2)
218
+ end
219
+
220
+ it 'should return the same task for subsequent calls' do
221
+ define 'foo', :version=>'1.0' do
222
+ package.should eql(package)
223
+ package(:jar, :classifier=>'resources').should be(package(:jar, :classifier=>'resources'))
224
+ end
225
+ end
226
+
227
+ it 'should return a packaging task even if file already exists' do
228
+ write 'target/foo-1.0.zip', ''
229
+ define 'foo', :version=>'1.0' do
230
+ package.should be_kind_of(ZipTask)
231
+ end
232
+ end
233
+
234
+ it 'should register task as artifact' do
235
+ define 'foo', :version=>'1.0' do
236
+ package(:jar, :id=>'bar')
237
+ package(:war)
238
+ end
239
+ project('foo').packages.should eql(artifacts('foo:bar:jar:1.0', 'foo:foo:war:1.0'))
240
+ end
241
+
242
+ it 'should create in target path' do
243
+ define 'foo', :version=>'1.0' do
244
+ package(:war).should point_to_path('target/foo-1.0.war')
245
+ package(:jar, :id=>'bar').should point_to_path('target/bar-1.0.jar')
246
+ package(:zip, :classifier=>'srcs').should point_to_path('target/foo-1.0-srcs.zip')
247
+ end
248
+ end
249
+
250
+ it 'should create prerequisite for package task' do
251
+ define 'foo', :version=>'1.0' do
252
+ package(:war)
253
+ package(:jar, :id=>'bar')
254
+ package(:jar, :classifier=>'srcs')
255
+ end
256
+ project('foo').task('package').prerequisites.should include(*project('foo').packages)
257
+ end
258
+
259
+ it 'should create task requiring a build' do
260
+ define 'foo', :version=>'1.0' do
261
+ package(:war).prerequisites.should include(build)
262
+ package(:jar, :id=>'bar').prerequisites.should include(build)
263
+ package(:jar, :classifier=>'srcs').prerequisites.should include(build)
264
+ end
265
+ end
266
+
267
+ it 'should create a POM artifact in local repository' do
268
+ define 'foo', :version=>'1.0' do
269
+ package.pom.should be(artifact('foo:foo:pom:1.0'))
270
+ repositories.locate('foo:foo:pom:1.0').should eql(package.pom.to_s)
271
+ end
272
+ end
273
+
274
+ it 'should create POM artifact ignoring classifier' do
275
+ define 'foo', :version=>'1.0' do
276
+ package(:jar, :classifier=>'srcs').pom.should be(artifact('foo:foo:pom:1.0'))
277
+ end
278
+ end
279
+
280
+ it 'should create POM artifact that creates its own POM' do
281
+ define('foo', :group=>'bar', :version=>'1.0') { package(:jar, :classifier=>'srcs') }
282
+ pom = project('foo').packages.first.pom
283
+ pom.invoke
284
+ read(pom.to_s).should eql(<<-POM
285
+ <?xml version="1.0" encoding="UTF-8"?>
286
+ <project>
287
+ <modelVersion>4.0.0</modelVersion>
288
+ <groupId>bar</groupId>
289
+ <artifactId>foo</artifactId>
290
+ <version>1.0</version>
291
+ </project>
292
+ POM
293
+ )
294
+ end
295
+
296
+ it 'should not require downloading artifact or POM' do
297
+ #task('artifacts').instance_eval { @actions.clear }
298
+ define('foo', :group=>'bar', :version=>'1.0') { package(:jar) }
299
+ lambda { task('artifacts').invoke }.should_not raise_error
300
+ end
301
+
302
+ end
303
+
304
+
305
+
306
+
307
+
308
+ describe Project, '#package file' do
309
+ it 'should be a file task' do
310
+ define 'foo' do
311
+ package(:zip, :file=>'foo.zip').should be_kind_of(Rake::FileTask)
312
+ end
313
+ end
314
+
315
+ it 'should not require id, project or version' do
316
+ define 'foo', :group=>nil do
317
+ lambda { package(:zip, :file=>'foo.zip') }.should_not raise_error
318
+ lambda { package(:zip, :file=>'bar.zip', :id=>'error') }.should raise_error
319
+ lambda { package(:zip, :file=>'bar.zip', :group=>'error') }.should raise_error
320
+ lambda { package(:zip, :file=>'bar.zip', :version=>'error') }.should raise_error
321
+ end
322
+ end
323
+
324
+ it 'should not provide project or version' do
325
+ define 'foo' do
326
+ package(:zip, :file=>'foo.zip').tap do |pkg|
327
+ pkg.should_not respond_to(:group)
328
+ pkg.should_not respond_to(:version)
329
+ end
330
+ end
331
+ end
332
+
333
+ it 'should provide packaging type' do
334
+ define 'foo', :version=>'1.0' do
335
+ zip = package(:zip, :file=>'foo.zip')
336
+ jar = package(:jar, :file=>'bar.jar')
337
+ zip.type.should eql(:zip)
338
+ jar.type.should eql(:jar)
339
+ end
340
+ end
341
+
342
+ it 'should assume packaging type from extension if unspecified' do
343
+ define 'foo', :version=>'1.0' do
344
+ package(:file=>'foo.zip').class.should be(Buildr::ZipTask)
345
+ define 'bar' do
346
+ package(:file=>'bar.jar').class.should be(Buildr::Packaging::Java::JarTask)
347
+ end
348
+ end
349
+ end
350
+
351
+ it 'should support different packaging types' do
352
+ define 'foo', :version=>'1.0' do
353
+ package(:jar, :file=>'foo.jar').class.should be(Buildr::Packaging::Java::JarTask)
354
+ end
355
+ define 'bar' do
356
+ package(:type=>:war, :file=>'bar.war').class.should be(Buildr::Packaging::Java::WarTask)
357
+ end
358
+ end
359
+
360
+ it 'should fail if packaging not supported' do
361
+ lambda { define('foo') { package(:weirdo, :file=>'foo.zip') } }.should raise_error(RuntimeError, /Don't know how to create a package/)
362
+ end
363
+
364
+ it 'should create different tasks for each file' do
365
+ define 'foo', :version=>'1.0' do
366
+ package(:zip, :file=>'foo.zip')
367
+ package(:jar, :file=>'foo.jar')
368
+ end
369
+ project('foo').packages.uniq.size.should be(2)
370
+ end
371
+
372
+ it 'should return the same task for subsequent calls' do
373
+ define 'foo', :version=>'1.0' do
374
+ package(:zip, :file=>'foo.zip').should eql(package(:file=>'foo.zip'))
375
+ end
376
+ end
377
+
378
+ it 'should point to specified file' do
379
+ define 'foo', :version=>'1.0' do
380
+ package(:zip, :file=>'foo.zip').should point_to_path('foo.zip')
381
+ package(:zip, :file=>'target/foo-1.0.zip').should point_to_path('target/foo-1.0.zip')
382
+ end
383
+ end
384
+
385
+ it 'should create prerequisite for package task' do
386
+ define 'foo', :version=>'1.0' do
387
+ package(:zip, :file=>'foo.zip')
388
+ end
389
+ project('foo').task('package').prerequisites.should include(*project('foo').packages)
390
+ end
391
+
392
+ it 'should create task requiring a build' do
393
+ define 'foo', :version=>'1.0' do
394
+ package(:zip, :file=>'foo.zip').prerequisites.should include(build)
395
+ end
396
+ end
397
+
398
+ it 'should create specified file during build' do
399
+ define 'foo', :version=>'1.0' do
400
+ package(:zip, :file=>'foo.zip')
401
+ end
402
+ lambda { project('foo').task('package').invoke }.should change { File.exist?('foo.zip') }.to(true)
403
+ end
404
+
405
+ it 'should do nothing for installation/upload' do
406
+ define 'foo', :version=>'1.0' do
407
+ package(:zip, :file=>'foo.zip')
408
+ end
409
+ lambda do
410
+ task('install').invoke
411
+ task('upload').invoke
412
+ task('uninstall').invoke
413
+ end.should_not raise_error
414
+ end
415
+
416
+ end
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+ describe Rake::Task, ' package' do
425
+ it 'should be local task' do
426
+ define 'foo', :version=>'1.0' do
427
+ package
428
+ define('bar') { package }
429
+ end
430
+ in_original_dir project('foo:bar').base_dir do
431
+ task('package').invoke
432
+ project('foo').package.should_not exist
433
+ project('foo:bar').package.should exist
434
+ end
435
+ end
436
+
437
+ it 'should be recursive task' do
438
+ define 'foo', :version=>'1.0' do
439
+ package
440
+ define('bar') { package }
441
+ end
442
+ task('package').invoke
443
+ project('foo').package.should exist
444
+ project('foo:bar').package.should exist
445
+ end
446
+
447
+ it 'should create package in target directory' do
448
+ define 'foo', :version=>'1.0' do
449
+ package
450
+ define('bar') { package }
451
+ end
452
+ task('package').invoke
453
+ FileList['**/target/*.zip'].map.sort.should == ['bar/target/foo-bar-1.0.zip', 'target/foo-1.0.zip']
454
+ end
455
+ end
456
+
457
+
458
+ describe Rake::Task, ' install' do
459
+ it 'should be local task' do
460
+ define 'foo', :version=>'1.0' do
461
+ package
462
+ define('bar') { package }
463
+ end
464
+ in_original_dir project('foo:bar').base_dir do
465
+ task('install').invoke
466
+ artifacts('foo:foo:zip:1.0', 'foo:foo:pom:1.0').each { |t| t.should_not exist }
467
+ artifacts('foo:foo-bar:zip:1.0', 'foo:foo-bar:pom:1.0').each { |t| t.should exist }
468
+ end
469
+ end
470
+
471
+ it 'should be recursive task' do
472
+ define 'foo', :version=>'1.0' do
473
+ package
474
+ define('bar') { package }
475
+ end
476
+ task('install').invoke
477
+ artifacts('foo:foo:zip:1.0', 'foo:foo:pom:1.0', 'foo:foo-bar:zip:1.0', 'foo:foo-bar:pom:1.0').each { |t| t.should exist }
478
+ end
479
+
480
+ it 'should create package in local repository' do
481
+ define 'foo', :version=>'1.0' do
482
+ package
483
+ define('bar') { package }
484
+ end
485
+ task('install').invoke
486
+ FileList[repositories.local + '/**/*'].reject { |f| File.directory?(f) }.sort.should == [
487
+ File.expand_path('foo/foo/1.0/foo-1.0.zip', repositories.local),
488
+ File.expand_path('foo/foo/1.0/foo-1.0.pom', repositories.local),
489
+ File.expand_path('foo/foo-bar/1.0/foo-bar-1.0.zip', repositories.local),
490
+ File.expand_path('foo/foo-bar/1.0/foo-bar-1.0.pom', repositories.local)].sort
491
+ end
492
+ end
493
+
494
+
495
+ describe Rake::Task, ' uninstall' do
496
+ it 'should be local task' do
497
+ define 'foo', :version=>'1.0' do
498
+ package
499
+ define('bar') { package }
500
+ end
501
+ task('install').invoke
502
+ in_original_dir project('foo:bar').base_dir do
503
+ task('uninstall').invoke
504
+ FileList[repositories.local + '/**/*'].reject { |f| File.directory?(f) }.sort.should == [
505
+ File.expand_path('foo/foo/1.0/foo-1.0.zip', repositories.local),
506
+ File.expand_path('foo/foo/1.0/foo-1.0.pom', repositories.local)].sort
507
+ end
508
+ end
509
+
510
+ it 'should be recursive task' do
511
+ define 'foo', :version=>'1.0' do
512
+ package
513
+ define('bar') { package }
514
+ end
515
+ task('install').invoke
516
+ task('uninstall').invoke
517
+ FileList[repositories.local + '/**/*'].reject { |f| File.directory?(f) }.sort.should be_empty
518
+ end
519
+ end
520
+
521
+
522
+ describe Rake::Task, ' upload' do
523
+ before do
524
+ repositories.release_to = "file://#{File.expand_path('remote')}"
525
+ end
526
+
527
+ it 'should be local task' do
528
+ define 'foo', :version=>'1.0' do
529
+ package
530
+ define('bar') { package }
531
+ end
532
+ in_original_dir project('foo:bar').base_dir do
533
+ lambda { task('upload').invoke }.should run_task('foo:bar:upload').but_not('foo:upload')
534
+ end
535
+ end
536
+
537
+ it 'should be recursive task' do
538
+ define 'foo', :version=>'1.0' do
539
+ package
540
+ define('bar') { package }
541
+ end
542
+ lambda { task('upload').invoke }.should run_tasks('foo:upload', 'foo:bar:upload')
543
+ end
544
+
545
+ it 'should upload artifact and POM' do
546
+ define('foo', :version=>'1.0') { package :jar }
547
+ task('upload').invoke
548
+ { 'remote/foo/foo/1.0/foo-1.0.jar'=>project('foo').package(:jar),
549
+ 'remote/foo/foo/1.0/foo-1.0.pom'=>project('foo').package(:jar).pom }.each do |upload, package|
550
+ read(upload).should eql(read(package))
551
+ end
552
+ end
553
+
554
+ it 'should upload signatures for artifact and POM' do
555
+ define('foo', :version=>'1.0') { package :jar }
556
+ task('upload').invoke
557
+ { 'remote/foo/foo/1.0/foo-1.0.jar'=>project('foo').package(:jar),
558
+ 'remote/foo/foo/1.0/foo-1.0.pom'=>project('foo').package(:jar).pom }.each do |upload, package|
559
+ read("#{upload}.md5").split.first.should eql(Digest::MD5.hexdigest(read(package)))
560
+ read("#{upload}.sha1").split.first.should eql(Digest::SHA1.hexdigest(read(package)))
561
+ end
562
+ end
563
+ end
564
+
565
+
566
+ describe Packaging, 'zip' do
567
+ it_should_behave_like 'packaging'
568
+ before { @packaging = :zip }
569
+
570
+ it 'should not include META-INF directory' do
571
+ define('foo', :version=>'1.0') { package(:zip) }
572
+ project('foo').package(:zip).invoke
573
+ Zip::ZipFile.open(project('foo').package(:zip).to_s) do |zip|
574
+ zip.entries.map(&:to_s).should_not include('META-INF/')
575
+ end
576
+ end
577
+ end
578
+
579
+
580
+ describe Packaging, ' tar' do
581
+ before { @packaging = :tar }
582
+ it_should_behave_like 'packaging'
583
+ end
584
+
585
+
586
+ describe Packaging, ' tgz' do
587
+ before { @packaging = :tgz }
588
+ it_should_behave_like 'packaging'
589
+ end