buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toulm...@apache.org
Subject svn commit: r951662 - in /buildr/trunk: CHANGELOG lib/buildr/packaging/artifact.rb spec/packaging/packaging_spec.rb
Date Sat, 05 Jun 2010 06:53:22 GMT
Author: toulmean
Date: Sat Jun  5 06:53:21 2010
New Revision: 951662

URL: http://svn.apache.org/viewvc?rev=951662&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/spec/packaging/packaging_spec.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=951662&r1=951661&r2=951662&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sat Jun  5 06:53:21 2010
@@ -95,6 +95,7 @@
           Java.classpath
 * Fixed:  BUILDR-373 Package type specific implementations of install, 
           uninstall and upload are not invoked (Antoine Toulme)
+* Fixed:  BUILDR-374 upload tasks can attempt to upload artifacts multiple times (Pepijn
Van Eeckhoudt)
 * Fixed:  BUILDR-379 Ant sql task abruptly terminates buildr
 * Fixed:  BUILDR-380 GitRelease: recursive search for root '/' does not work
           under Windows (Antoine Toulme)

Modified: buildr/trunk/lib/buildr/packaging/artifact.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/artifact.rb?rev=951662&r1=951661&r2=951662&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/artifact.rb (original)
+++ buildr/trunk/lib/buildr/packaging/artifact.rb Sat Jun  5 06:53:21 2010
@@ -171,14 +171,13 @@ module Buildr
     # 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.
@@ -187,10 +186,19 @@ module Buildr
       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
@@ -770,11 +778,10 @@ module Buildr
   def upload(*args, &block)
     artifacts = artifacts(args)
     raise ArgumentError, 'This method can only upload artifacts' unless artifacts.all? {
|f| f.respond_to?(:to_spec) }
+    upload_artifacts_tasks = artifacts.map { |artifact| artifact.upload_task }
     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/spec/packaging/packaging_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/packaging_spec.rb?rev=951662&r1=951661&r2=951662&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/packaging_spec.rb (original)
+++ buildr/trunk/spec/packaging/packaging_spec.rb Sat Jun  5 06:53:21 2010
@@ -654,6 +654,24 @@ describe Rake::Task, ' upload' do
       read(upload).should eql(read(package))
     end
   end
+  
+  it 'should not upload twice the pom when artifacts are uploaded from a project' do
+    write 'src/main/java/Foo.java', 'public class Foo {}'
+    repositories.release_to = 'sftp://example.com/base'
+    define 'foo' do 
+      project.group = "attached" 
+      project.version = "1.0" 
+      package(:jar) 
+      package(:sources) 
+    end
+     URI.should_receive(:upload).exactly(:once).
+         with(URI.parse('sftp://example.com/base/attached/foo/1.0/foo-1.0-sources.jar'),
project("foo").package(:sources).to_s, anything)
+     URI.should_receive(:upload).exactly(:once).
+         with(URI.parse('sftp://example.com/base/attached/foo/1.0/foo-1.0.jar'), project("foo").package(:jar).to_s,
anything)
+     URI.should_receive(:upload).exactly(:once).
+        with(URI.parse('sftp://example.com/base/attached/foo/1.0/foo-1.0.pom'), project("foo").package(:jar).pom.to_s,
anything)
+     verbose(false) { project("foo").upload.invoke }
+  end
 
   it 'should upload signatures for artifact and POM' do
     define('foo', :version=>'1.0') { package :jar }



Mime
View raw message