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