buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toulm...@apache.org
Subject svn commit: r985101 - in /buildr/trunk: CHANGELOG lib/buildr/packaging/artifact.rb spec/packaging/artifact_spec.rb
Date Fri, 13 Aug 2010 06:07:57 GMT
Author: toulmean
Date: Fri Aug 13 06:07:57 2010
New Revision: 985101

URL: http://svn.apache.org/viewvc?rev=985101&view=rev
Log:
BUILDR-477 Error while parsing maven-metadata.xml

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/packaging/artifact.rb
    buildr/trunk/spec/packaging/artifact_spec.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=985101&r1=985100&r2=985101&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Fri Aug 13 06:07:57 2010
@@ -22,6 +22,7 @@
 * Fixed:  BUILDR-468 test:failed does not respect test.exclude
 * Fixed:  BUILDR-469 test:failed causes all transitive tests to run
 * Fixed:  BUILDR-472 ECJ dependency now required to build any java project
+* Fixed:  BUILDR-477 Error while parsing maven-metadata.xml
 * Fixed:  BUILDR-479 Enforce using a minimal version of jruby
 * Fixed:  BUILDR-481 Antwrap monkey-patching in core.rb
 * Fixed:  BUILDR-488 artifact poms not reinstalled

Modified: buildr/trunk/lib/buildr/packaging/artifact.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/artifact.rb?rev=985101&r1=985100&r2=985101&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/artifact.rb (original)
+++ buildr/trunk/lib/buildr/packaging/artifact.rb Fri Aug 13 06:07:57 2010
@@ -455,10 +455,13 @@ module Buildr
         metadata_xml = StringIO.new
         URI.download repo_url + metadata_path, metadata_xml
         metadata = REXML::Document.new(metadata_xml.string).root
-        timestamp = REXML::XPath.first(metadata, '//timestamp').text
-        build_number = REXML::XPath.first(metadata, '//buildNumber').text
+        timestamp = REXML::XPath.first(metadata, '//timestamp')
+        build_number = REXML::XPath.first(metadata, '//buildNumber')
+        error "No timestamp provided for the snapshot #{to_spec}" if timestamp.nil?
+        error "No build number provided for the snapshot #{to_spec}" if build_number.nil?
+        return nil if timestamp.nil? || build_number.nil?
         snapshot_of = version[0, version.size - 9]
-        repo_url + "#{group_path}/#{id}/#{version}/#{id}-#{snapshot_of}-#{timestamp}-#{build_number}.#{type}"
+        repo_url + "#{group_path}/#{id}/#{version}/#{id}-#{snapshot_of}-#{timestamp.text}-#{build_number.text}.#{type}"
       rescue URI::NotFoundError
         nil
       end

Modified: buildr/trunk/spec/packaging/artifact_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/artifact_spec.rb?rev=985101&r1=985100&r2=985101&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/artifact_spec.rb (original)
+++ buildr/trunk/spec/packaging/artifact_spec.rb Fri Aug 13 06:07:57 2010
@@ -295,6 +295,58 @@ describe Repositories, 'remote' do
     lambda { artifact('com.example:library:jar:2.1-SNAPSHOT').invoke }.
       should change { File.exist?(File.join(repositories.local, 'com/example/library/2.1-SNAPSHOT/library-2.1-SNAPSHOT.jar'))
}.to(true)
   end
+  
+  it 'should fail resolving m2-style deployed snapshots if a timestamp is missing' do
+    metadata = <<-XML
+    <?xml version='1.0' encoding='UTF-8'?>
+    <metadata>
+      <groupId>com.example</groupId>
+      <artifactId>library</artifactId>
+      <version>2.1-SNAPSHOT</version>
+      <versioning>
+        <snapshot>
+          <buildNumber>8</buildNumber>
+        </snapshot>
+        <lastUpdated>20071012190008</lastUpdated>
+      </versioning>
+    </metadata>
+    XML
+    repositories.remote = 'http://example.com'
+    URI.should_receive(:download).once.with(uri(/2.1-SNAPSHOT\/library-2.1-SNAPSHOT.(jar|pom)$/),
anything()).
+      and_return { fail URI::NotFoundError }
+    URI.should_receive(:download).once.with(uri(/2.1-SNAPSHOT\/maven-metadata.xml$/), duck_type(:write)).
+      and_return { |uri, target, options| target.write(metadata) }
+    lambda {
+      lambda { artifact('com.example:library:jar:2.1-SNAPSHOT').invoke }.should raise_error(RuntimeError,
/Failed to download/)
+    }.should show_error "No timestamp provided for the snapshot com.example:library:jar:2.1-SNAPSHOT"
+    File.exist?(File.join(repositories.local, 'com/example/library/2.1-SNAPSHOT/library-2.1-SNAPSHOT.jar')).should
be_false
+  end
+  
+  it 'should fail resolving m2-style deployed snapshots if a build number is missing' do
+    metadata = <<-XML
+    <?xml version='1.0' encoding='UTF-8'?>
+    <metadata>
+      <groupId>com.example</groupId>
+      <artifactId>library</artifactId>
+      <version>2.1-SNAPSHOT</version>
+      <versioning>
+        <snapshot>
+          <timestamp>20071012.190008</timestamp>
+        </snapshot>
+        <lastUpdated>20071012190008</lastUpdated>
+      </versioning>
+    </metadata>
+    XML
+    repositories.remote = 'http://example.com'
+    URI.should_receive(:download).once.with(uri(/2.1-SNAPSHOT\/library-2.1-SNAPSHOT.(jar|pom)$/),
anything()).
+      and_return { fail URI::NotFoundError }
+    URI.should_receive(:download).once.with(uri(/2.1-SNAPSHOT\/maven-metadata.xml$/), duck_type(:write)).
+      and_return { |uri, target, options| target.write(metadata) }
+    lambda {
+      lambda { artifact('com.example:library:jar:2.1-SNAPSHOT').invoke }.should raise_error(RuntimeError,
/Failed to download/)
+    }.should show_error "No build number provided for the snapshot com.example:library:jar:2.1-SNAPSHOT"
+    File.exist?(File.join(repositories.local, 'com/example/library/2.1-SNAPSHOT/library-2.1-SNAPSHOT.jar')).should
be_false
+  end
 
   it 'should handle missing maven metadata by reporting the artifact unavailable' do
     repositories.remote = 'http://example.com'



Mime
View raw message