buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r915688 - in /buildr/trunk: CHANGELOG lib/buildr/packaging/artifact.rb lib/buildr/packaging/package.rb
Date Wed, 24 Feb 2010 05:45:03 GMT
Author: boisvert
Date: Wed Feb 24 05:45:02 2010
New Revision: 915688

URL: http://svn.apache.org/viewvc?rev=915688&view=rev
Log:
BUILDR-374 upload tasks can attempt to upload artifacts multiple times (Pepijn Van Eeckhoudt)


Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/packaging/artifact.rb
    buildr/trunk/lib/buildr/packaging/package.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=915688&r1=915687&r2=915688&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Wed Feb 24 05:45:02 2010
@@ -49,6 +49,8 @@
 * Fixed:  BUILDR-365 test task should use test compile dependencies
 * Fixed:  BUILDR-366 Scala dependencies should be lazily loaded into
           Java.classpath
+* Fixed:  BUILDR-374 upload tasks can attempt to upload artifacts multiple times
+          (Pepijn Van Eeckhoudt)
 * Fixed:  Fail-fast if package.with() or include() called with nil values
 * Fixed:  Failures not reported correctly for ScalaTest (Alex Eagle)
 * Fixed:  Test dependencies should include test compile dependencies

Modified: buildr/trunk/lib/buildr/packaging/artifact.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/artifact.rb?rev=915688&r1=915687&r2=915688&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/artifact.rb (original)
+++ buildr/trunk/lib/buildr/packaging/artifact.rb Wed Feb 24 05:45:02 2010
@@ -153,14 +153,13 @@
     # In the third form, uses a hash with the options :url, :username, :password,
     # and :permissions. All but :url are optional.
     def upload(upload_to = nil)
-      # Where do we release to?
+      upload_task(upload_to).invoke
+    end
+
+    def upload_task(upload_to = nil)
       upload_to ||= Buildr.repositories.release_to
       upload_to = { :url=>upload_to } unless Hash === upload_to
       raise ArgumentError, 'Don\'t know where to upload, perhaps you forgot to set repositories.release_to'
unless upload_to[:url]
-      invoke # Make sure we exist.
-
-      # Upload POM ahead of package, so we don't fail and find POM-less package (the horror!)
-      pom.upload(upload_to) if pom && pom != self
 
       # Set the upload URI, including mandatory slash (we expect it to be the base directory).
       # Username/password may be part of URI, or separate entities.
@@ -169,10 +168,19 @@
       uri.user = upload_to[:username] if upload_to[:username]
       uri.password = upload_to[:password] if upload_to[:password]
 
-      # Upload artifact relative to base URL, need to create path before uploading.
-      info "Deploying #{to_spec}"
       path = group.gsub('.', '/') + "/#{id}/#{version}/#{File.basename(name)}"
-      URI.upload uri + path, name, :permissions=>upload_to[:permissions]
+
+      unless task = Buildr.application.lookup(uri+path)
+        deps = [self]
+        deps << pom.upload_task( upload_to ) if pom && pom != self
+
+        task = Rake::Task.define_task uri + path => deps do
+          # Upload artifact relative to base URL, need to create path before uploading.
+          info "Deploying #{to_spec}"
+          URI.upload uri + path, name, :permissions=>upload_to[:permissions]
+        end
+      end
+      task
     end
 
   protected
@@ -737,13 +745,11 @@
   #   upload artifact('group:id:jar:1.0').from('some_jar.jar')
   #   $ buildr upload
   def upload(*args, &block)
-    artifacts = artifacts(args)
+    upload_artifacts_tasks = artifacts(args).map { |artifact| artifact.upload_task }
     raise ArgumentError, 'This method can only upload artifacts' unless artifacts.all? {
|f| f.respond_to?(:to_spec) }
     task('upload').tap do |task|
       task.enhance &block if block
-      task.enhance artifacts do
-        artifacts.each { |artifact| artifact.upload }
-      end
+      task.enhance upload_artifacts_tasks
     end
   end
 

Modified: buildr/trunk/lib/buildr/packaging/package.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/package.rb?rev=915688&r1=915687&r2=915688&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/package.rb (original)
+++ buildr/trunk/lib/buildr/packaging/package.rb Wed Feb 24 05:45:02 2010
@@ -192,7 +192,7 @@
 
         task('install')   { package.install if package.respond_to?(:install) }
         task('uninstall') { package.uninstall if package.respond_to?(:uninstall) }
-        task('upload')    { package.upload if package.respond_to?(:upload) }
+        task('upload' => package.upload_task ) if package.respond_to?(:upload_task)
 
         packages << package
       end



Mime
View raw message