Return-Path: Delivered-To: apmail-buildr-commits-archive@www.apache.org Received: (qmail 88201 invoked from network); 13 Aug 2010 06:09:17 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Aug 2010 06:09:17 -0000 Received: (qmail 94654 invoked by uid 500); 13 Aug 2010 06:09:17 -0000 Delivered-To: apmail-buildr-commits-archive@buildr.apache.org Received: (qmail 94624 invoked by uid 500); 13 Aug 2010 06:09:16 -0000 Mailing-List: contact commits-help@buildr.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@buildr.apache.org Delivered-To: mailing list commits@buildr.apache.org Received: (qmail 94615 invoked by uid 99); 13 Aug 2010 06:09:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Aug 2010 06:09:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Aug 2010 06:09:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 0CC3A23889B9; Fri, 13 Aug 2010 06:07:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@buildr.apache.org From: toulmean@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100813060758.0CC3A23889B9@eris.apache.org> 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 + + + com.example + library + 2.1-SNAPSHOT + + + 8 + + 20071012190008 + + + 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 + + + com.example + library + 2.1-SNAPSHOT + + + 20071012.190008 + + 20071012190008 + + + 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'