Something similar to what's in the attached patch worked for me when I was running into similar issues. Be warned it's been a while since I've looked at this and it's not been tested in months -- hopefully it still works.

I haven't had time to clean it up into a "proper" patch with tests etc., but happy to give it a crack should you find it useful.

The patch is against the latest in git master.

Cheers,
Tom

On 21/10/11 19:13, Sprog : Weyert de Boer wrote:
My buildr copy currently trying to download a Moven repository item. A zip file 
but it keeps timing out.
Can I somehow increase the timeout so that it has a bit more time to finish the 
download?

I am using buildr together with jruby. I already tried to put the file in the 
.m2 directory but that didn't fool buildr.

** Invoke 
C:/Users/x/.m2/repository/com/adobe/flex/sdk/4.5.0.20967/sdk-4.5.0.20967.zip 
(first_time)
** Execute 
C:/Users/x/.m2/repository/com/adobe/flex/sdk/4.5.0.20967/sdk-4.5.0.20967.zip
Requesting 
http://fpdownload.adobe.com/pub/flex/sdk/builds/flex4.5/flex_sdk_4.5.0.20967.zip
Downloading 
http://fpdownload.adobe.com/pub/flex/sdk/builds/flex4.5/flex_sdk_4.5.0.20967.zip
Buildr aborted!2096..:  99% |......................................... |  
218.5MB/218.6MB ETA:  00:00:01
Timeout::Error : execution expired
org/jruby/RubyIO.java:2629:in `sysread'

Thanks.



--

*Tom Lee*
Software Developer / Consultant
http://tomlee.co | @tglee <http://twitter.com/tglee> | (503) 522-6274 <tel:+15035226274>

/(or check out my code on github <http://github.com/thomaslee>)/

diff --git a/lib/buildr/core/environment.rb b/lib/buildr/core/environment.rb
index ac215e8..091caed 100644
--- a/lib/buildr/core/environment.rb
+++ b/lib/buildr/core/environment.rb
@@ -83,6 +83,10 @@ module Buildr
 
     end
 
+    class Download
+      attr_accessor :read_timeout
+    end
+
     # :call-seq:
     #   proxy => options
     #
@@ -102,6 +106,9 @@ module Buildr
       @proxy ||= Proxies.new
     end
 
+    def download
+      @http ||= Download.new
+    end
   end
 
 
diff --git a/lib/buildr/core/transports.rb b/lib/buildr/core/transports.rb
index af89a95..37baece 100644
--- a/lib/buildr/core/transports.rb
+++ b/lib/buildr/core/transports.rb
@@ -270,6 +270,10 @@ module URI
     def read(options = nil, &block)
       options ||= {}
       connect do |http|
+        # it's possible we may see :read_timeout => nil, so check for the key..
+        if options.key?(:read_timeout)
+          http.read_timeout = options[:read_timeout]
+        end
         trace "Requesting #{self}"
         headers = { 'If-Modified-Since' => CGI.rfc1123_date(options[:modified].utc) } if options[:modified]
         request = Net::HTTP::Get.new(request_uri.empty? ? '/' : request_uri, headers)
diff --git a/lib/buildr/packaging/artifact.rb b/lib/buildr/packaging/artifact.rb
index 970d02b..e45f91b 100644
--- a/lib/buildr/packaging/artifact.rb
+++ b/lib/buildr/packaging/artifact.rb
@@ -463,7 +463,7 @@ module Buildr
       begin
         metadata_path = "#{group_path}/#{id}/#{version}/maven-metadata.xml"
         metadata_xml = StringIO.new
-        URI.download repo_url + metadata_path, metadata_xml
+        URI.download repo_url + metadata_path, metadata_xml, Buildr.options.download
         metadata = REXML::Document.new(metadata_xml.string).root
         timestamp = REXML::XPath.first(metadata, '//timestamp')
         build_number = REXML::XPath.first(metadata, '//buildNumber')

Reply via email to