assaf-buildr 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/CHANGELOG +887 -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 +62 -0
  7. data/_buildr +38 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/cobertura.rb +236 -0
  10. data/addon/buildr/emma.rb +238 -0
  11. data/addon/buildr/hibernate.rb +142 -0
  12. data/addon/buildr/javacc.rb +85 -0
  13. data/addon/buildr/jdepend.rb +60 -0
  14. data/addon/buildr/jetty.rb +248 -0
  15. data/addon/buildr/jibx.rb +86 -0
  16. data/addon/buildr/nailgun.rb +817 -0
  17. data/addon/buildr/openjpa.rb +90 -0
  18. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  19. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  20. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  21. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  22. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  23. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  25. data/addon/buildr/xmlbeans.rb +93 -0
  26. data/bin/buildr +28 -0
  27. data/buildr.buildfile +53 -0
  28. data/buildr.gemspec +58 -0
  29. data/doc/css/default.css +228 -0
  30. data/doc/css/print.css +100 -0
  31. data/doc/css/syntax.css +52 -0
  32. data/doc/images/apache-incubator-logo.png +0 -0
  33. data/doc/images/buildr-hires.png +0 -0
  34. data/doc/images/buildr.png +0 -0
  35. data/doc/images/favicon.png +0 -0
  36. data/doc/images/growl-icon.tiff +0 -0
  37. data/doc/images/note.png +0 -0
  38. data/doc/images/project-structure.png +0 -0
  39. data/doc/images/tip.png +0 -0
  40. data/doc/images/zbuildr.tif +0 -0
  41. data/doc/pages/artifacts.textile +207 -0
  42. data/doc/pages/building.textile +240 -0
  43. data/doc/pages/contributing.textile +208 -0
  44. data/doc/pages/download.textile +62 -0
  45. data/doc/pages/extending.textile +175 -0
  46. data/doc/pages/getting_started.textile +273 -0
  47. data/doc/pages/index.textile +42 -0
  48. data/doc/pages/languages.textile +407 -0
  49. data/doc/pages/mailing_lists.textile +17 -0
  50. data/doc/pages/more_stuff.textile +286 -0
  51. data/doc/pages/packaging.textile +427 -0
  52. data/doc/pages/projects.textile +274 -0
  53. data/doc/pages/recipes.textile +103 -0
  54. data/doc/pages/settings_profiles.textile +274 -0
  55. data/doc/pages/testing.textile +212 -0
  56. data/doc/pages/troubleshooting.textile +103 -0
  57. data/doc/pages/whats_new.textile +323 -0
  58. data/doc/print.haml +51 -0
  59. data/doc/print.toc.yaml +29 -0
  60. data/doc/scripts/buildr-git.rb +412 -0
  61. data/doc/scripts/install-jruby.sh +44 -0
  62. data/doc/scripts/install-linux.sh +64 -0
  63. data/doc/scripts/install-osx.sh +52 -0
  64. data/doc/site.haml +56 -0
  65. data/doc/site.toc.yaml +47 -0
  66. data/etc/KEYS +151 -0
  67. data/etc/git-svn-authors +16 -0
  68. data/lib/buildr.rb +35 -0
  69. data/lib/buildr/core.rb +27 -0
  70. data/lib/buildr/core/application.rb +489 -0
  71. data/lib/buildr/core/application_cli.rb +139 -0
  72. data/lib/buildr/core/build.rb +311 -0
  73. data/lib/buildr/core/checks.rb +382 -0
  74. data/lib/buildr/core/common.rb +154 -0
  75. data/lib/buildr/core/compile.rb +596 -0
  76. data/lib/buildr/core/environment.rb +120 -0
  77. data/lib/buildr/core/filter.rb +362 -0
  78. data/lib/buildr/core/generate.rb +195 -0
  79. data/lib/buildr/core/help.rb +118 -0
  80. data/lib/buildr/core/progressbar.rb +156 -0
  81. data/lib/buildr/core/project.rb +892 -0
  82. data/lib/buildr/core/test.rb +715 -0
  83. data/lib/buildr/core/transports.rb +558 -0
  84. data/lib/buildr/core/util.rb +289 -0
  85. data/lib/buildr/groovy.rb +18 -0
  86. data/lib/buildr/groovy/bdd.rb +105 -0
  87. data/lib/buildr/groovy/compiler.rb +138 -0
  88. data/lib/buildr/ide.rb +19 -0
  89. data/lib/buildr/ide/eclipse.rb +212 -0
  90. data/lib/buildr/ide/idea.ipr.template +300 -0
  91. data/lib/buildr/ide/idea.rb +189 -0
  92. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  93. data/lib/buildr/ide/idea7x.rb +210 -0
  94. data/lib/buildr/java.rb +23 -0
  95. data/lib/buildr/java/ant.rb +92 -0
  96. data/lib/buildr/java/bdd.rb +449 -0
  97. data/lib/buildr/java/commands.rb +211 -0
  98. data/lib/buildr/java/compiler.rb +348 -0
  99. data/lib/buildr/java/deprecated.rb +141 -0
  100. data/lib/buildr/java/jruby.rb +117 -0
  101. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  102. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  103. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +119 -0
  104. data/lib/buildr/java/packaging.rb +713 -0
  105. data/lib/buildr/java/pom.rb +178 -0
  106. data/lib/buildr/java/rjb.rb +155 -0
  107. data/lib/buildr/java/test_result.rb +308 -0
  108. data/lib/buildr/java/tests.rb +324 -0
  109. data/lib/buildr/java/version_requirement.rb +172 -0
  110. data/lib/buildr/packaging.rb +21 -0
  111. data/lib/buildr/packaging/artifact.rb +730 -0
  112. data/lib/buildr/packaging/artifact_namespace.rb +972 -0
  113. data/lib/buildr/packaging/artifact_search.rb +140 -0
  114. data/lib/buildr/packaging/gems.rb +102 -0
  115. data/lib/buildr/packaging/package.rb +233 -0
  116. data/lib/buildr/packaging/tar.rb +104 -0
  117. data/lib/buildr/packaging/zip.rb +722 -0
  118. data/lib/buildr/resources/buildr.icns +0 -0
  119. data/lib/buildr/scala.rb +19 -0
  120. data/lib/buildr/scala/compiler.rb +109 -0
  121. data/lib/buildr/scala/tests.rb +203 -0
  122. data/rakelib/apache.rake +191 -0
  123. data/rakelib/changelog.rake +57 -0
  124. data/rakelib/doc.rake +103 -0
  125. data/rakelib/package.rake +73 -0
  126. data/rakelib/release.rake +65 -0
  127. data/rakelib/rspec.rake +83 -0
  128. data/rakelib/rubyforge.rake +53 -0
  129. data/rakelib/scm.rake +49 -0
  130. data/rakelib/setup.rake +86 -0
  131. data/rakelib/stage.rake +48 -0
  132. data/spec/addon/cobertura_spec.rb +77 -0
  133. data/spec/addon/emma_spec.rb +120 -0
  134. data/spec/addon/test_coverage_spec.rb +255 -0
  135. data/spec/core/application_spec.rb +412 -0
  136. data/spec/core/artifact_namespace_spec.rb +646 -0
  137. data/spec/core/build_spec.rb +415 -0
  138. data/spec/core/checks_spec.rb +537 -0
  139. data/spec/core/common_spec.rb +664 -0
  140. data/spec/core/compile_spec.rb +566 -0
  141. data/spec/core/generate_spec.rb +33 -0
  142. data/spec/core/project_spec.rb +754 -0
  143. data/spec/core/test_spec.rb +1091 -0
  144. data/spec/core/transport_spec.rb +500 -0
  145. data/spec/groovy/bdd_spec.rb +80 -0
  146. data/spec/groovy/compiler_spec.rb +239 -0
  147. data/spec/ide/eclipse_spec.rb +243 -0
  148. data/spec/java/ant.rb +28 -0
  149. data/spec/java/bdd_spec.rb +358 -0
  150. data/spec/java/compiler_spec.rb +446 -0
  151. data/spec/java/java_spec.rb +88 -0
  152. data/spec/java/packaging_spec.rb +1103 -0
  153. data/spec/java/tests_spec.rb +466 -0
  154. data/spec/packaging/archive_spec.rb +503 -0
  155. data/spec/packaging/artifact_spec.rb +754 -0
  156. data/spec/packaging/packaging_helper.rb +63 -0
  157. data/spec/packaging/packaging_spec.rb +589 -0
  158. data/spec/sandbox.rb +137 -0
  159. data/spec/scala/compiler_spec.rb +228 -0
  160. data/spec/scala/tests_spec.rb +215 -0
  161. data/spec/spec_helpers.rb +304 -0
  162. data/spec/version_requirement_spec.rb +123 -0
  163. metadata +369 -0
