buildr 1.2.10 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +566 -268
- data/DISCLAIMER +7 -1
- data/KEYS +151 -0
- data/NOTICE +23 -8
- data/README +122 -22
- data/Rakefile +49 -229
- data/{lib → addon}/buildr/antlr.rb +23 -10
- data/addon/buildr/cobertura.rb +232 -0
- data/{lib → addon}/buildr/hibernate.rb +20 -4
- data/{lib → addon}/buildr/javacc.rb +27 -12
- data/addon/buildr/jdepend.rb +60 -0
- data/{lib → addon}/buildr/jetty.rb +34 -18
- data/addon/buildr/nailgun.rb +892 -0
- data/{lib → addon}/buildr/openjpa.rb +23 -6
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
- data/{lib → addon}/buildr/xmlbeans.rb +39 -14
- data/bin/buildr +21 -7
- data/buildr.gemspec +50 -0
- data/doc/css/default.css +225 -0
- data/doc/css/print.css +95 -0
- data/doc/css/syntax.css +43 -0
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +317 -0
- data/doc/pages/building.textile +501 -0
- data/doc/pages/contributing.textile +178 -0
- data/doc/pages/download.textile +25 -0
- data/doc/pages/extending.textile +229 -0
- data/doc/pages/getting_started.textile +337 -0
- data/doc/pages/index.textile +63 -0
- data/doc/pages/mailing_lists.textile +17 -0
- data/doc/pages/more_stuff.textile +367 -0
- data/doc/pages/packaging.textile +592 -0
- data/doc/pages/projects.textile +449 -0
- data/doc/pages/recipes.textile +127 -0
- data/doc/pages/settings_profiles.textile +339 -0
- data/doc/pages/testing.textile +475 -0
- data/doc/pages/troubleshooting.textile +121 -0
- data/doc/pages/whats_new.textile +389 -0
- data/doc/print.haml +52 -0
- data/doc/print.toc.yaml +28 -0
- data/doc/scripts/buildr-git.rb +411 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +64 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/site.haml +55 -0
- data/doc/site.toc.yaml +44 -0
- data/lib/buildr.rb +28 -45
- data/lib/buildr/core.rb +27 -0
- data/lib/buildr/core/application.rb +373 -0
- data/lib/buildr/core/application_cli.rb +134 -0
- data/lib/{core → buildr/core}/build.rb +91 -77
- data/lib/{core → buildr/core}/checks.rb +116 -95
- data/lib/buildr/core/common.rb +155 -0
- data/lib/buildr/core/compile.rb +594 -0
- data/lib/buildr/core/environment.rb +120 -0
- data/lib/buildr/core/filter.rb +258 -0
- data/lib/{core → buildr/core}/generate.rb +22 -5
- data/lib/buildr/core/help.rb +118 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/{core → buildr/core}/project.rb +468 -213
- data/lib/buildr/core/test.rb +690 -0
- data/lib/{core → buildr/core}/transports.rb +107 -127
- data/lib/buildr/core/util.rb +235 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/{java → buildr/ide}/eclipse.rb +86 -60
- data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
- data/lib/buildr/ide/idea.rb +194 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +210 -0
- data/lib/buildr/java.rb +26 -0
- data/lib/buildr/java/ant.rb +71 -0
- data/lib/buildr/java/bdd_frameworks.rb +267 -0
- data/lib/buildr/java/commands.rb +210 -0
- data/lib/buildr/java/compilers.rb +432 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/groovyc.rb +137 -0
- data/lib/buildr/java/jruby.rb +99 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
- data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
- data/lib/buildr/java/packaging.rb +706 -0
- data/lib/{java → buildr/java}/pom.rb +20 -4
- data/lib/buildr/java/rjb.rb +142 -0
- data/lib/buildr/java/test_frameworks.rb +290 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +21 -0
- data/lib/{java → buildr/packaging}/artifact.rb +170 -179
- data/lib/buildr/packaging/artifact_namespace.rb +957 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +233 -0
- data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
- data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
- data/rakelib/apache.rake +126 -0
- data/rakelib/changelog.rake +56 -0
- data/rakelib/doc.rake +103 -0
- data/rakelib/package.rake +44 -0
- data/rakelib/release.rake +53 -0
- data/rakelib/rspec.rake +81 -0
- data/rakelib/rubyforge.rake +45 -0
- data/rakelib/scm.rake +49 -0
- data/rakelib/setup.rake +59 -0
- data/rakelib/stage.rake +45 -0
- data/spec/application_spec.rb +316 -0
- data/spec/archive_spec.rb +494 -0
- data/spec/artifact_namespace_spec.rb +635 -0
- data/spec/artifact_spec.rb +738 -0
- data/spec/build_spec.rb +193 -0
- data/spec/checks_spec.rb +537 -0
- data/spec/common_spec.rb +579 -0
- data/spec/compile_spec.rb +561 -0
- data/spec/groovy_compilers_spec.rb +239 -0
- data/spec/java_bdd_frameworks_spec.rb +238 -0
- data/spec/java_compilers_spec.rb +446 -0
- data/spec/java_packaging_spec.rb +1042 -0
- data/spec/java_test_frameworks_spec.rb +414 -0
- data/spec/packaging_helper.rb +63 -0
- data/spec/packaging_spec.rb +589 -0
- data/spec/project_spec.rb +739 -0
- data/spec/sandbox.rb +116 -0
- data/spec/scala_compilers_spec.rb +239 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helpers.rb +283 -0
- data/spec/test_spec.rb +871 -0
- data/spec/transport_spec.rb +300 -0
- data/spec/version_requirement_spec.rb +115 -0
- metadata +188 -77
- data/lib/buildr/cobertura.rb +0 -89
- data/lib/buildr/jdepend.rb +0 -40
- data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
- data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.class +0 -0
- data/lib/buildr/scala.rb +0 -368
- data/lib/core/application.rb +0 -188
- data/lib/core/common.rb +0 -562
- data/lib/core/help.rb +0 -72
- data/lib/core/rake_ext.rb +0 -81
- data/lib/java/ant.rb +0 -71
- data/lib/java/compile.rb +0 -589
- data/lib/java/idea.rb +0 -159
- data/lib/java/java.rb +0 -432
- data/lib/java/packaging.rb +0 -581
- data/lib/java/test.rb +0 -795
- data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,738 @@
|
|
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 Artifact do
|
21
|
+
before do
|
22
|
+
@spec = { :group=>'com.example', :id=>'library', :type=>:jar, :version=>'2.0' }
|
23
|
+
@artifact = artifact(@spec)
|
24
|
+
@classified = artifact(@spec.merge(:classifier=>'all'))
|
25
|
+
@snapshot = artifact(@spec.merge({ :version=>'2.1-SNAPSHOT' }))
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should act as one' do
|
29
|
+
@artifact.should respond_to(:to_spec)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have an artifact identifier' do
|
33
|
+
@artifact.id.should eql('library')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have a group identifier' do
|
37
|
+
@artifact.group.should eql('com.example')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should have a version number' do
|
41
|
+
@artifact.version.should eql('2.0')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should know if it is a snapshot' do
|
45
|
+
@artifact.should_not be_snapshot
|
46
|
+
@classified.should_not be_snapshot
|
47
|
+
@snapshot.should be_snapshot
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should have a file type' do
|
51
|
+
@artifact.type.should eql(:jar)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should understand classifier' do
|
55
|
+
@artifact.classifier.should be_nil
|
56
|
+
@classified.classifier.should eql('all')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should return hash specification' do
|
60
|
+
@artifact.to_hash.should == @spec
|
61
|
+
@artifact.to_spec_hash.should == @spec
|
62
|
+
@classified.to_hash.should == @spec.merge(:classifier=>'all')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should return string specification' do
|
66
|
+
@artifact.to_spec.should eql('com.example:library:jar:2.0')
|
67
|
+
@classified.to_spec.should eql('com.example:library:jar:all:2.0')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should have associated POM artifact' do
|
71
|
+
@artifact.pom.to_hash.should == @artifact.to_hash.merge(:type=>:pom)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should have one artifact for all classifiers' do
|
75
|
+
@classified.pom.to_hash.should == @classified.to_hash.merge(:type=>:pom).except(:classifier)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should download file if file does not exist' do
|
79
|
+
lambda { @artifact.invoke }.should raise_error(Exception, /No remote repositories/)
|
80
|
+
lambda { @classified.invoke }.should raise_error(Exception, /No remote repositories/)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should not download file if file exists' do
|
84
|
+
write repositories.locate(@artifact)
|
85
|
+
lambda { @artifact.invoke }.should_not raise_error
|
86
|
+
write repositories.locate(@classified)
|
87
|
+
lambda { @classified.invoke }.should_not raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should handle lack of POM gracefully' do
|
91
|
+
repositories.remote = 'http://example.com'
|
92
|
+
URI.should_receive(:download).twice { |uri, target, options| raise URI::NotFoundError if uri.to_s.ends_with('.pom') }
|
93
|
+
lambda { @artifact.invoke }.should_not raise_error
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should pass if POM provided' do
|
97
|
+
repositories.remote = 'http://example.com'
|
98
|
+
@artifact.pom.enhance { |task| write task.name, @artifact.pom_xml }
|
99
|
+
write repositories.locate(@artifact)
|
100
|
+
lambda { @artifact.invoke }.should_not raise_error
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should pass if POM not required' do
|
104
|
+
repositories.remote = 'http://example.com'
|
105
|
+
class << @artifact ; def pom() ; end ; end
|
106
|
+
write repositories.locate(@artifact)
|
107
|
+
lambda { @artifact.invoke }.should_not raise_error
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should not download file if dry-run' do
|
111
|
+
dryrun do
|
112
|
+
lambda { @artifact.invoke }.should_not raise_error
|
113
|
+
lambda { @classified.invoke }.should_not raise_error
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should resolve to path in local repository' do
|
118
|
+
@artifact.to_s.should == File.join(repositories.local, 'com/example/library/2.0/library-2.0.jar')
|
119
|
+
@classified.to_s.should == File.join(repositories.local, 'com/example/library/2.0/library-2.0-all.jar')
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should return a list of all registered artifact specifications' do
|
123
|
+
define('foo', :version=>'1.0') { package :jar }
|
124
|
+
Artifact.list.should include(@artifact.to_spec)
|
125
|
+
Artifact.list.should include(@classified.to_spec)
|
126
|
+
Artifact.list.should include('foo:foo:jar:1.0')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
describe Repositories, 'local' do
|
132
|
+
it 'should default to .m2 path' do
|
133
|
+
# For convenience, sandbox actually sets the local repository to a temp directory
|
134
|
+
repositories.local = nil
|
135
|
+
repositories.local.should eql(File.expand_path('.m2/repository', ENV['HOME']))
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should be settable' do
|
139
|
+
repositories.local = '.m2/local'
|
140
|
+
repositories.local.should eql(File.expand_path('.m2/local'))
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should reset to default' do
|
144
|
+
repositories.local = '.m2/local'
|
145
|
+
repositories.local = nil
|
146
|
+
repositories.local.should eql(File.expand_path('~/.m2/repository'))
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should locate file from string specification' do
|
150
|
+
repositories.local = nil
|
151
|
+
repositories.locate('com.example:library:jar:2.0').should eql(
|
152
|
+
File.expand_path('~/.m2/repository/com/example/library/2.0/library-2.0.jar'))
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should locate file from hash specification' do
|
156
|
+
repositories.local = nil
|
157
|
+
repositories.locate(:group=>'com.example', :id=>'library', :version=>'2.0').should eql(
|
158
|
+
File.expand_path('~/.m2/repository/com/example/library/2.0/library-2.0.jar'))
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should load path from settings file' do
|
162
|
+
write 'home/.buildr/settings.yaml', <<-YAML
|
163
|
+
repositories:
|
164
|
+
local: my_repo
|
165
|
+
YAML
|
166
|
+
repositories.local.should eql(File.expand_path('my_repo'))
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
describe Repositories, 'remote' do
|
172
|
+
before do
|
173
|
+
@repos = [ 'http://www.ibiblio.org/maven2', 'http://repo1.maven.org/maven2' ]
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'should be empty initially' do
|
177
|
+
repositories.remote.should be_empty
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should be settable' do
|
181
|
+
repositories.remote = @repos.first
|
182
|
+
repositories.remote.should eql([@repos.first])
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should be settable from array' do
|
186
|
+
repositories.remote = @repos
|
187
|
+
repositories.remote.should eql(@repos)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should add and return repositories in order' do
|
191
|
+
@repos.each { |url| repositories.remote << url }
|
192
|
+
repositories.remote.should eql(@repos)
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'should be used to download artifact' do
|
196
|
+
repositories.remote = 'http://example.com'
|
197
|
+
URI.should_receive(:download).twice.and_return { |uri, target, options| write target }
|
198
|
+
lambda { artifact('com.example:library:jar:2.0').invoke }.
|
199
|
+
should change { File.exist?(File.join(repositories.local, 'com/example/library/2.0/library-2.0.jar')) }.to(true)
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'should lookup in array order' do
|
203
|
+
repositories.remote = [ 'http://example.com', 'http://example.org' ]
|
204
|
+
order = ['com', 'org']
|
205
|
+
URI.should_receive(:download).any_number_of_times do |uri, target, options|
|
206
|
+
order.shift if order.first && uri.to_s[order.first]
|
207
|
+
fail URI::NotFoundError unless order.empty?
|
208
|
+
write target
|
209
|
+
end
|
210
|
+
lambda { artifact('com.example:library:jar:2.0').invoke }.should change { order.empty? }
|
211
|
+
end
|
212
|
+
|
213
|
+
it 'should fail if artifact not found' do
|
214
|
+
repositories.remote = 'http://example.com'
|
215
|
+
URI.should_receive(:download).once.ordered.and_return { fail URI::NotFoundError }
|
216
|
+
lambda { artifact('com.example:library:jar:2.0').invoke }.should raise_error(RuntimeError, /Failed to download/)
|
217
|
+
File.exist?(File.join(repositories.local, 'com/example/library/2.0/library-2.0.jar')).should be_false
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'should support artifact classifier' do
|
221
|
+
repositories.remote = 'http://example.com'
|
222
|
+
URI.should_receive(:download).twice.and_return { |uri, target, options| write target }
|
223
|
+
lambda { artifact('com.example:library:jar:all:2.0').invoke }.
|
224
|
+
should change { File.exist?(File.join(repositories.local, 'com/example/library/2.0/library-2.0-all.jar')) }.to(true)
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'should deal well with repositories URL that lack the last slash' do
|
228
|
+
repositories.remote = 'http://example.com/base'
|
229
|
+
uri = nil
|
230
|
+
URI.should_receive(:download).twice.and_return { |uri, target, options| }
|
231
|
+
artifact('group:id:jar:1.0').invoke
|
232
|
+
uri.to_s.should eql('http://example.com/base/group/id/1.0/id-1.0.pom')
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'should deal well with repositories URL that have the last slash' do
|
236
|
+
repositories.remote = 'http://example.com/base/'
|
237
|
+
uri = nil
|
238
|
+
URI.should_receive(:download).twice.and_return { |uri, target, options| }
|
239
|
+
artifact('group:id:jar:1.0').invoke
|
240
|
+
uri.to_s.should eql('http://example.com/base/group/id/1.0/id-1.0.pom')
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'should resolve m2-style deployed snapshots' do
|
244
|
+
metadata = <<-XML
|
245
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
246
|
+
<metadata>
|
247
|
+
<groupId>com.example</groupId>
|
248
|
+
<artifactId>library</artifactId>
|
249
|
+
<version>2.1-SNAPSHOT</version>
|
250
|
+
<versioning>
|
251
|
+
<snapshot>
|
252
|
+
<timestamp>20071012.190008</timestamp>
|
253
|
+
<buildNumber>8</buildNumber>
|
254
|
+
</snapshot>
|
255
|
+
<lastUpdated>20071012190008</lastUpdated>
|
256
|
+
</versioning>
|
257
|
+
</metadata>
|
258
|
+
XML
|
259
|
+
repositories.remote = 'http://example.com'
|
260
|
+
URI.should_receive(:download).twice.with(uri(/2.1-SNAPSHOT\/library-2.1-SNAPSHOT.(jar|pom)$/), anything()).
|
261
|
+
and_return { fail URI::NotFoundError }
|
262
|
+
URI.should_receive(:download).twice.with(uri(/2.1-SNAPSHOT\/maven-metadata.xml$/), duck_type(:write)).
|
263
|
+
and_return { |uri, target, options| target.write(metadata) }
|
264
|
+
URI.should_receive(:download).twice.with(uri(/2.1-SNAPSHOT\/library-2.1-20071012.190008-8.(jar|pom)$/), /2.1-SNAPSHOT\/library-2.1-SNAPSHOT.(jar|pom)$/).
|
265
|
+
and_return { |uri, target, options| write target }
|
266
|
+
lambda { artifact('com.example:library:jar:2.1-SNAPSHOT').invoke }.
|
267
|
+
should change { File.exist?(File.join(repositories.local, 'com/example/library/2.1-SNAPSHOT/library-2.1-SNAPSHOT.jar')) }.to(true)
|
268
|
+
end
|
269
|
+
|
270
|
+
it 'should handle missing maven metadata by reporting the artifact unavailable' do
|
271
|
+
repositories.remote = 'http://example.com'
|
272
|
+
URI.should_receive(:download).with(uri(/2.1-SNAPSHOT\/library-2.1-SNAPSHOT.jar$/), anything()).
|
273
|
+
and_return { fail URI::NotFoundError }
|
274
|
+
URI.should_receive(:download).with(uri(/2.1-SNAPSHOT\/maven-metadata.xml$/), duck_type(:write)).
|
275
|
+
and_return { fail URI::NotFoundError }
|
276
|
+
lambda { artifact('com.example:library:jar:2.1-SNAPSHOT').invoke }.should raise_error(RuntimeError, /Failed to download/)
|
277
|
+
File.exist?(File.join(repositories.local, 'com/example/library/2.1-SNAPSHOT/library-2.1-SNAPSHOT.jar')).should be_false
|
278
|
+
end
|
279
|
+
|
280
|
+
it 'should handle missing m2 snapshots by reporting the artifact unavailable' do
|
281
|
+
metadata = <<-XML
|
282
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
283
|
+
<metadata>
|
284
|
+
<groupId>com.example</groupId>
|
285
|
+
<artifactId>library</artifactId>
|
286
|
+
<version>2.1-SNAPSHOT</version>
|
287
|
+
<versioning>
|
288
|
+
<snapshot>
|
289
|
+
<timestamp>20071012.190008</timestamp>
|
290
|
+
<buildNumber>8</buildNumber>
|
291
|
+
</snapshot>
|
292
|
+
<lastUpdated>20071012190008</lastUpdated>
|
293
|
+
</versioning>
|
294
|
+
</metadata>
|
295
|
+
XML
|
296
|
+
repositories.remote = 'http://example.com'
|
297
|
+
URI.should_receive(:download).with(uri(/2.1-SNAPSHOT\/library-2.1-SNAPSHOT.jar$/), anything()).
|
298
|
+
and_return { fail URI::NotFoundError }
|
299
|
+
URI.should_receive(:download).with(uri(/2.1-SNAPSHOT\/maven-metadata.xml$/), duck_type(:write)).
|
300
|
+
and_return { |uri, target, options| target.write(metadata) }
|
301
|
+
URI.should_receive(:download).with(uri(/2.1-SNAPSHOT\/library-2.1-20071012.190008-8.jar$/), anything()).
|
302
|
+
and_return { fail URI::NotFoundError }
|
303
|
+
lambda { artifact('com.example:library:jar:2.1-SNAPSHOT').invoke }.should raise_error(RuntimeError, /Failed to download/)
|
304
|
+
File.exist?(File.join(repositories.local, 'com/example/library/2.1-SNAPSHOT/library-2.1-SNAPSHOT.jar')).should be_false
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'should load with all repositories specified in settings file' do
|
308
|
+
write 'home/.buildr/settings.yaml', <<-YAML
|
309
|
+
repositories:
|
310
|
+
remote:
|
311
|
+
- http://example.com
|
312
|
+
- http://example.org
|
313
|
+
YAML
|
314
|
+
repositories.remote.should include('http://example.com', 'http://example.org')
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'should load with all repositories specified in build.yaml file' do
|
318
|
+
write 'build.yaml', <<-YAML
|
319
|
+
repositories:
|
320
|
+
remote:
|
321
|
+
- http://example.com
|
322
|
+
- http://example.org
|
323
|
+
YAML
|
324
|
+
repositories.remote.should include('http://example.com', 'http://example.org')
|
325
|
+
end
|
326
|
+
|
327
|
+
it 'should load with all repositories specified in settings and build.yaml files' do
|
328
|
+
write 'home/.buildr/settings.yaml', <<-YAML
|
329
|
+
repositories:
|
330
|
+
remote:
|
331
|
+
- http://example.com
|
332
|
+
YAML
|
333
|
+
write 'build.yaml', <<-YAML
|
334
|
+
repositories:
|
335
|
+
remote:
|
336
|
+
- http://example.org
|
337
|
+
YAML
|
338
|
+
repositories.remote.should include('http://example.com', 'http://example.org')
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
|
343
|
+
describe Repositories, 'release_to' do
|
344
|
+
it 'should accept URL as first argument' do
|
345
|
+
repositories.release_to = 'http://example.com'
|
346
|
+
repositories.release_to.should == { :url=>'http://example.com' }
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'should accept hash with options' do
|
350
|
+
repositories.release_to = { :url=>'http://example.com', :username=>'john' }
|
351
|
+
repositories.release_to.should == { :url=>'http://example.com', :username=>'john' }
|
352
|
+
end
|
353
|
+
|
354
|
+
it 'should allow the hash to be manipulated' do
|
355
|
+
repositories.release_to = 'http://example.com'
|
356
|
+
repositories.release_to.should == { :url=>'http://example.com' }
|
357
|
+
repositories.release_to[:username] = 'john'
|
358
|
+
repositories.release_to.should == { :url=>'http://example.com', :username=>'john' }
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'should load URL from settings file' do
|
362
|
+
write 'home/.buildr/settings.yaml', <<-YAML
|
363
|
+
repositories:
|
364
|
+
release_to: http://john:secret@example.com
|
365
|
+
YAML
|
366
|
+
repositories.release_to.should == { :url=>'http://john:secret@example.com' }
|
367
|
+
end
|
368
|
+
|
369
|
+
it 'should load URL, username and password from settings file' do
|
370
|
+
write 'home/.buildr/settings.yaml', <<-YAML
|
371
|
+
repositories:
|
372
|
+
release_to:
|
373
|
+
url: http://example.com
|
374
|
+
username: john
|
375
|
+
password: secret
|
376
|
+
YAML
|
377
|
+
repositories.release_to.should == { :url=>'http://example.com', :username=>'john', :password=>'secret' }
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
|
382
|
+
describe Buildr, '#artifact' do
|
383
|
+
before { @spec = { :group=>'com.example', :id=>'library', :type=>'jar', :version=>'2.0' } }
|
384
|
+
|
385
|
+
it 'should accept hash specification' do
|
386
|
+
artifact(:group=>'com.example', :id=>'library', :type=>'jar', :version=>'2.0').should respond_to(:invoke)
|
387
|
+
end
|
388
|
+
|
389
|
+
it 'should reject partial hash specifier' do
|
390
|
+
lambda { artifact(@spec.merge(:group=>nil)) }.should raise_error
|
391
|
+
lambda { artifact(@spec.merge(:id=>nil)) }.should raise_error
|
392
|
+
lambda { artifact(@spec.merge(:version=>nil)) }.should raise_error
|
393
|
+
end
|
394
|
+
|
395
|
+
it 'should complain about invalid key' do
|
396
|
+
lambda { artifact(@spec.merge(:error=>true)) }.should raise_error(ArgumentError, /no such option/i)
|
397
|
+
end
|
398
|
+
|
399
|
+
it 'should use JAR type by default' do
|
400
|
+
artifact(@spec.merge(:type=>nil)).should respond_to(:invoke)
|
401
|
+
end
|
402
|
+
|
403
|
+
it 'should accept string specification' do
|
404
|
+
artifact('com.example:library:jar:2.0').should respond_to(:invoke)
|
405
|
+
end
|
406
|
+
|
407
|
+
it 'should reject partial string specifier' do
|
408
|
+
artifact('com.example:library::2.0')
|
409
|
+
lambda { artifact('com.example:library:jar') }.should raise_error
|
410
|
+
lambda { artifact('com.example:library:jar:') }.should raise_error
|
411
|
+
lambda { artifact('com.example:library::2.0') }.should_not raise_error
|
412
|
+
lambda { artifact('com.example::jar:2.0') }.should raise_error
|
413
|
+
lambda { artifact(':library:jar:2.0') }.should raise_error
|
414
|
+
end
|
415
|
+
|
416
|
+
it 'should create a task naming the artifact in the local repository' do
|
417
|
+
file = File.join(repositories.local, 'com', 'example', 'library', '2.0', 'library-2.0.jar')
|
418
|
+
Rake::Task.task_defined?(file).should be_false
|
419
|
+
artifact('com.example:library:jar:2.0').name.should eql(file)
|
420
|
+
end
|
421
|
+
|
422
|
+
it 'should use from method to install artifact from existing file' do
|
423
|
+
write 'test.jar'
|
424
|
+
artifact = artifact('group:id:jar:1.0').from('test.jar')
|
425
|
+
lambda { artifact.invoke }.should change { File.exist?(artifact.to_s) }.to(true)
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
|
430
|
+
describe Buildr, '#artifacts' do
|
431
|
+
it 'should return a list of artifacts from all its arguments' do
|
432
|
+
specs = [ 'saxon:saxon:jar:8.4', 'saxon:saxon-dom:jar:8.4', 'saxon:saxon-xpath:jar:8.4' ]
|
433
|
+
artifacts(*specs).should eql(specs.map { |spec| artifact(spec) })
|
434
|
+
end
|
435
|
+
|
436
|
+
it 'should accept nested arrays' do
|
437
|
+
specs = [ 'saxon:saxon:jar:8.4', 'saxon:saxon-dom:jar:8.4', 'saxon:saxon-xpath:jar:8.4' ]
|
438
|
+
artifacts([[specs[0]]], [[specs[1]], specs[2]]).should eql(specs.map { |spec| artifact(spec) })
|
439
|
+
end
|
440
|
+
|
441
|
+
it 'should accept struct' do
|
442
|
+
specs = struct(:main=>'saxon:saxon:jar:8.4', :dom=>'saxon:saxon-dom:jar:8.4', :xpath=>'saxon:saxon-xpath:jar:8.4')
|
443
|
+
artifacts(specs).should eql(specs.values.map { |spec| artifact(spec) })
|
444
|
+
end
|
445
|
+
|
446
|
+
it 'should ignore duplicates' do
|
447
|
+
artifacts('saxon:saxon:jar:8.4', 'saxon:saxon:jar:8.4').size.should be(1)
|
448
|
+
end
|
449
|
+
|
450
|
+
it 'should accept and return existing tasks' do
|
451
|
+
artifacts(task('foo'), task('bar')).should eql([task('foo'), task('bar')])
|
452
|
+
end
|
453
|
+
|
454
|
+
it 'should accept filenames and expand them' do
|
455
|
+
artifacts('test').map(&:to_s).should eql([File.expand_path('test')])
|
456
|
+
end
|
457
|
+
|
458
|
+
it 'should accept filenames and return filenames' do
|
459
|
+
artifacts('c:test').first.should be_kind_of(String)
|
460
|
+
end
|
461
|
+
|
462
|
+
it 'should accept project and return all its packaging tasks' do
|
463
|
+
define 'foobar', :group=>'group', :version=>'1.0' do
|
464
|
+
package :jar, :id=>'code'
|
465
|
+
package :war, :id=>'webapp'
|
466
|
+
end
|
467
|
+
foobar = project('foobar')
|
468
|
+
artifacts(foobar).should eql([
|
469
|
+
task(foobar.path_to('target/code-1.0.jar')),
|
470
|
+
task(foobar.path_to('target/webapp-1.0.war'))
|
471
|
+
])
|
472
|
+
end
|
473
|
+
|
474
|
+
it 'should complain about an invalid specification' do
|
475
|
+
lambda { artifacts(5) }.should raise_error
|
476
|
+
lambda { artifacts('group:no:version:') }.should raise_error
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
|
481
|
+
describe Buildr, '#group' do
|
482
|
+
it 'should accept list of artifact identifiers' do
|
483
|
+
list = group('saxon', 'saxon-dom', 'saxon-xpath', :under=>'saxon', :version=>'8.4')
|
484
|
+
list.should include(artifact('saxon:saxon:jar:8.4'))
|
485
|
+
list.should include(artifact('saxon:saxon-dom:jar:8.4'))
|
486
|
+
list.should include(artifact('saxon:saxon-xpath:jar:8.4'))
|
487
|
+
list.size.should be(3)
|
488
|
+
end
|
489
|
+
|
490
|
+
it 'should accept array with artifact identifiers' do
|
491
|
+
list = group(%w{saxon saxon-dom saxon-xpath}, :under=>'saxon', :version=>'8.4')
|
492
|
+
list.should include(artifact('saxon:saxon:jar:8.4'))
|
493
|
+
list.should include(artifact('saxon:saxon-dom:jar:8.4'))
|
494
|
+
list.should include(artifact('saxon:saxon-xpath:jar:8.4'))
|
495
|
+
list.size.should be(3)
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
|
500
|
+
describe Builder, '#install' do
|
501
|
+
before do
|
502
|
+
@spec = 'group:id:jar:1.0'
|
503
|
+
write @file = 'test.jar'
|
504
|
+
end
|
505
|
+
|
506
|
+
it 'should return the install task' do
|
507
|
+
install.should be(task('install'))
|
508
|
+
end
|
509
|
+
|
510
|
+
it 'should accept artifacts to install' do
|
511
|
+
install artifact(@spec)
|
512
|
+
lambda { install @file }.should raise_error(ArgumentError)
|
513
|
+
end
|
514
|
+
|
515
|
+
it 'should install artifact when install task is run' do
|
516
|
+
write @file
|
517
|
+
install artifact(@spec).from(@file)
|
518
|
+
lambda { install.invoke }.should change { File.exist?(artifact(@spec).to_s) }.to(true)
|
519
|
+
end
|
520
|
+
|
521
|
+
it 'should install POM alongside artifact' do
|
522
|
+
write @file
|
523
|
+
install artifact(@spec).from(@file)
|
524
|
+
lambda { install.invoke }.should change { File.exist?(artifact(@spec).pom.to_s) }.to(true)
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
528
|
+
|
529
|
+
describe Builder, '#upload' do
|
530
|
+
before do
|
531
|
+
@spec = 'group:id:jar:1.0'
|
532
|
+
write @file = 'test.jar'
|
533
|
+
repositories.release_to = 'sftp://example.com/base'
|
534
|
+
end
|
535
|
+
|
536
|
+
it 'should return the upload task' do
|
537
|
+
upload.should be(task('upload'))
|
538
|
+
end
|
539
|
+
|
540
|
+
it 'should accept artifacts to upload' do
|
541
|
+
upload artifact(@spec)
|
542
|
+
lambda { upload @file }.should raise_error(ArgumentError)
|
543
|
+
end
|
544
|
+
|
545
|
+
it 'should upload artifact when upload task is run' do
|
546
|
+
write @file
|
547
|
+
upload artifact(@spec).from(@file)
|
548
|
+
URI.should_receive(:upload).once.
|
549
|
+
with(URI.parse('sftp://example.com/base/group/id/1.0/id-1.0.jar'), artifact(@spec).to_s, anything)
|
550
|
+
URI.should_receive(:upload).once.
|
551
|
+
with(URI.parse('sftp://example.com/base/group/id/1.0/id-1.0.pom'), artifact(@spec).pom.to_s, anything)
|
552
|
+
upload.invoke
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
|
557
|
+
describe ActsAsArtifact, '#upload' do
|
558
|
+
it 'should be used to upload artifact' do
|
559
|
+
artifact = artifact('com.example:library:jar:2.0')
|
560
|
+
# Prevent artifact from downloading anything.
|
561
|
+
write repositories.locate(artifact)
|
562
|
+
write repositories.locate(artifact.pom)
|
563
|
+
URI.should_receive(:upload).once.
|
564
|
+
with(URI.parse('sftp://example.com/base/com/example/library/2.0/library-2.0.pom'), artifact.pom.to_s, anything)
|
565
|
+
URI.should_receive(:upload).once.
|
566
|
+
with(URI.parse('sftp://example.com/base/com/example/library/2.0/library-2.0.jar'), artifact.to_s, anything)
|
567
|
+
verbose(false) { artifact.upload(:url=>'sftp://example.com/base') }
|
568
|
+
end
|
569
|
+
|
570
|
+
it 'should support artifact classifier' do
|
571
|
+
artifact = artifact('com.example:library:jar:all:2.0')
|
572
|
+
# Prevent artifact from downloading anything.
|
573
|
+
write repositories.locate(artifact)
|
574
|
+
write repositories.locate(artifact.pom)
|
575
|
+
URI.should_receive(:upload).at_least(:once).
|
576
|
+
with(URI.parse('sftp://example.com/base/com/example/library/2.0/library-2.0.pom'), artifact.pom.to_s, anything)
|
577
|
+
URI.should_receive(:upload).at_least(:once).
|
578
|
+
with(URI.parse('sftp://example.com/base/com/example/library/2.0/library-2.0-all.jar'), artifact.to_s, anything)
|
579
|
+
verbose(false) { artifact.upload(:url=>'sftp://example.com/base') }
|
580
|
+
end
|
581
|
+
|
582
|
+
it 'should complain without any repository configuration' do
|
583
|
+
artifact = artifact('com.example:library:jar:2.0')
|
584
|
+
# Prevent artifact from downloading anything.
|
585
|
+
write repositories.locate(artifact)
|
586
|
+
write repositories.locate(artifact.pom)
|
587
|
+
lambda { artifact.upload }.should raise_error(Exception, /where to upload/)
|
588
|
+
end
|
589
|
+
|
590
|
+
it 'should accept repositories.upload setting' do
|
591
|
+
artifact = artifact('com.example:library:jar:2.0')
|
592
|
+
# Prevent artifact from downloading anything.
|
593
|
+
write repositories.locate(artifact)
|
594
|
+
write repositories.locate(artifact.pom)
|
595
|
+
URI.should_receive(:upload).at_least(:once)
|
596
|
+
repositories.release_to = 'sftp://example.com/base'
|
597
|
+
artifact.upload
|
598
|
+
lambda { artifact.upload }.should_not raise_error
|
599
|
+
end
|
600
|
+
end
|
601
|
+
|
602
|
+
|
603
|
+
describe Rake::Task, ' artifacts' do
|
604
|
+
it 'should download all specified artifacts' do
|
605
|
+
artifact 'group:id:jar:1.0'
|
606
|
+
repositories.remote = 'http://example.com'
|
607
|
+
URI.should_receive(:download).twice.and_return { |uri, target, options| write target }
|
608
|
+
task('artifacts').invoke
|
609
|
+
end
|
610
|
+
|
611
|
+
it 'should fail if failed to download an artifact' do
|
612
|
+
artifact 'group:id:jar:1.0'
|
613
|
+
lambda { task('artifacts').invoke }.should raise_error(RuntimeError, /No remote repositories/)
|
614
|
+
end
|
615
|
+
|
616
|
+
it 'should succeed if artifact already exists' do
|
617
|
+
write repositories.locate(artifact('group:id:jar:1.0'))
|
618
|
+
suppress_stdout do
|
619
|
+
lambda { task('artifacts').invoke }.should_not raise_error
|
620
|
+
end
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
|
625
|
+
describe Buildr, '#transitive' do
|
626
|
+
before do
|
627
|
+
repositories.remote = 'http://example.com'
|
628
|
+
@simple = [ 'saxon:saxon:jar:8.4', 'saxon:saxon-dom:jar:8.4', 'saxon:saxon-xpath:jar:8.4' ]
|
629
|
+
@simple.map { |spec| artifact(spec).pom }.each { |task| write task.name, task.pom_xml }
|
630
|
+
@provided = @simple.first
|
631
|
+
@complex = 'group:app:jar:1.0'
|
632
|
+
write artifact(@complex).pom.to_s, <<-XML
|
633
|
+
<project>
|
634
|
+
<artifactId>app</artifactId>
|
635
|
+
<groupId>group</groupId>
|
636
|
+
<dependencies>
|
637
|
+
<dependency>
|
638
|
+
<artifactId>saxon</artifactId>
|
639
|
+
<groupId>saxon</groupId>
|
640
|
+
<version>8.4</version>
|
641
|
+
<scope>provided</scope>
|
642
|
+
</dependency>
|
643
|
+
<dependency>
|
644
|
+
<artifactId>saxon-dom</artifactId>
|
645
|
+
<groupId>saxon</groupId>
|
646
|
+
<version>8.4</version>
|
647
|
+
<scope>runtime</scope>
|
648
|
+
</dependency>
|
649
|
+
<dependency>
|
650
|
+
<artifactId>saxon-xpath</artifactId>
|
651
|
+
<groupId>saxon</groupId>
|
652
|
+
<version>8.4</version>
|
653
|
+
</dependency>
|
654
|
+
<dependency>
|
655
|
+
<artifactId>saxon-nosuch</artifactId>
|
656
|
+
<groupId>saxon</groupId>
|
657
|
+
<version>8.4</version>
|
658
|
+
<scope>test</scope>
|
659
|
+
</dependency>
|
660
|
+
</dependencies>
|
661
|
+
</project>
|
662
|
+
XML
|
663
|
+
@transitive = 'master:app:war:1.0'
|
664
|
+
write artifact(@transitive).pom.to_s, <<-XML
|
665
|
+
<project>
|
666
|
+
<artifactId>app</artifactId>
|
667
|
+
<groupId>group</groupId>
|
668
|
+
<dependencies>
|
669
|
+
<dependency>
|
670
|
+
<artifactId>app</artifactId>
|
671
|
+
<groupId>group</groupId>
|
672
|
+
<version>1.0</version>
|
673
|
+
</dependency>
|
674
|
+
</dependencies>
|
675
|
+
</project>
|
676
|
+
XML
|
677
|
+
end
|
678
|
+
|
679
|
+
it 'should return a list of artifacts from all its arguments' do
|
680
|
+
specs = [ 'saxon:saxon:jar:8.4', 'saxon:saxon-dom:jar:8.4', 'saxon:saxon-xpath:jar:8.4' ]
|
681
|
+
transitive(*specs).should eql(specs.map { |spec| artifact(spec) })
|
682
|
+
end
|
683
|
+
|
684
|
+
it 'should accept nested arrays' do
|
685
|
+
specs = [ 'saxon:saxon:jar:8.4', 'saxon:saxon-dom:jar:8.4', 'saxon:saxon-xpath:jar:8.4' ]
|
686
|
+
transitive([[specs[0]]], [[specs[1]], specs[2]]).should eql(specs.map { |spec| artifact(spec) })
|
687
|
+
end
|
688
|
+
|
689
|
+
it 'should accept struct' do
|
690
|
+
specs = struct(:main=>'saxon:saxon:jar:8.4', :dom=>'saxon:saxon-dom:jar:8.4', :xpath=>'saxon:saxon-xpath:jar:8.4')
|
691
|
+
transitive(specs).should eql(specs.values.map { |spec| artifact(spec) })
|
692
|
+
end
|
693
|
+
|
694
|
+
it 'should ignore duplicates' do
|
695
|
+
transitive('saxon:saxon:jar:8.4', 'saxon:saxon:jar:8.4').size.should be(1)
|
696
|
+
end
|
697
|
+
|
698
|
+
it 'should accept and return existing tasks' do
|
699
|
+
transitive(task('foo'), task('bar')).should eql([task('foo'), task('bar')])
|
700
|
+
end
|
701
|
+
|
702
|
+
it 'should accept filenames and expand them' do
|
703
|
+
transitive('test').map(&:to_s).should eql([File.expand_path('test')])
|
704
|
+
end
|
705
|
+
|
706
|
+
it 'should accept filenames and return file task' do
|
707
|
+
transitive('c:test').first.should be_kind_of(Rake::FileTask)
|
708
|
+
end
|
709
|
+
|
710
|
+
it 'should accept project and return all its packaging tasks' do
|
711
|
+
define 'foobar', :group=>'group', :version=>'1.0' do
|
712
|
+
package :jar, :id=>'code'
|
713
|
+
package :war, :id=>'webapp'
|
714
|
+
end
|
715
|
+
foobar = project('foobar')
|
716
|
+
transitive(foobar).should eql([
|
717
|
+
task(foobar.path_to('target/code-1.0.jar')),
|
718
|
+
task(foobar.path_to('target/webapp-1.0.war'))
|
719
|
+
])
|
720
|
+
end
|
721
|
+
|
722
|
+
it 'should complain about an invalid specification' do
|
723
|
+
lambda { transitive(5) }.should raise_error
|
724
|
+
lambda { transitive('group:no:version:') }.should raise_error
|
725
|
+
end
|
726
|
+
|
727
|
+
it 'should bring artifact and its dependencies' do
|
728
|
+
transitive(@complex).should eql(artifacts(@complex, @simple))
|
729
|
+
end
|
730
|
+
|
731
|
+
it 'should bring dependencies of POM without artifact itself' do
|
732
|
+
transitive(@complex.sub(/jar/, 'pom')).should eql(artifacts(@simple))
|
733
|
+
end
|
734
|
+
|
735
|
+
it 'should bring artifact and transitive depenencies' do
|
736
|
+
transitive(@transitive).should eql(artifacts(@transitive, @complex, @simple - [@provided]))
|
737
|
+
end
|
738
|
+
end
|