Fix the regression : a maven_metadata.xml file was written to disk when uploading
Project: http://git-wip-us.apache.org/repos/asf/buildr/repo Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/cb629a4f Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/cb629a4f Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/cb629a4f Branch: refs/heads/master Commit: cb629a4f40d73917d15988b93f697e99dff588b9 Parents: cd239ee Author: Antoine Toulme <[email protected]> Authored: Sun Aug 21 14:46:06 2016 -0700 Committer: Antoine Toulme <[email protected]> Committed: Sun Aug 21 14:46:06 2016 -0700 ---------------------------------------------------------------------- lib/buildr/packaging/artifact.rb | 3 +-- spec/packaging/artifact_spec.rb | 15 +++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/buildr/blob/cb629a4f/lib/buildr/packaging/artifact.rb ---------------------------------------------------------------------- diff --git a/lib/buildr/packaging/artifact.rb b/lib/buildr/packaging/artifact.rb index 97c5de3..c58fb38 100644 --- a/lib/buildr/packaging/artifact.rb +++ b/lib/buildr/packaging/artifact.rb @@ -241,7 +241,7 @@ module Buildr #:nodoc: URI.upload uri + path, name, options if snapshot? && pom != self maven_metadata = group.gsub('.', '/') + "/#{id}/#{version}/#{MAVEN_METADATA}" - URI.upload uri + maven_metadata, MAVEN_METADATA, :permissions => upload_to[:permissions] + URI.write uri + maven_metadata, maven_metadata_xml, :permissions => upload_to[:permissions] end end end @@ -436,7 +436,6 @@ module Buildr #:nodoc: unless @content enhance do write name, self.content - write MAVEN_METADATA, maven_metadata_xml if snapshot? end class << self http://git-wip-us.apache.org/repos/asf/buildr/blob/cb629a4f/spec/packaging/artifact_spec.rb ---------------------------------------------------------------------- diff --git a/spec/packaging/artifact_spec.rb b/spec/packaging/artifact_spec.rb index c4ac5a3..947baf0 100644 --- a/spec/packaging/artifact_spec.rb +++ b/spec/packaging/artifact_spec.rb @@ -998,6 +998,7 @@ end describe ActsAsArtifact, '#upload' do + it 'should be used to upload artifact' do artifact = artifact('com.example:library:jar:2.0') # Prevent artifact from downloading anything. @@ -1040,8 +1041,8 @@ describe ActsAsArtifact, '#upload' do with(URI.parse('sftp://example.com/base/com/example/library/2.0-SNAPSHOT/library-2.0-20110311.140236-1.pom'), artifact.pom.to_s, anything) URI.should_receive(:upload).once. with(URI.parse('sftp://example.com/base/com/example/library/2.0-SNAPSHOT/library-2.0-20110311.140236-1.jar'), artifact.to_s, anything) - URI.should_receive(:upload).once. - with(URI.parse('sftp://example.com/base/com/example/library/2.0-SNAPSHOT/maven_metadata.xml'), "maven_metadata.xml", anything) + URI.should_receive(:write).once. + with(URI.parse('sftp://example.com/base/com/example/library/2.0-SNAPSHOT/maven_metadata.xml'), anything, anything) verbose(false) { artifact.upload(:url=>'sftp://example.com/base') } end @@ -1067,8 +1068,8 @@ describe ActsAsArtifact, '#upload' do with(URI.parse('sftp://buildr.apache.org/repository/noexist/base/com/example/library/2.0-SNAPSHOT/library-2.0-20161111.140236-1.pom'), artifact.pom.to_s, anything) URI.should_receive(:upload).once. with(URI.parse('sftp://buildr.apache.org/repository/noexist/base/com/example/library/2.0-SNAPSHOT/library-2.0-20161111.140236-1.jar'), artifact.to_s, anything) - URI.should_receive(:upload).once. - with(URI.parse('sftp://buildr.apache.org/repository/noexist/base/com/example/library/2.0-SNAPSHOT/maven_metadata.xml'), "maven_metadata.xml", anything) + URI.should_receive(:write).once. + with(URI.parse('sftp://buildr.apache.org/repository/noexist/base/com/example/library/2.0-SNAPSHOT/maven_metadata.xml'), anything, anything) repositories.release_to = 'sftp://buildr.apache.org/repository/noexist/base' artifact.upload lambda { artifact.upload }.should_not raise_error @@ -1085,8 +1086,8 @@ describe ActsAsArtifact, '#upload' do with(URI.parse('sftp://buildr.apache.org/repository/noexist/snapshot/com/example/library/2.0-SNAPSHOT/library-2.0-20161111.140236-1.pom'), artifact.pom.to_s, anything) URI.should_receive(:upload).once. with(URI.parse('sftp://buildr.apache.org/repository/noexist/snapshot/com/example/library/2.0-SNAPSHOT/library-2.0-20161111.140236-1.jar'), artifact.to_s, anything) - URI.should_receive(:upload).once. - with(URI.parse('sftp://buildr.apache.org/repository/noexist/snapshot/com/example/library/2.0-SNAPSHOT/maven_metadata.xml'), "maven_metadata.xml", anything) + URI.should_receive(:write).once. + with(URI.parse('sftp://buildr.apache.org/repository/noexist/snapshot/com/example/library/2.0-SNAPSHOT/maven_metadata.xml'), anything, anything) repositories.release_to = 'sftp://buildr.apache.org/repository/noexist/base' repositories.snapshot_to = 'sftp://buildr.apache.org/repository/noexist/snapshot' artifact.upload @@ -1101,8 +1102,6 @@ describe ActsAsArtifact, '#upload' do repositories.snapshot_to = 'sftp://buildr.apache.org/repository/noexist/snapshot' lambda { artifact.upload }.should raise_error(Exception, /where to upload/) end - - end
