Author: boisvert
Date: Fri Sep 24 00:52:05 2010
New Revision: 1000680

URL: http://svn.apache.org/viewvc?rev=1000680&view=rev
Log:
BUILDR-515 -update-snapshot doesn't work as expected
Turns out we had a bug in the spec test :(

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=1000680&r1=1000679&r2=1000680&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Fri Sep 24 00:52:05 2010
@@ -3,6 +3,7 @@
 * Fixed:  BUILDR-512 Buildr::Util.ruby invokes non existent method (Peter 
Donald)
 * Fixed:  BUILDR-513 --trace fails with NoMethodError : undefined method 
           `include?' for nil:NilClass
+* Fixed:  BUILDR-515 -update-snapshot doesn't work as expected
 
 1.4.2 (2010-09-18)
 * Added:  BUILDR-415 Ability to exclude tests from command line

Modified: buildr/trunk/lib/buildr/packaging/artifact.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/artifact.rb?rev=1000680&r1=1000679&r2=1000680&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/artifact.rb (original)
+++ buildr/trunk/lib/buildr/packaging/artifact.rb Fri Sep 24 00:52:05 2010
@@ -488,23 +488,23 @@ module Buildr
     end
 
    protected
-  
+
     # :call-seq:
     #   needed?
     #
     # Validates whether artifact is required to be downloaded from repository
     def needed?
-      return true if snapshot? && File.exist?(name) && old?
-      super      
+      return true if snapshot? && File.exist?(name) && (update_snapshot? || 
old?)
+      super
     end
-    
+
   private
-  
+
     # :call-seq:
     #   download_artifact
     #
-    # Downloads artifact from given repository, 
-    # supports downloading snapshot artifact with relocation on succeed to 
local repository 
+    # Downloads artifact from given repository,
+    # supports downloading snapshot artifact with relocation on succeed to 
local repository
     def download_artifact(path)
       download_file = "#{name}.#{Time.new.to_i}"
       begin
@@ -517,7 +517,7 @@ module Buildr
         File.delete(download_file) if File.exist?(download_file)
       end
     end
-    
+
     # :call-seq:
     #   :download_needed?
     #
@@ -529,22 +529,22 @@ module Buildr
         return false if offline? && File.exist?(name)
         return true if update_snapshot? || old?
       end
-      
+
       return false
     end
-    
+
     def update_snapshot?
       Buildr.application.options.update_snapshots
     end
-    
+
     def offline?
       Buildr.application.options.work_offline
     end
-    
+
     # :call-seq:
     #   old?
     #
-    # Checks whether existing artifact is older than period from build 
settings or one day 
+    # Checks whether existing artifact is older than period from build 
settings or one day
     def old?
       settings = Buildr.application.settings
       time_to_be_old = settings.user[:expire_time] || 
settings.build[:expire_time] || 60 * 60 * 24
@@ -757,7 +757,7 @@ module Buildr
       Rake::Task['rake:artifacts'].enhance [task]
       Artifact.register(task)
       unless spec[:type] == :pom
-        Rake::Task['artifacts:sources'].enhance [task.sources_artifact] 
+        Rake::Task['artifacts:sources'].enhance [task.sources_artifact]
         Rake::Task['artifacts:javadoc'].enhance [task.javadoc_artifact]
       end
     end

Modified: buildr/trunk/spec/packaging/artifact_spec.rb
URL: 
http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/artifact_spec.rb?rev=1000680&r1=1000679&r2=1000680&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/artifact_spec.rb (original)
+++ buildr/trunk/spec/packaging/artifact_spec.rb Fri Sep 24 00:52:05 2010
@@ -299,7 +299,7 @@ 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'?>
@@ -325,7 +325,7 @@ describe Repositories, 'remote' do
     }.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'?>
@@ -465,10 +465,10 @@ end
 
 
 describe Buildr, '#artifact' do
-  before do 
+  before do
     @spec = { :group=>'com.example', :id=>'library', :type=>'jar', 
:version=>'2.0' }
     @snapshot_spec = 'group:id:jar:1.0-SNAPSHOT'
-    write @file = 'testartifact.jar' 
+    write @file = 'testartifact.jar'
   end
 
   it 'should accept hash specification' do
@@ -556,11 +556,11 @@ describe Buildr, '#artifact' do
     Buildr.application.send(:load_artifact_ns)
     artifact(:j2ee).to_s.pathmap('%f').should == 
'geronimo-spec-j2ee-1.4-rc4.jar'
   end
-  
+
   it 'should try to download snapshot artifact' do
     run_with_repo
     snapshot = artifact(@snapshot_spec)
-    
+
     URI.should_receive(:download).at_least(:twice).and_return { |uri, target, 
options| write target }
     FileUtils.should_receive(:mv).at_least(:twice)
     snapshot.invoke
@@ -574,7 +574,7 @@ describe Buildr, '#artifact' do
     URI.should_receive(:download).exactly(0).times
     snapshot.invoke
   end
-  
+
   it 'should download snapshot even in offline mode if it doesn''t exist' do
     run_with_repo
     snapshot = artifact(@snapshot_spec)
@@ -582,17 +582,18 @@ describe Buildr, '#artifact' do
     URI.should_receive(:download).exactly(2).times
     snapshot.invoke
   end
-  
+
   it 'should update snapshots if --update-snapshots' do
     run_with_repo
     snapshot = artifact(@snapshot_spec)
+    write snapshot.to_s
     Buildr.application.options.update_snapshots = true
-    
+
     URI.should_receive(:download).at_least(:twice).and_return { |uri, target, 
options| write target }
     FileUtils.should_receive(:mv).at_least(:twice)
     snapshot.invoke
   end
-  
+
   it 'should update snapshot if it''s older than 24 hours' do
     run_with_repo
     snapshot = artifact(@snapshot_spec)
@@ -602,11 +603,11 @@ describe Buildr, '#artifact' do
     URI.should_receive(:download).at_least(:once).and_return { |uri, target, 
options| write target }
     snapshot.invoke
   end
-  
+
   def run_with_repo
     repositories.remote = 'http://example.com'
   end
-  
+
 end
 
 
@@ -730,13 +731,13 @@ describe Buildr, '#install' do
     sleep 1; write @file       # make sure the "from" file has newer 
modification time
     lambda { install.invoke }.should change { modified?(old_mtime, 
@snapshot_spec) }.to(true)
   end
-  
+
   it 'should download snapshot to temporary location' do
     repositories.remote = 'http://example.com'
     snapshot = artifact(@snapshot_spec)
     same_time = Time.new
     download_file = 
"#{Dir.tmpdir}/#{File.basename(snapshot.name)}#{same_time.to_i}"
-    
+
     Time.should_receive(:new).twice.and_return(same_time)
     URI.should_receive(:download).at_least(:twice).and_return { |uri, target, 
options| write target }
     FileUtils.should_receive(:mv).at_least(:twice)


Reply via email to