@@ -0,0 +1,63 @@
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
+ shared_examples_for 'packaging' do
18
+ it 'should create artifact of proper type' do
19
+ packaging = @packaging
20
+ package_type = @package_type || @packaging
21
+ define 'foo', :version=>'1.0' do
22
+ package(packaging).type.should eql(package_type) rescue exit!
23
+ end
24
+ end
25
+
26
+ it 'should create file with proper extension' do
27
+ packaging = @packaging
28
+ package_type = @package_type || @packaging
29
+ define 'foo', :version=>'1.0' do
30
+ package(packaging).to_s.should match(/.#{package_type}$/)
31
+ end
32
+ end
33
+
34
+ it 'should always return same task for the same package' do
35
+ packaging = @packaging
36
+ define 'foo', :version=>'1.0' do
37
+ package(packaging)
38
+ package(packaging, :id=>'other')
39
+ end
40
+ project('foo').packages.uniq.size.should eql(2)
41
+ end
42
+
43
+ it 'should complain if option not known' do
44
+ packaging = @packaging
45
+ define 'foo', :version=>'1.0' do
46
+ lambda { package(packaging, :unknown_option=>true) }.should raise_error(ArgumentError, /no such option/)
47
+ end
48
+ end
49
+
50
+ it 'should respond to with() and return self' do
51
+ packaging = @packaging
52
+ define 'foo', :version=>'1.0' do
53
+ package(packaging).with({}).should be(package(packaging))
54
+ end
55
+ end
56
+
57
+ it 'should respond to with() and complain if unknown option' do
58
+ packaging = @packaging
59
+ define 'foo', :version=>'1.0' do
60
+ lambda { package(packaging).with(:unknown_option=>true) }.should raise_error(ArgumentError, /does not support the option/)
61
+ end
62
+ end
63
+ end
@@ -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