buildr-resolver 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,10 +1,9 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "naether", "0.3.3"
4
- gem "buildr", ">= 1.4.4"
3
+ gem "naether", "0.3.4"
4
+ gem "buildr", "= 1.4.5"
5
5
 
6
6
  group :development do
7
- gem "rspec", "~> 1.3.1"
8
7
  gem "bundler", "~> 1.0.0"
9
8
  gem "jeweler", "~> 1.5.2"
10
9
  end
data/Rakefile CHANGED
@@ -9,11 +9,9 @@ rescue Bundler::BundlerError => e
9
9
  end
10
10
  require 'rake'
11
11
 
12
- require 'spec/rake/spectask'
12
+ require 'rspec/core/rake_task'
13
13
 
14
- Spec::Rake::SpecTask.new(:spec) do |t|
15
- t.spec_files = FileList['spec/**/*_spec.rb']
16
- end
14
+ RSpec::Core::RakeTask.new(:spec)
17
15
 
18
16
  task :test => :spec
19
17
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{buildr-resolver}
8
- s.version = "0.3.4"
8
+ s.version = "0.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Guymon"]
12
- s.date = %q{2011-03-14}
12
+ s.date = %q{2011-03-30}
13
13
  s.description = %q{Java dependency resolver for Buildr using Maven's Aether}
14
14
  s.email = %q{michael.guymon@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -23,40 +23,43 @@ Gem::Specification.new do |s|
23
23
  "Rakefile",
24
24
  "VERSION",
25
25
  "buildr-resolver.gemspec",
26
+ "lib/buildr/override/core/transports.rb",
27
+ "lib/buildr/override/packaging/artifact.rb",
28
+ "lib/buildr/packaging/repository_array.rb",
26
29
  "lib/buildr/resolver.rb",
27
30
  "lib/buildr/resolver/java.rb",
31
+ "spec/repository_array_spec.rb",
28
32
  "spec/resolver_spec.rb"
29
33
  ]
30
34
  s.homepage = %q{http://github.com/mguymon/buildr-resolver}
31
35
  s.licenses = ["Apache"]
32
36
  s.require_paths = ["lib"]
33
37
  s.rubyforge_project = %q{buildr-resolver}
34
- s.rubygems_version = %q{1.5.2}
38
+ s.rubygems_version = %q{1.3.7}
35
39
  s.summary = %q{Java dependency resolver for Buildr using Maven's Aether}
36
40
  s.test_files = [
41
+ "spec/repository_array_spec.rb",
37
42
  "spec/resolver_spec.rb"
38
43
  ]
39
44
 
40
45
  if s.respond_to? :specification_version then
46
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
47
  s.specification_version = 3
42
48
 
43
49
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_runtime_dependency(%q<naether>, ["= 0.3.3"])
45
- s.add_runtime_dependency(%q<buildr>, [">= 1.4.4"])
46
- s.add_development_dependency(%q<rspec>, ["~> 1.3.1"])
50
+ s.add_runtime_dependency(%q<naether>, ["= 0.3.4"])
51
+ s.add_runtime_dependency(%q<buildr>, ["= 1.4.5"])
47
52
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
48
53
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
49
54
  else
50
- s.add_dependency(%q<naether>, ["= 0.3.3"])
51
- s.add_dependency(%q<buildr>, [">= 1.4.4"])
52
- s.add_dependency(%q<rspec>, ["~> 1.3.1"])
55
+ s.add_dependency(%q<naether>, ["= 0.3.4"])
56
+ s.add_dependency(%q<buildr>, ["= 1.4.5"])
53
57
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
58
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
55
59
  end
56
60
  else
57
- s.add_dependency(%q<naether>, ["= 0.3.3"])
58
- s.add_dependency(%q<buildr>, [">= 1.4.4"])
59
- s.add_dependency(%q<rspec>, ["~> 1.3.1"])
61
+ s.add_dependency(%q<naether>, ["= 0.3.4"])
62
+ s.add_dependency(%q<buildr>, ["= 1.4.5"])
60
63
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
61
64
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
62
65
  end
@@ -0,0 +1,103 @@
1
+ require 'buildr'
2
+
3
+ module URI
4
+ class HTTP #:nodoc:
5
+
6
+ def read(options = nil, &block)
7
+ options ||= {}
8
+
9
+ user = self.user || options[:username]
10
+ password = self.password || options[:password]
11
+
12
+ connect do |http|
13
+ trace "Requesting #{self}"
14
+ headers = { 'If-Modified-Since' => CGI.rfc1123_date(options[:modified].utc) } if options[:modified]
15
+ request = Net::HTTP::Get.new(request_uri.empty? ? '/' : request_uri, headers)
16
+ request.basic_auth user, password if user
17
+
18
+ http.request request do |response|
19
+ case response
20
+ when Net::HTTPNotModified
21
+ # No modification, nothing to do.
22
+ trace 'Not modified since last download'
23
+ return nil
24
+ when Net::HTTPRedirection
25
+ # Try to download from the new URI, handle relative redirects.
26
+ trace "Redirected to #{response['Location']}"
27
+ rself = self + URI.parse(response['Location'])
28
+ rself.user, rself.password = user, password
29
+ return rself.read(options, &block)
30
+ when Net::HTTPOK
31
+ info "Downloading #{self}"
32
+ result = nil
33
+ with_progress_bar options[:progress], path.split('/').last, response.content_length do |progress|
34
+ if block
35
+ response.read_body do |chunk|
36
+ block.call chunk
37
+ progress << chunk
38
+ end
39
+ else
40
+ result = ''
41
+ response.read_body do |chunk|
42
+ result << chunk
43
+ progress << chunk
44
+ end
45
+ end
46
+ end
47
+ return result
48
+ when Net::HTTPNotFound
49
+ raise NotFoundError, "Looking for #{self} and all I got was a 404!"
50
+ else
51
+ raise RuntimeError, "Failed to download #{self}: #{response.message}"
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def write_internal(options, &block) #:nodoc:
61
+ options ||= {}
62
+ user = self.user || options[:username]
63
+ password = self.password || options[:password]
64
+
65
+ connect do |http|
66
+ trace "Uploading to #{path}"
67
+ content = StringIO.new
68
+ while chunk = yield(RW_CHUNK_SIZE)
69
+ content << chunk
70
+ end
71
+ headers = { 'Content-MD5'=>Digest::MD5.hexdigest(content.string), 'Content-Type'=>'application/octet-stream' }
72
+ request = Net::HTTP::Put.new(request_uri.empty? ? '/' : request_uri, headers)
73
+
74
+ request.basic_auth user, password if user
75
+
76
+ response = nil
77
+ with_progress_bar options[:progress], path.split('/').last, content.size do |progress|
78
+ request.content_length = content.size
79
+ content.rewind
80
+ stream = Object.new
81
+ class << stream ; self ;end.send :define_method, :read do |count|
82
+ bytes = content.read(count)
83
+ progress << bytes if bytes
84
+ bytes
85
+ end
86
+ request.body_stream = stream
87
+ response = http.request(request)
88
+ end
89
+
90
+ case response
91
+ when Net::HTTPRedirection
92
+ # Try to download from the new URI, handle relative redirects.
93
+ trace "Redirected to #{response['Location']}"
94
+ content.rewind
95
+ return (self + URI.parse(response['location'])).write_internal(options) { |bytes| content.read(bytes) }
96
+ when Net::HTTPSuccess
97
+ else
98
+ raise RuntimeError, "Failed to upload #{self}: #{response.message}"
99
+ end
100
+ end
101
+ end
102
+
103
+ end
@@ -0,0 +1,175 @@
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
+ require 'buildr'
17
+ require 'buildr/packaging/repository_array'
18
+
19
+
20
+ module Buildr
21
+
22
+ # A file task referencing an artifact in the local repository.
23
+ #
24
+ # This task includes all the artifact attributes (group, id, version, etc). It points
25
+ # to the artifact's path in the local repository. When invoked, it will download the
26
+ # artifact into the local repository if the artifact does not already exist.
27
+ #
28
+ # Note: You can enhance this task to create the artifact yourself, e.g. download it from
29
+ # a site that doesn't have a remote repository structure, copy it from a different disk, etc.
30
+ class Artifact
31
+
32
+ protected
33
+
34
+ # :call-seq:
35
+ # download
36
+ #
37
+ # Downloads an artifact from one of the remote repositories, and stores it in the local
38
+ # repository. Raises an exception if the artifact is not found.
39
+ #
40
+ # This method attempts to download the artifact from each repository in the order in
41
+ # which they are returned from #remote, until successful.
42
+ def download
43
+ trace "Downloading #{to_spec}"
44
+ remote = Buildr.repositories.remote
45
+ remote = remote.each { |repo| repo[:url].path += '/' unless repo[:url].path[-1] == '/' }
46
+ fail "Unable to download #{to_spec}. No remote repositories defined." if remote.empty?
47
+ exact_success = remote.find do |repo|
48
+ begin
49
+ path = "#{group_path}/#{id}/#{version}/#{File.basename(name)}"
50
+ download_artifact(repo[:url] + path, repo)
51
+ true
52
+ rescue URI::NotFoundError
53
+ false
54
+ rescue Exception=>error
55
+ info error
56
+ trace error.backtrace.join("\n")
57
+ false
58
+ end
59
+ end
60
+
61
+ if exact_success
62
+ return
63
+ elsif snapshot?
64
+ download_m2_snapshot(remote)
65
+ else
66
+ fail_download(remote)
67
+ end
68
+ end
69
+
70
+ def download_m2_snapshot(repos)
71
+ repos.find do |repo|
72
+ snapshot_url = current_snapshot_repo_url(repo)
73
+ if snapshot_url
74
+ begin
75
+ download_artifact snapshot_url
76
+ true
77
+ rescue URI::NotFoundError
78
+ false
79
+ end
80
+ else
81
+ false
82
+ end
83
+ end or fail_download(repos)
84
+ end
85
+
86
+ def current_snapshot_repo_url(repo)
87
+ begin
88
+ metadata_path = "#{group_path}/#{id}/#{version}/maven-metadata.xml"
89
+ metadata_xml = StringIO.new
90
+ URI.download repo[:url] + metadata_path, metadata_xml
91
+ metadata = REXML::Document.new(metadata_xml.string).root
92
+ timestamp = REXML::XPath.first(metadata, '//timestamp')
93
+ build_number = REXML::XPath.first(metadata, '//buildNumber')
94
+ error "No timestamp provided for the snapshot #{to_spec}" if timestamp.nil?
95
+ error "No build number provided for the snapshot #{to_spec}" if build_number.nil?
96
+ return nil if timestamp.nil? || build_number.nil?
97
+ snapshot_of = version[0, version.size - 9]
98
+ repo[:url] + "#{group_path}/#{id}/#{version}/#{id}-#{snapshot_of}-#{timestamp.text}-#{build_number.text}.#{type}"
99
+ rescue URI::NotFoundError
100
+ nil
101
+ end
102
+ end
103
+
104
+ def fail_download(repos)
105
+ fail "Failed to download #{to_spec}, tried the following repositories:\n#{repos.map{ |repo| "#{repo[:url].to_s}#{' as ' + repo[:username] if repo[:username]}" }.join("\n")}"
106
+ end
107
+
108
+ private
109
+
110
+ # :call-seq:
111
+ # download_artifact
112
+ #
113
+ # Downloads artifact from given repository,
114
+ # supports downloading snapshot artifact with relocation on succeed to local repository
115
+ def download_artifact(path, opts = {})
116
+ download_file = "#{name}.#{Time.new.to_i}"
117
+ begin
118
+ URI.download path, download_file, opts
119
+ if File.exist?(download_file)
120
+ FileUtils.mkdir_p(File.dirname(name))
121
+ FileUtils.mv(download_file, name)
122
+ end
123
+ ensure
124
+ File.delete(download_file) if File.exist?(download_file)
125
+ end
126
+ end
127
+
128
+ # :call-seq:
129
+ # :download_needed?
130
+ #
131
+ # Validates whether artifact is required to be downloaded from repository
132
+ def download_needed?(task)
133
+ return true if !File.exist?(name)
134
+
135
+ if snapshot?
136
+ return false if offline? && File.exist?(name)
137
+ return true if update_snapshot? || old?
138
+ end
139
+
140
+ return false
141
+ end
142
+
143
+
144
+ end
145
+
146
+ # Holds the path to the local repository, URLs for remote repositories, and settings for release server.
147
+ #
148
+ # You can access this object from the #repositories method. For example:
149
+ # puts repositories.local
150
+ # repositories.remote << 'http://example.com/repo'
151
+ # repositories.release_to = 'sftp://example.com/var/www/public/repo'
152
+ class Repositories
153
+ include Singleton
154
+
155
+
156
+ # :call-seq:
157
+ # remote = Array
158
+ # remote = url
159
+ # remote = nil
160
+ #
161
+ # With a String argument, clears the array and set it to that single URL.
162
+ #
163
+ # With an Array argument, clears the array and set it to these specific URLs.
164
+ #
165
+ # With nil, clears the array.
166
+ def remote=(urls)
167
+ case urls
168
+ when nil then @remote = nil
169
+ when Array then @remote = RepositoryArray.new(urls.dup)
170
+ else @remote = RepositoryArray.new([urls])
171
+ end
172
+ end
173
+
174
+ end
175
+ end
@@ -0,0 +1,108 @@
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
+ module Buildr
17
+ # Extention of Array to standardize URLs into { :url => 'url', :username => 'username', :password => 'password' }.
18
+ # :url = url of remote repository
19
+ # :username = optional username for authentication
20
+ # :password = optional password for authentication
21
+ class RepositoryArray < Array
22
+
23
+ def initialize( *args )
24
+ if !args.nil? && args.is_a?(Array) && args.size == 1
25
+ args = args[0]
26
+ converted = args.map {|url| convert_remote_url(url) }
27
+ super(converted)
28
+ else
29
+ super(args)
30
+ end
31
+ end
32
+
33
+ # Concatenation—Returns a new array built by concatenating the two arrays together to produce a third array of standardized URL Hashes.
34
+ def +(urls)
35
+ concat(urls)
36
+ end
37
+
38
+ # Append—Pushes the given object on to the end of this array, as a standardize URL Hash. This expression returns the array itself, so several appends may be chained together.
39
+ def <<(url)
40
+ converted = convert_remote_url( url )
41
+ super( converted )
42
+ end
43
+
44
+ # Appends the elements in other_array to self, as standardized URL Hashes
45
+ def concat(urls)
46
+ if !urls.nil?
47
+ converted = urls.map { |url| convert_remote_url( url ) }
48
+ super(converted)
49
+ else
50
+ super(nil)
51
+ end
52
+ end
53
+
54
+ # :call-seq:
55
+ # url = url => hash
56
+ # url = Hash => hash
57
+ #
58
+ # With a String url, returns a standardize URL Hash.
59
+ #
60
+ # With a Hash argument { :url => 'url', :username => 'username', :password => 'password' }, returns a standardize URL Hash.
61
+ #
62
+ def convert_remote_url(url)
63
+ if url.is_a? String
64
+ return {:url => URI.parse(url)}
65
+ elsif url.is_a? Hash
66
+ hash = { :url => URI.parse((url[:url] || url['url'])) }
67
+ username = url[:username] || url['username']
68
+ hash[:username] = username if username
69
+
70
+ password = (url[:password] || url['password'])
71
+ hash[:password] = password if password
72
+
73
+ return hash
74
+ elsif url.is_a? URI
75
+ return { :url => url }
76
+ else
77
+ raise ArgumentError, "Unsupported :url, must be String, Hash, or URI: #{url.inspect}"
78
+ end
79
+ end
80
+
81
+ # Inserts the given values before the element with the given index (which may be negative), as standardized URL Hashes
82
+ def insert( index, *args)
83
+ if !args.nil?
84
+ pos = index
85
+ args.each do |url|
86
+ convert = convert_remote_url( url )
87
+ super( pos, convert )
88
+ if index >= 0
89
+ pos = pos + 1
90
+ end
91
+ end
92
+ else
93
+ super( index, nil )
94
+ end
95
+ end
96
+
97
+ # Replaces the contents of self with the contents of other_array, truncating or expanding if necessary. The contents of other_array
98
+ # is converted standardized URL Hashes.
99
+ def replace( other_array )
100
+ if !other_array.nil?
101
+ converted = other_array.map { |url| convert_remote_url( url ) }
102
+ super( converted )
103
+ else
104
+ super( nil )
105
+ end
106
+ end
107
+ end
108
+ end
@@ -1,6 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'naether'
3
- require "#{File.dirname(__FILE__)}/resolver/java"
3
+ require "buildr/resolver/java"
4
+ require "buildr/packaging/repository_array"
5
+ require "buildr/override/core/transports"
6
+ require "buildr/override/packaging/artifact"
4
7
 
5
8
  module Buildr
6
9
  module Resolver
@@ -17,7 +20,7 @@ module Buildr
17
20
  #
18
21
  # Options
19
22
  # * :excludes - an array of dependencies to regex exclude
20
- # * :repos - an array of {:url => '', :username => '', :password => '' } of additional remote repos that require auth
23
+ # * :download - have Buildr::Resolver download artifacts instead of Buildr
21
24
  def resolve( dependencies, opts = {} )
22
25
 
23
26
  options = opts
@@ -25,25 +28,14 @@ module Buildr
25
28
  if Buildr.repositories.remote.size > 0
26
29
  naether.clear_remote_repositories
27
30
  Buildr.repositories.remote.each do |repo|
28
- naether.add_remote_repository( repo )
29
- end
30
-
31
- unless options[:repos].nil?
32
- repos = options[:repos]
33
- unless repos.is_a? Array
34
- repos = [repos]
35
- end
36
-
37
- repos.each do |repo|
38
- naether.add_remote_repository( repo[:url], repo[:username], repo[:password] )
39
- end
40
- end
31
+ naether.add_remote_repository( repo[:url].to_s, repo[:username], repo[:password] )
32
+ end
41
33
  end
42
34
 
43
35
  naether.local_repo_path = Repositories.instance.local
44
36
 
45
37
  naether.dependencies = dependencies
46
- naether.resolve_dependencies( false )
38
+ naether.resolve_dependencies( opts[:download] == true )
47
39
 
48
40
  unless options[:excludes].nil?
49
41
 
@@ -71,6 +63,10 @@ module Buildr
71
63
  naether.deploy_artifact( notation, file_path, url, opts )
72
64
  end
73
65
 
66
+ def install_artifact( notation, file_path, opts = {} )
67
+ naether.install_artifact( notation, file_path, opts )
68
+ end
69
+
74
70
  def write_pom( notation, file_path )
75
71
  naether.write_pom( notation, file_path )
76
72
  end
@@ -0,0 +1,107 @@
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
+ require 'buildr/packaging/repository_array'
16
+
17
+ describe Buildr::RepositoryArray do
18
+ it 'should create a new instance' do
19
+ repo_array = Buildr::RepositoryArray.new
20
+ repo_array.should_not be_nil
21
+ end
22
+
23
+ it 'should create a new instance from an array' do
24
+ repo_array = Buildr::RepositoryArray.new( ['url1', {:url => 'url2'}] )
25
+ repo_array[0].should eql( { :url => URI.parse('url1') } )
26
+ repo_array[1].should eql( { :url => URI.parse('url2') } )
27
+ end
28
+
29
+ context "instance" do
30
+ before(:each) do
31
+ @array = Buildr::RepositoryArray.new
32
+ end
33
+
34
+ it 'should << and convert to standardize Hash' do
35
+ @array << 'url1' << { 'url' => 'url2' }
36
+ @array[0].should eql( {:url => URI.parse('url1')} )
37
+ @array[1].should eql( {:url => URI.parse('url2')} )
38
+ end
39
+
40
+ it 'should + and convert to standardize Hash' do
41
+ @array + ['url1', { :url => 'url2'}]
42
+ @array[0].should eql( {:url => URI.parse('url1')} )
43
+ @array[1].should eql( {:url => URI.parse('url2')} )
44
+
45
+ @array + ['url3', { :url => 'url4'}]
46
+ @array[0].should eql( {:url => URI.parse('url1')} )
47
+ @array[1].should eql( {:url => URI.parse('url2')} )
48
+ @array[2].should eql( {:url => URI.parse('url3')} )
49
+ @array[3].should eql( {:url => URI.parse('url4')} )
50
+ end
51
+
52
+ it 'should concat and convert to standardize Hash' do
53
+ @array + ['url1', { :url => 'url2'}]
54
+ @array[0].should eql( {:url => URI.parse('url1')} )
55
+ @array[1].should eql( {:url => URI.parse('url2')} )
56
+
57
+ @array + ['url3', { :url => 'url4'}]
58
+ @array[0].should eql( {:url => URI.parse('url1')} )
59
+ @array[1].should eql( {:url => URI.parse('url2')} )
60
+ @array[2].should eql( {:url => URI.parse('url3')} )
61
+ @array[3].should eql( {:url => URI.parse('url4')} )
62
+ end
63
+
64
+ it 'should convert a String into a standardize Hash' do
65
+ @array.convert_remote_url( 'url' ).should eql( {:url => URI.parse('url') } )
66
+ end
67
+
68
+ it 'should convert a Hash into a standardize Hash' do
69
+ @array.convert_remote_url({ :username => 'username', :blah => 7, 'password' => 'password', 'foo' => 'bot', 'url' => 'url' }).should eql( {:url => URI.parse('url'), :username => 'username', :password => 'password' } )
70
+ end
71
+
72
+ it 'should convert a URI into a standardize Hash' do
73
+ @array.convert_remote_url( URI.parse('test')).should eql( {:url => URI.parse('test') } )
74
+ end
75
+
76
+ it 'Unsupported :url, must be String, Hash, or URI: 7' do
77
+ lambda { @array.convert_remote_url( 7 ) }.should raise_error(ArgumentError, /Unsupported :url, must be String, Hash, or URI: 7/)
78
+ end
79
+
80
+ it "should insert as standardized Hash" do
81
+ @array << 'url1' << 'url3'
82
+ @array.insert( 1, 'url2', 'url2.5' )
83
+
84
+ @array[0].should eql( {:url => URI.parse('url1')} )
85
+ @array[1].should eql( {:url => URI.parse('url2')} )
86
+ @array[2].should eql( {:url => URI.parse('url2.5')} )
87
+ @array[3].should eql( {:url => URI.parse('url3')} )
88
+
89
+ @array.insert( -3, 'url2.2', 'url2.3' )
90
+
91
+ @array[0].should eql( {:url => URI.parse('url1')} )
92
+ @array[1].should eql( {:url => URI.parse('url2')} )
93
+ @array[2].should eql( {:url => URI.parse('url2.2')} )
94
+ @array[3].should eql( {:url => URI.parse('url2.3')} )
95
+ @array[4].should eql( {:url => URI.parse('url2.5')} )
96
+ @array[5].should eql( {:url => URI.parse('url3')} )
97
+ end
98
+
99
+ it "should replace as standardized Hash" do
100
+ @array << 'test'
101
+ @array.replace( ['url1', 'url2'] )
102
+
103
+ @array[0].should eql( {:url => URI.parse('url1')} )
104
+ @array[1].should eql( {:url => URI.parse('url2')} )
105
+ end
106
+ end
107
+ end
@@ -1,11 +1,31 @@
1
- require 'lib/buildr/resolver'
2
1
  require 'buildr'
2
+ require 'lib/buildr/resolver'
3
+ require 'uri'
3
4
  require 'fileutils'
4
5
 
5
6
  Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
6
7
 
7
8
  describe Buildr::Resolver do
8
9
  context "Module" do
10
+
11
+ before(:all) do
12
+ unless File.exists? 'tmp/test-repo'
13
+ FileUtils::mkdir_p 'tmp/test-repo'
14
+ end
15
+
16
+ Buildr.repositories.remote = 'http://repo1.maven.org/maven2/'
17
+ Buildr::Resolver.naether.local_repo_path = 'tmp/test-repo'
18
+ Buildr.repositories.local = 'tmp/test-repo'
19
+ end
20
+
21
+
22
+ context "overrides for Buildr" do
23
+ it "should support hash repositories" do
24
+ Buildr.repositories.remote << { :url => 'http://test.com' }
25
+ Buildr.repositories.remote.last.should eql( { :url => URI.parse('http://test.com') } )
26
+ end
27
+ end
28
+
9
29
  it "should resolve dependencies" do
10
30
  dependencies = Buildr::Resolver.resolve( ['ch.qos.logback:logback-classic:jar:0.9.24'] )
11
31
 
@@ -24,18 +44,11 @@ describe Buildr::Resolver do
24
44
  end
25
45
 
26
46
  it "should deploy artifact" do
27
- unless File.exists? 'tmp/test-repo'
28
- FileUtils::mkdir_p 'tmp/test-repo'
29
- end
30
-
31
47
  Buildr::Resolver.deploy_artifact( "test:test:jar:1.12", Naether::Bootstrap.naether_jar, 'file:tmp/test-repo' )
32
48
  File.exists?('tmp/test-repo/test/test/1.12/test-1.12.jar').should be_true
33
49
  end
34
50
 
35
51
  it "should write a pom" do
36
- unless File.exists? 'tmp'
37
- FileUtils::mkdir 'tmp'
38
- end
39
52
  Buildr::Resolver.resolve( ['ch.qos.logback:logback-classic:jar:0.9.24'] )
40
53
  Buildr::Resolver.write_pom( "buildr-resolver:buildr-resolver:jar:45.45", "tmp/pom.xml" )
41
54
  File.exists?( 'tmp/pom.xml' ).should be_true
@@ -45,5 +58,17 @@ describe Buildr::Resolver do
45
58
  xml.should match /.+org.slf4j<\/groupId>\s+<artifactId>slf4j-api<\/artifactId>\s+<version>1.6.0.+/
46
59
 
47
60
  end
61
+
62
+ it "should install a pom" do
63
+ if File.exists?( "#{Buildr::Resolver.naether.local_repo_path}buildr-resolver/11.11/buildr-resolver-11.11.jar" )
64
+ File.delete("#{Buildr::Resolver.naether.local_repo_path}buildr-resolver/11.11/buildr-resolver-11.11.jar")
65
+ end
66
+
67
+ Buildr::Resolver.resolve( ['ch.qos.logback:logback-classic:jar:0.9.24'] )
68
+ Buildr::Resolver.write_pom( "buildr-resolver:buildr-resolver:jar:45.45", "tmp/pom.xml" )
69
+ Buildr::Resolver.install_artifact( "buildr-resolver:buildr-resolver:jar:11.11", Naether::Bootstrap.naether_jar, {:pom_path => "tmp/pom.xml"} )
70
+ File.exists?( "#{Buildr::Resolver.naether.local_repo_path}/buildr-resolver/11.11/buildr-resolver-11.11.jar" )
71
+ end
48
72
  end
73
+
49
74
  end
metadata CHANGED
@@ -1,73 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildr-resolver
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.3.4
4
+ hash: 25
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 5
10
+ version: 0.3.5
6
11
  platform: ruby
7
12
  authors:
8
- - Michael Guymon
13
+ - Michael Guymon
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-03-14 00:00:00 -04:00
18
+ date: 2011-03-30 00:00:00 -04:00
14
19
  default_executable:
15
20
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: naether
18
- version_requirements: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - "="
22
- - !ruby/object:Gem::Version
23
- version: 0.3.3
24
- requirement: *id001
25
- prerelease: false
26
- type: :runtime
27
- - !ruby/object:Gem::Dependency
28
- name: buildr
29
- version_requirements: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 1.4.4
35
- requirement: *id002
36
- prerelease: false
37
- type: :runtime
38
- - !ruby/object:Gem::Dependency
39
- name: rspec
40
- version_requirements: &id003 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.3.1
46
- requirement: *id003
47
- prerelease: false
48
- type: :development
49
- - !ruby/object:Gem::Dependency
50
- name: bundler
51
- version_requirements: &id004 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- version: 1.0.0
57
- requirement: *id004
58
- prerelease: false
59
- type: :development
60
- - !ruby/object:Gem::Dependency
61
- name: jeweler
62
- version_requirements: &id005 !ruby/object:Gem::Requirement
63
- none: false
64
- requirements:
65
- - - ~>
66
- - !ruby/object:Gem::Version
67
- version: 1.5.2
68
- requirement: *id005
69
- prerelease: false
70
- type: :development
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ name: naether
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 27
30
+ segments:
31
+ - 0
32
+ - 3
33
+ - 4
34
+ version: 0.3.4
35
+ requirement: *id001
36
+ type: :runtime
37
+ - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
+ name: buildr
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 13
46
+ segments:
47
+ - 1
48
+ - 4
49
+ - 5
50
+ version: 1.4.5
51
+ requirement: *id002
52
+ type: :runtime
53
+ - !ruby/object:Gem::Dependency
54
+ prerelease: false
55
+ name: bundler
56
+ version_requirements: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 23
62
+ segments:
63
+ - 1
64
+ - 0
65
+ - 0
66
+ version: 1.0.0
67
+ requirement: *id003
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ prerelease: false
71
+ name: jeweler
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 7
78
+ segments:
79
+ - 1
80
+ - 5
81
+ - 2
82
+ version: 1.5.2
83
+ requirement: *id004
84
+ type: :development
71
85
  description: Java dependency resolver for Buildr using Maven's Aether
72
86
  email: michael.guymon@gmail.com
73
87
  executables: []
@@ -75,48 +89,56 @@ executables: []
75
89
  extensions: []
76
90
 
77
91
  extra_rdoc_files:
78
- - LICENSE
79
- - README.rdoc
92
+ - LICENSE
93
+ - README.rdoc
80
94
  files:
81
- - Gemfile
82
- - LICENSE
83
- - README.rdoc
84
- - Rakefile
85
- - VERSION
86
- - buildr-resolver.gemspec
87
- - lib/buildr/resolver.rb
88
- - lib/buildr/resolver/java.rb
89
- - spec/resolver_spec.rb
95
+ - Gemfile
96
+ - LICENSE
97
+ - README.rdoc
98
+ - Rakefile
99
+ - VERSION
100
+ - buildr-resolver.gemspec
101
+ - lib/buildr/override/core/transports.rb
102
+ - lib/buildr/override/packaging/artifact.rb
103
+ - lib/buildr/packaging/repository_array.rb
104
+ - lib/buildr/resolver.rb
105
+ - lib/buildr/resolver/java.rb
106
+ - spec/repository_array_spec.rb
107
+ - spec/resolver_spec.rb
90
108
  has_rdoc: true
91
109
  homepage: http://github.com/mguymon/buildr-resolver
92
110
  licenses:
93
- - Apache
111
+ - Apache
94
112
  post_install_message:
95
113
  rdoc_options: []
96
114
 
97
115
  require_paths:
98
- - lib
116
+ - lib
99
117
  required_ruby_version: !ruby/object:Gem::Requirement
100
118
  none: false
101
119
  requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 2
105
- segments:
106
- - 0
107
- version: "0"
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ hash: 3
123
+ segments:
124
+ - 0
125
+ version: "0"
108
126
  required_rubygems_version: !ruby/object:Gem::Requirement
109
127
  none: false
110
128
  requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: "0"
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 3
132
+ segments:
133
+ - 0
134
+ version: "0"
114
135
  requirements: []
115
136
 
116
137
  rubyforge_project: buildr-resolver
117
- rubygems_version: 1.5.2
138
+ rubygems_version: 1.3.7
118
139
  signing_key:
119
140
  specification_version: 3
120
141
  summary: Java dependency resolver for Buildr using Maven's Aether
121
142
  test_files:
122
- - spec/resolver_spec.rb
143
+ - spec/repository_array_spec.rb
144
+ - spec/resolver_spec.rb