mguymon-buildr 1.4.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (220) hide show
  1. data/CHANGELOG +1291 -0
  2. data/LICENSE +176 -0
  3. data/NOTICE +26 -0
  4. data/README.rdoc +134 -0
  5. data/Rakefile +44 -0
  6. data/_buildr +35 -0
  7. data/_jbuildr +35 -0
  8. data/addon/buildr/antlr.rb +65 -0
  9. data/addon/buildr/bnd.rb +147 -0
  10. data/addon/buildr/cobertura.rb +22 -0
  11. data/addon/buildr/drb.rb +281 -0
  12. data/addon/buildr/emma.rb +22 -0
  13. data/addon/buildr/hibernate.rb +149 -0
  14. data/addon/buildr/javacc.rb +85 -0
  15. data/addon/buildr/jaxb_xjc.rb +72 -0
  16. data/addon/buildr/jdepend.rb +60 -0
  17. data/addon/buildr/jetty.rb +248 -0
  18. data/addon/buildr/jibx.rb +86 -0
  19. data/addon/buildr/nailgun.rb +221 -0
  20. data/addon/buildr/openjpa.rb +88 -0
  21. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  22. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  23. data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  24. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  25. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  26. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  27. data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  28. data/addon/buildr/protobuf.rb +88 -0
  29. data/addon/buildr/xmlbeans.rb +93 -0
  30. data/bin/buildr +19 -0
  31. data/buildr.buildfile +58 -0
  32. data/buildr.gemspec +78 -0
  33. data/doc/_config.yml +1 -0
  34. data/doc/_layouts/default.html +90 -0
  35. data/doc/_layouts/preface.html +22 -0
  36. data/doc/artifacts.textile +217 -0
  37. data/doc/building.textile +276 -0
  38. data/doc/contributing.textile +268 -0
  39. data/doc/css/default.css +236 -0
  40. data/doc/css/print.css +101 -0
  41. data/doc/css/syntax.css +23 -0
  42. data/doc/download.textile +151 -0
  43. data/doc/extending.textile +212 -0
  44. data/doc/images/1442160941-frontcover.jpg +0 -0
  45. data/doc/images/asf-logo.gif +0 -0
  46. data/doc/images/asf-logo.png +0 -0
  47. data/doc/images/buildr-hires.png +0 -0
  48. data/doc/images/buildr.png +0 -0
  49. data/doc/images/favicon.png +0 -0
  50. data/doc/images/growl-icon.tiff +0 -0
  51. data/doc/images/note.png +0 -0
  52. data/doc/images/project-structure.png +0 -0
  53. data/doc/images/tip.png +0 -0
  54. data/doc/images/zbuildr.png +0 -0
  55. data/doc/images/zbuildr.tif +0 -0
  56. data/doc/index.textile +109 -0
  57. data/doc/installing.textile +284 -0
  58. data/doc/languages.textile +599 -0
  59. data/doc/mailing_lists.textile +29 -0
  60. data/doc/more_stuff.textile +845 -0
  61. data/doc/packaging.textile +618 -0
  62. data/doc/preface.textile +54 -0
  63. data/doc/projects.textile +276 -0
  64. data/doc/quick_start.textile +210 -0
  65. data/doc/releasing.textile +117 -0
  66. data/doc/scripts/buildr-git.rb +512 -0
  67. data/doc/scripts/gitflow.rb +296 -0
  68. data/doc/scripts/install-jruby.sh +44 -0
  69. data/doc/scripts/install-linux.sh +73 -0
  70. data/doc/scripts/install-osx.sh +52 -0
  71. data/doc/settings_profiles.textile +287 -0
  72. data/doc/testing.textile +247 -0
  73. data/etc/KEYS +189 -0
  74. data/lib/buildr.rb +44 -0
  75. data/lib/buildr/clojure.rb +34 -0
  76. data/lib/buildr/clojure/shell.rb +52 -0
  77. data/lib/buildr/core.rb +34 -0
  78. data/lib/buildr/core/application.rb +700 -0
  79. data/lib/buildr/core/build.rb +516 -0
  80. data/lib/buildr/core/cc.rb +166 -0
  81. data/lib/buildr/core/checks.rb +253 -0
  82. data/lib/buildr/core/common.rb +151 -0
  83. data/lib/buildr/core/compile.rb +622 -0
  84. data/lib/buildr/core/doc.rb +276 -0
  85. data/lib/buildr/core/environment.rb +129 -0
  86. data/lib/buildr/core/filter.rb +404 -0
  87. data/lib/buildr/core/generate.rb +197 -0
  88. data/lib/buildr/core/help.rb +119 -0
  89. data/lib/buildr/core/jrebel.rb +42 -0
  90. data/lib/buildr/core/linux.rb +30 -0
  91. data/lib/buildr/core/osx.rb +46 -0
  92. data/lib/buildr/core/progressbar.rb +161 -0
  93. data/lib/buildr/core/project.rb +975 -0
  94. data/lib/buildr/core/run.rb +43 -0
  95. data/lib/buildr/core/shell.rb +137 -0
  96. data/lib/buildr/core/test.rb +843 -0
  97. data/lib/buildr/core/transports.rb +575 -0
  98. data/lib/buildr/core/util.rb +537 -0
  99. data/lib/buildr/groovy.rb +20 -0
  100. data/lib/buildr/groovy/bdd.rb +106 -0
  101. data/lib/buildr/groovy/compiler.rb +153 -0
  102. data/lib/buildr/groovy/doc.rb +76 -0
  103. data/lib/buildr/groovy/shell.rb +57 -0
  104. data/lib/buildr/ide.rb +19 -0
  105. data/lib/buildr/ide/eclipse.rb +427 -0
  106. data/lib/buildr/ide/eclipse/java.rb +53 -0
  107. data/lib/buildr/ide/eclipse/plugin.rb +71 -0
  108. data/lib/buildr/ide/eclipse/scala.rb +68 -0
  109. data/lib/buildr/ide/idea.rb +576 -0
  110. data/lib/buildr/java.rb +25 -0
  111. data/lib/buildr/java/ant.rb +94 -0
  112. data/lib/buildr/java/bdd.rb +460 -0
  113. data/lib/buildr/java/cobertura.rb +297 -0
  114. data/lib/buildr/java/commands.rb +223 -0
  115. data/lib/buildr/java/compiler.rb +135 -0
  116. data/lib/buildr/java/deprecated.rb +141 -0
  117. data/lib/buildr/java/doc.rb +86 -0
  118. data/lib/buildr/java/ecj.rb +69 -0
  119. data/lib/buildr/java/emma.rb +244 -0
  120. data/lib/buildr/java/external.rb +73 -0
  121. data/lib/buildr/java/jruby.rb +122 -0
  122. data/lib/buildr/java/jtestr_result.rb +295 -0
  123. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  124. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  125. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  126. data/lib/buildr/java/packaging.rb +734 -0
  127. data/lib/buildr/java/pom.rb +178 -0
  128. data/lib/buildr/java/rjb.rb +154 -0
  129. data/lib/buildr/java/test_result.rb +101 -0
  130. data/lib/buildr/java/tests.rb +362 -0
  131. data/lib/buildr/java/version_requirement.rb +172 -0
  132. data/lib/buildr/packaging.rb +25 -0
  133. data/lib/buildr/packaging/archive.rb +535 -0
  134. data/lib/buildr/packaging/artifact.rb +904 -0
  135. data/lib/buildr/packaging/artifact_namespace.rb +984 -0
  136. data/lib/buildr/packaging/artifact_search.rb +140 -0
  137. data/lib/buildr/packaging/gems.rb +105 -0
  138. data/lib/buildr/packaging/package.rb +249 -0
  139. data/lib/buildr/packaging/repository_array.rb +108 -0
  140. data/lib/buildr/packaging/tar.rb +189 -0
  141. data/lib/buildr/packaging/version_requirement.rb +192 -0
  142. data/lib/buildr/packaging/zip.rb +178 -0
  143. data/lib/buildr/packaging/ziptask.rb +356 -0
  144. data/lib/buildr/resources/buildr.icns +0 -0
  145. data/lib/buildr/resources/completed.png +0 -0
  146. data/lib/buildr/resources/failed.png +0 -0
  147. data/lib/buildr/resources/icons-license.txt +17 -0
  148. data/lib/buildr/run.rb +195 -0
  149. data/lib/buildr/scala.rb +26 -0
  150. data/lib/buildr/scala/bdd.rb +118 -0
  151. data/lib/buildr/scala/compiler.rb +242 -0
  152. data/lib/buildr/scala/doc.rb +142 -0
  153. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  154. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  155. data/lib/buildr/scala/shell.rb +52 -0
  156. data/lib/buildr/scala/tests.rb +171 -0
  157. data/lib/buildr/shell.rb +185 -0
  158. data/lib/buildr/version.rb +18 -0
  159. data/rakelib/all-in-one.rake +113 -0
  160. data/rakelib/checks.rake +57 -0
  161. data/rakelib/doc.rake +137 -0
  162. data/rakelib/metrics.rake +39 -0
  163. data/rakelib/package.rake +73 -0
  164. data/rakelib/release.rake +160 -0
  165. data/rakelib/rspec.rake +91 -0
  166. data/rakelib/setup.rake +66 -0
  167. data/rakelib/stage.rake +220 -0
  168. data/spec/addon/bnd_spec.rb +330 -0
  169. data/spec/addon/drb_spec.rb +328 -0
  170. data/spec/addon/jaxb_xjc_spec.rb +125 -0
  171. data/spec/core/application_spec.rb +631 -0
  172. data/spec/core/build_spec.rb +837 -0
  173. data/spec/core/cc_spec.rb +224 -0
  174. data/spec/core/checks_spec.rb +519 -0
  175. data/spec/core/common_spec.rb +725 -0
  176. data/spec/core/compile_spec.rb +658 -0
  177. data/spec/core/doc_spec.rb +195 -0
  178. data/spec/core/extension_spec.rb +201 -0
  179. data/spec/core/generate_spec.rb +33 -0
  180. data/spec/core/project_spec.rb +772 -0
  181. data/spec/core/run_spec.rb +93 -0
  182. data/spec/core/shell_spec.rb +146 -0
  183. data/spec/core/test_spec.rb +1320 -0
  184. data/spec/core/transport_spec.rb +544 -0
  185. data/spec/core/util_spec.rb +141 -0
  186. data/spec/groovy/bdd_spec.rb +80 -0
  187. data/spec/groovy/compiler_spec.rb +251 -0
  188. data/spec/groovy/doc_spec.rb +65 -0
  189. data/spec/ide/eclipse_spec.rb +739 -0
  190. data/spec/ide/idea_spec.rb +1145 -0
  191. data/spec/java/ant_spec.rb +37 -0
  192. data/spec/java/bdd_spec.rb +374 -0
  193. data/spec/java/cobertura_spec.rb +112 -0
  194. data/spec/java/commands_spec.rb +93 -0
  195. data/spec/java/compiler_spec.rb +252 -0
  196. data/spec/java/doc_spec.rb +56 -0
  197. data/spec/java/ecj_spec.rb +115 -0
  198. data/spec/java/emma_spec.rb +121 -0
  199. data/spec/java/external_spec.rb +56 -0
  200. data/spec/java/java_spec.rb +132 -0
  201. data/spec/java/packaging_spec.rb +1266 -0
  202. data/spec/java/run_spec.rb +78 -0
  203. data/spec/java/test_coverage_helper.rb +257 -0
  204. data/spec/java/tests_spec.rb +497 -0
  205. data/spec/packaging/archive_spec.rb +775 -0
  206. data/spec/packaging/artifact_namespace_spec.rb +743 -0
  207. data/spec/packaging/artifact_spec.rb +1074 -0
  208. data/spec/packaging/packaging_helper.rb +63 -0
  209. data/spec/packaging/packaging_spec.rb +719 -0
  210. data/spec/packaging/repository_array_spec.rb +109 -0
  211. data/spec/sandbox.rb +165 -0
  212. data/spec/scala/bdd_spec.rb +124 -0
  213. data/spec/scala/compiler_spec.rb +289 -0
  214. data/spec/scala/doc_spec.rb +88 -0
  215. data/spec/scala/scala.rb +38 -0
  216. data/spec/scala/tests_spec.rb +283 -0
  217. data/spec/spec_helpers.rb +369 -0
  218. data/spec/version_requirement_spec.rb +143 -0
  219. data/spec/xpath_matchers.rb +121 -0
  220. metadata +600 -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,719 @@
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.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+ require File.expand_path(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 id 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 call package_as_foo when using package(:foo)' do
172
+ class Buildr::Project
173
+ def package_as_foo(file_name)
174
+ file(file_name) do |t|
175
+ mkdir_p File.dirname(t.to_s)
176
+ File.open(t.to_s, 'w') {|f| f.write('foo') }
177
+ end
178
+ end
179
+ end
180
+ define('foo', :version => '1.0') do |project|
181
+ package(:foo).invoke
182
+ package(:foo).should exist
183
+ package(:foo).should contain('foo')
184
+ end
185
+ end
186
+
187
+ it 'should allow to respec package(:sources) using package_as_sources_spec()' do
188
+ class Buildr::Project
189
+ def package_as_sources_spec(spec)
190
+ spec.merge({ :type=>:jar, :classifier=>'sources' })
191
+ end
192
+ end
193
+ define('foo', :version => '1.0') do
194
+ package(:sources).type.should eql(:jar)
195
+ package(:sources).classifier.should eql('sources')
196
+ end
197
+ end
198
+
199
+ it 'should produce different packages for different specs' do
200
+ class Buildr::Project
201
+ def package_as_foo(file_name)
202
+ file(file_name)
203
+ end
204
+
205
+ def package_as_foo_spec(spec)
206
+ spec.merge(:type => :zip)
207
+ end
208
+
209
+ def package_as_bar(file_name)
210
+ file(file_name)
211
+ end
212
+
213
+ def package_as_bar_spec(spec)
214
+ spec.merge(:type => :zip, :classifier => "foobar")
215
+ end
216
+
217
+ end
218
+ define('foo', :version => '1.0') do
219
+ package(:foo).type.should eql(:zip)
220
+ package(:foo).classifier.should be_nil
221
+ package(:bar).type.should eql(:zip)
222
+ package(:bar).classifier.should eql('foobar')
223
+ package(:foo).equal?(package(:bar)).should be_false
224
+ end
225
+ end
226
+
227
+ it 'should default to no classifier' do
228
+ define 'foo', :version=>'1.0' do
229
+ package.classifier.should be_nil
230
+ define 'bar' do
231
+ package.classifier.should be_nil
232
+ end
233
+ end
234
+ end
235
+
236
+ it 'should accept classifier from option' do
237
+ define 'foo', :version=>'1.0' do
238
+ package(:classifier=>'srcs').classifier.should eql('srcs')
239
+ define 'bar' do
240
+ package(:classifier=>'docs').classifier.should eql('docs')
241
+ end
242
+ end
243
+ end
244
+
245
+ it 'should return a file task' do
246
+ define('foo', :version=>'1.0') { package(:jar) }
247
+ project('foo').package(:jar).should be_kind_of(Rake::FileTask)
248
+ end
249
+
250
+ it 'should return a task that acts as artifact' do
251
+ define('foo', :version=>'1.0') { package(:jar) }
252
+ project('foo').package(:jar).should respond_to(:to_spec)
253
+ project('foo').package(:jar).to_spec.should eql('foo:foo:jar:1.0')
254
+ end
255
+
256
+ it 'should create different tasks for each spec' do
257
+ define 'foo', :version=>'1.0' do
258
+ package(:jar)
259
+ package(:war)
260
+ package(:jar, :id=>'bar')
261
+ package(:jar, :classifier=>'srcs')
262
+ package(:jar, :classifier=>'doc')
263
+ end
264
+ project('foo').packages.uniq.size.should be(5)
265
+ end
266
+
267
+ it 'should create different tasks for package with different ids' do
268
+ define 'foo', :version=>'1.0' do
269
+ package(:jar, :id=>'bar')
270
+ package(:jar)
271
+ end
272
+ project('foo').packages.uniq.size.should be(2)
273
+ end
274
+
275
+ it 'should create different tasks for package with classifier' do
276
+ define 'foo', :version=>'1.0' do
277
+ package(:jar)
278
+ package(:jar, :classifier=>'foo')
279
+ end
280
+ project('foo').packages.uniq.size.should be(2)
281
+ end
282
+
283
+ it 'should not create multiple packages for the same spec' do
284
+ define 'foo', :version=>'1.0' do
285
+ package(:war)
286
+ package(:war)
287
+ package(:jar, :id=>'bar')
288
+ package(:jar, :id=>'bar')
289
+ package(:jar, :id=>'baz')
290
+ end
291
+ project('foo').packages.uniq.size.should be(3)
292
+ end
293
+
294
+ it 'should create different tasks for specs with matching type' do
295
+ define 'foo', :version=>'1.0' do
296
+ javadoc("foo").into( "foo" )
297
+ package(:javadoc)
298
+ package(:zip)
299
+ end
300
+ project('foo').packages.uniq.size.should be(2)
301
+ end
302
+
303
+ it 'should return the same task for subsequent calls' do
304
+ define 'foo', :version=>'1.0' do
305
+ package.should eql(package)
306
+ package(:jar, :classifier=>'resources').should be(package(:jar, :classifier=>'resources'))
307
+ end
308
+ end
309
+
310
+ it 'should return a packaging task even if file already exists' do
311
+ write 'target/foo-1.0.zip', ''
312
+ define 'foo', :version=>'1.0' do
313
+ package.should be_kind_of(ZipTask)
314
+ end
315
+ end
316
+
317
+ it 'should register task as artifact' do
318
+ define 'foo', :version=>'1.0' do
319
+ package(:jar, :id=>'bar')
320
+ package(:war)
321
+ end
322
+ project('foo').packages.should eql(artifacts('foo:bar:jar:1.0', 'foo:foo:war:1.0'))
323
+ end
324
+
325
+ it 'should create in target path' do
326
+ define 'foo', :version=>'1.0' do
327
+ package(:war).should point_to_path('target/foo-1.0.war')
328
+ package(:jar, :id=>'bar').should point_to_path('target/bar-1.0.jar')
329
+ package(:zip, :classifier=>'srcs').should point_to_path('target/foo-1.0-srcs.zip')
330
+ end
331
+ end
332
+
333
+ it 'should create prerequisite for package task' do
334
+ define 'foo', :version=>'1.0' do
335
+ package(:war)
336
+ package(:jar, :id=>'bar')
337
+ package(:jar, :classifier=>'srcs')
338
+ end
339
+ project('foo').task('package').prerequisites.should include(*project('foo').packages)
340
+ end
341
+
342
+ it 'should create task requiring a build' do
343
+ define 'foo', :version=>'1.0' do
344
+ package(:war).prerequisites.should include(build)
345
+ package(:jar, :id=>'bar').prerequisites.should include(build)
346
+ package(:jar, :classifier=>'srcs').prerequisites.should include(build)
347
+ end
348
+ end
349
+
350
+ it 'should create a POM artifact in target directory' do
351
+ define 'foo', :version=>'1.0' do
352
+ package.pom.should be(artifact('foo:foo:pom:1.0'))
353
+ package.pom.to_s.should point_to_path('target/foo-1.0.pom')
354
+ end
355
+ end
356
+
357
+ it 'should create POM artifact ignoring classifier' do
358
+ define 'foo', :version=>'1.0' do
359
+ package(:jar, :classifier=>'srcs').pom.should be(artifact('foo:foo:pom:1.0'))
360
+ end
361
+ end
362
+
363
+ it 'should create POM artifact that creates its own POM' do
364
+ define('foo', :group=>'bar', :version=>'1.0') { package(:jar, :classifier=>'srcs') }
365
+ pom = project('foo').packages.first.pom
366
+ pom.invoke
367
+ read(pom.to_s).should eql(<<-POM
368
+ <?xml version="1.0" encoding="UTF-8"?>
369
+ <project>
370
+ <modelVersion>4.0.0</modelVersion>
371
+ <groupId>bar</groupId>
372
+ <artifactId>foo</artifactId>
373
+ <version>1.0</version>
374
+ </project>
375
+ POM
376
+ )
377
+ end
378
+
379
+ it 'should not require downloading artifact or POM' do
380
+ #task('artifacts').instance_eval { @actions.clear }
381
+ define('foo', :group=>'bar', :version=>'1.0') { package(:jar) }
382
+ lambda { task('artifacts').invoke }.should_not raise_error
383
+ end
384
+
385
+ describe "existing package access" do
386
+ it "should return the same instance for identical optionless invocations" do
387
+ define 'foo', :version => '1.0' do
388
+ package(:zip).should equal(package(:zip))
389
+ end
390
+ project('foo').packages.size.should == 1
391
+ end
392
+
393
+ it "should return the exactly matching package identical invocations with options" do
394
+ define 'foo', :version => '1.0' do
395
+ package(:zip, :id => 'src')
396
+ package(:zip, :id => 'bin')
397
+ end
398
+ project('foo').package(:zip, :id => 'src').should equal(project('foo').packages.first)
399
+ project('foo').package(:zip, :id => 'bin').should equal(project('foo').packages.last)
400
+ project('foo').packages.size.should == 2
401
+ end
402
+
403
+ it "should return the first of the same type for subsequent optionless invocations" do
404
+ define 'foo', :version => '1.0' do
405
+ package(:zip, :file => 'override.zip')
406
+ package(:jar, :file => 'another.jar')
407
+ end
408
+ project('foo').package(:zip).name.should == 'override.zip'
409
+ project('foo').package(:jar).name.should == 'another.jar'
410
+ project('foo').packages.size.should == 2
411
+ end
412
+ end
413
+
414
+ end
415
+
416
+
417
+
418
+
419
+
420
+ describe Project, '#package file' do
421
+ it 'should be a file task' do
422
+ define 'foo' do
423
+ package(:zip, :file=>'foo.zip').should be_kind_of(Rake::FileTask)
424
+ end
425
+ end
426
+
427
+ it 'should not require id, project or version' do
428
+ define 'foo', :group=>nil do
429
+ lambda { package(:zip, :file=>'foo.zip') }.should_not raise_error
430
+ lambda { package(:zip, :file=>'bar.zip', :id=>'error') }.should raise_error
431
+ lambda { package(:zip, :file=>'bar.zip', :group=>'error') }.should raise_error
432
+ lambda { package(:zip, :file=>'bar.zip', :version=>'error') }.should raise_error
433
+ end
434
+ end
435
+
436
+ it 'should not provide project or version' do
437
+ define 'foo' do
438
+ package(:zip, :file=>'foo.zip').tap do |pkg|
439
+ pkg.should_not respond_to(:group)
440
+ pkg.should_not respond_to(:version)
441
+ end
442
+ end
443
+ end
444
+
445
+ it 'should provide packaging type' do
446
+ define 'foo', :version=>'1.0' do
447
+ zip = package(:zip, :file=>'foo.zip')
448
+ jar = package(:jar, :file=>'bar.jar')
449
+ zip.type.should eql(:zip)
450
+ jar.type.should eql(:jar)
451
+ end
452
+ end
453
+
454
+ it 'should assume packaging type from extension if unspecified' do
455
+ define 'foo', :version=>'1.0' do
456
+ package(:file=>'foo.zip').class.should be(Buildr::ZipTask)
457
+ define 'bar' do
458
+ package(:file=>'bar.jar').class.should be(Buildr::Packaging::Java::JarTask)
459
+ end
460
+ end
461
+ end
462
+
463
+ it 'should support different packaging types' do
464
+ define 'foo', :version=>'1.0' do
465
+ package(:jar, :file=>'foo.jar').class.should be(Buildr::Packaging::Java::JarTask)
466
+ end
467
+ define 'bar' do
468
+ package(:type=>:war, :file=>'bar.war').class.should be(Buildr::Packaging::Java::WarTask)
469
+ end
470
+ end
471
+
472
+ it 'should fail if packaging not supported' do
473
+ lambda { define('foo') { package(:weirdo, :file=>'foo.zip') } }.should raise_error(RuntimeError, /Don't know how to create a package/)
474
+ end
475
+
476
+ it 'should create different tasks for each file' do
477
+ define 'foo', :version=>'1.0' do
478
+ package(:zip, :file=>'foo.zip')
479
+ package(:jar, :file=>'foo.jar')
480
+ end
481
+ project('foo').packages.uniq.size.should be(2)
482
+ end
483
+
484
+ it 'should return the same task for subsequent calls' do
485
+ define 'foo', :version=>'1.0' do
486
+ package(:zip, :file=>'foo.zip').should eql(package(:file=>'foo.zip'))
487
+ end
488
+ end
489
+
490
+ it 'should point to specified file' do
491
+ define 'foo', :version=>'1.0' do
492
+ package(:zip, :file=>'foo.zip').should point_to_path('foo.zip')
493
+ package(:zip, :file=>'target/foo-1.0.zip').should point_to_path('target/foo-1.0.zip')
494
+ end
495
+ end
496
+
497
+ it 'should create prerequisite for package task' do
498
+ define 'foo', :version=>'1.0' do
499
+ package(:zip, :file=>'foo.zip')
500
+ end
501
+ project('foo').task('package').prerequisites.should include(*project('foo').packages)
502
+ end
503
+
504
+ it 'should create task requiring a build' do
505
+ define 'foo', :version=>'1.0' do
506
+ package(:zip, :file=>'foo.zip').prerequisites.should include(build)
507
+ end
508
+ end
509
+
510
+ it 'should create specified file during build' do
511
+ define 'foo', :version=>'1.0' do
512
+ package(:zip, :file=>'foo.zip')
513
+ end
514
+ lambda { project('foo').task('package').invoke }.should change { File.exist?('foo.zip') }.to(true)
515
+ end
516
+
517
+ it 'should do nothing for installation/upload' do
518
+ define 'foo', :version=>'1.0' do
519
+ package(:zip, :file=>'foo.zip')
520
+ end
521
+ lambda do
522
+ task('install').invoke
523
+ task('upload').invoke
524
+ task('uninstall').invoke
525
+ end.should_not raise_error
526
+ end
527
+
528
+ end
529
+
530
+
531
+
532
+
533
+
534
+
535
+
536
+ describe Rake::Task, ' package' do
537
+ it 'should be local task' do
538
+ define 'foo', :version=>'1.0' do
539
+ package
540
+ define('bar') { package }
541
+ end
542
+ in_original_dir project('foo:bar').base_dir do
543
+ task('package').invoke
544
+ project('foo').package.should_not exist
545
+ project('foo:bar').package.should exist
546
+ end
547
+ end
548
+
549
+ it 'should be recursive task' do
550
+ define 'foo', :version=>'1.0' do
551
+ package
552
+ define('bar') { package }
553
+ end
554
+ task('package').invoke
555
+ project('foo').package.should exist
556
+ project('foo:bar').package.should exist
557
+ end
558
+
559
+ it 'should create package in target directory' do
560
+ define 'foo', :version=>'1.0' do
561
+ package
562
+ define('bar') { package }
563
+ end
564
+ task('package').invoke
565
+ FileList['**/target/*.zip'].map.sort.should == ['bar/target/foo-bar-1.0.zip', 'target/foo-1.0.zip']
566
+ end
567
+ end
568
+
569
+
570
+ describe Rake::Task, ' install' do
571
+ it 'should be local task' do
572
+ define 'foo', :version=>'1.0' do
573
+ package
574
+ define('bar') { package }
575
+ end
576
+ in_original_dir project('foo:bar').base_dir do
577
+ task('install').invoke
578
+ artifacts('foo:foo:zip:1.0', 'foo:foo:pom:1.0').each { |t| t.should_not exist }
579
+ artifacts('foo:foo-bar:zip:1.0', 'foo:foo-bar:pom:1.0').each { |t| t.should exist }
580
+ end
581
+ end
582
+
583
+ it 'should be recursive task' do
584
+ define 'foo', :version=>'1.0' do
585
+ package
586
+ define('bar') { package }
587
+ end
588
+ task('install').invoke
589
+ 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 }
590
+ end
591
+
592
+ it 'should create package in local repository' do
593
+ define 'foo', :version=>'1.0' do
594
+ package
595
+ define('bar') { package }
596
+ end
597
+ task('install').invoke
598
+ FileList[repositories.local + '/**/*'].reject { |f| File.directory?(f) }.sort.should == [
599
+ File.expand_path('foo/foo/1.0/foo-1.0.zip', repositories.local),
600
+ File.expand_path('foo/foo/1.0/foo-1.0.pom', repositories.local),
601
+ File.expand_path('foo/foo-bar/1.0/foo-bar-1.0.zip', repositories.local),
602
+ File.expand_path('foo/foo-bar/1.0/foo-bar-1.0.pom', repositories.local)].sort
603
+ end
604
+ end
605
+
606
+
607
+ describe Rake::Task, ' uninstall' do
608
+ it 'should be local task' do
609
+ define 'foo', :version=>'1.0' do
610
+ package
611
+ define('bar') { package }
612
+ end
613
+ task('install').invoke
614
+ in_original_dir project('foo:bar').base_dir do
615
+ task('uninstall').invoke
616
+ FileList[repositories.local + '/**/*'].reject { |f| File.directory?(f) }.sort.should == [
617
+ File.expand_path('foo/foo/1.0/foo-1.0.zip', repositories.local),
618
+ File.expand_path('foo/foo/1.0/foo-1.0.pom', repositories.local)].sort
619
+ end
620
+ end
621
+
622
+ it 'should be recursive task' do
623
+ define 'foo', :version=>'1.0' do
624
+ package
625
+ define('bar') { package }
626
+ end
627
+ task('install').invoke
628
+ task('uninstall').invoke
629
+ FileList[repositories.local + '/**/*'].reject { |f| File.directory?(f) }.sort.should be_empty
630
+ end
631
+ end
632
+
633
+
634
+ describe Rake::Task, ' upload' do
635
+ before do
636
+ repositories.release_to = URI.escape("file://#{File.expand_path('remote')}")
637
+ end
638
+
639
+ it 'should be local task' do
640
+ define 'foo', :version=>'1.0' do
641
+ package
642
+ define('bar') { package }
643
+ end
644
+ in_original_dir project('foo:bar').base_dir do
645
+ lambda { task('upload').invoke }.should run_task('foo:bar:upload').but_not('foo:upload')
646
+ end
647
+ end
648
+
649
+ it 'should be recursive task' do
650
+ define 'foo', :version=>'1.0' do
651
+ package
652
+ define('bar') { package }
653
+ end
654
+ lambda { task('upload').invoke }.should run_tasks('foo:upload', 'foo:bar:upload')
655
+ end
656
+
657
+ it 'should upload artifact and POM' do
658
+ define('foo', :version=>'1.0') { package :jar }
659
+ task('upload').invoke
660
+ { 'remote/foo/foo/1.0/foo-1.0.jar'=>project('foo').package(:jar),
661
+ 'remote/foo/foo/1.0/foo-1.0.pom'=>project('foo').package(:jar).pom }.each do |upload, package|
662
+ read(upload).should eql(read(package))
663
+ end
664
+ end
665
+
666
+ it 'should not upload twice the pom when artifacts are uploaded from a project' do
667
+ write 'src/main/java/Foo.java', 'public class Foo {}'
668
+ repositories.release_to = 'sftp://example.com/base'
669
+ define 'foo' do
670
+ project.group = "attached"
671
+ project.version = "1.0"
672
+ package(:jar)
673
+ package(:sources)
674
+ end
675
+ URI.should_receive(:upload).exactly(:once).
676
+ with(URI.parse('sftp://example.com/base/attached/foo/1.0/foo-1.0-sources.jar'), project("foo").package(:sources).to_s, anything)
677
+ URI.should_receive(:upload).exactly(:once).
678
+ with(URI.parse('sftp://example.com/base/attached/foo/1.0/foo-1.0.jar'), project("foo").package(:jar).to_s, anything)
679
+ URI.should_receive(:upload).exactly(:once).
680
+ with(URI.parse('sftp://example.com/base/attached/foo/1.0/foo-1.0.pom'), project("foo").package(:jar).pom.to_s, anything)
681
+ verbose(false) { project("foo").upload.invoke }
682
+ end
683
+
684
+ it 'should upload signatures for artifact and POM' do
685
+ define('foo', :version=>'1.0') { package :jar }
686
+ task('upload').invoke
687
+ { 'remote/foo/foo/1.0/foo-1.0.jar'=>project('foo').package(:jar),
688
+ 'remote/foo/foo/1.0/foo-1.0.pom'=>project('foo').package(:jar).pom }.each do |upload, package|
689
+ read("#{upload}.md5").split.first.should eql(Digest::MD5.hexdigest(read(package, "rb")))
690
+ read("#{upload}.sha1").split.first.should eql(Digest::SHA1.hexdigest(read(package, "rb")))
691
+ end
692
+ end
693
+ end
694
+
695
+
696
+ describe Packaging, 'zip' do
697
+ it_should_behave_like 'packaging'
698
+ before { @packaging = :zip }
699
+
700
+ it 'should not include META-INF directory' do
701
+ define('foo', :version=>'1.0') { package(:zip) }
702
+ project('foo').package(:zip).invoke
703
+ Zip::ZipFile.open(project('foo').package(:zip).to_s) do |zip|
704
+ zip.entries.map(&:to_s).should_not include('META-INF/')
705
+ end
706
+ end
707
+ end
708
+
709
+
710
+ describe Packaging, ' tar' do
711
+ before { @packaging = :tar }
712
+ it_should_behave_like 'packaging'
713
+ end
714
+
715
+
716
+ describe Packaging, ' tgz' do
717
+ before { @packaging = :tgz }
718
+ it_should_behave_like 'packaging'
719
+ end