# File lib/buildr/packaging/artifact.rb, line 195
    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]

      # 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.
      uri = URI.parse(upload_to[:url].clone)
      uri.path = uri.path + '/' unless uri.path[-1] == '/'
      uri.user = upload_to[:username] if upload_to[:username]
      uri.password = upload_to[:password] if upload_to[:password]

      path = group.gsub('.', '/') + "/#{id}/#{version}/#{File.basename(name)}"

      unless task = Buildr.application.lookup(uri+path)
        deps = [self]
        deps << pom.upload_task( upload_to ) if pom && pom != self && classifier.nil?

        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