You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by bo...@apache.org on 2010/02/27 23:16:13 UTC

svn commit: r917061 - in /buildr/trunk: CHANGELOG lib/buildr/packaging/artifact.rb spec/packaging/artifact_spec.rb

Author: boisvert
Date: Sat Feb 27 22:16:12 2010
New Revision: 917061

URL: http://svn.apache.org/viewvc?rev=917061&view=rev
Log:
BUILDR-383 artifact().from(task_dependency) should not trigger task_dependency if artifact exists
(specs graciously provided by Antoine Toulme)


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=917061&r1=917060&r2=917061&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sat Feb 27 22:16:12 2010
@@ -49,6 +49,8 @@
 * Fixed:  BUILDR-365 test task should use test compile dependencies
 * Fixed:  BUILDR-366 Scala dependencies should be lazily loaded into
           Java.classpath
+* Fixed:  BUILDR-383 artifact().from(task_dependency) should not trigger 
+          task_dependency if artifact exists
 * Fixed:  BUILDR-384 Buildr fails with rubygems 1.3.6
 * Fixed:  Fail-fast if package.with() or include() called with nil values
 * Fixed:  Failures not reported correctly for ScalaTest (Alex Eagle)

Modified: buildr/trunk/lib/buildr/packaging/artifact.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/artifact.rb?rev=917061&r1=917060&r2=917061&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/artifact.rb (original)
+++ buildr/trunk/lib/buildr/packaging/artifact.rb Sat Feb 27 22:16:12 2010
@@ -323,19 +323,25 @@
     #   install test
     # See also Buildr#install and Buildr#upload.
     def from(path)
-      path = File.expand_path(path.to_s)
-      enhance [path] do
-        mkpath File.dirname(name)
-        pom.invoke unless type == :pom
-        cp path, name
-        info "Installed #{path} as #{to_spec}"
+      path = path.is_a?(Rake::Task) ? path : File.expand_path(path.to_s)
+      unless exist?
+        enhance [path] do
+          path = File.expand_path(path.to_s)
+          mkpath File.dirname(name)
+          pom.invoke unless type == :pom
+          
+          cp path, name
+          info "Installed #{path} as #{to_spec}"
+        end
       end
       unless type == :pom
         pom.enhance do
+          unless pom.exist?
           mkpath File.dirname(pom.name)
           File.open(pom.name, 'w') { |file| file.write pom.pom_xml }
         end
       end
+      end
       self
     end
 

Modified: buildr/trunk/spec/packaging/artifact_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/artifact_spec.rb?rev=917061&r1=917060&r2=917061&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/artifact_spec.rb (original)
+++ buildr/trunk/spec/packaging/artifact_spec.rb Sat Feb 27 22:16:12 2010
@@ -428,6 +428,40 @@
     artifact = artifact('group:id:jar:1.0').from('test.jar')
     lambda { artifact.invoke }.should change { File.exist?(artifact.to_s) }.to(true)
   end
+  
+  it 'should use from method to install artifact from a file task' do
+    test_jar = file('test.jar')
+    test_jar.enhance do
+      #nothing...
+    end
+    write 'test.jar'
+    artifact = artifact('group:id:jar:1.0').from(test_jar)
+    lambda { artifact.invoke }.should change { File.exist?(artifact.to_s) }.to(true)
+  end
+  
+  it 'should invoke the artifact associated file task if the file doesnt exist' do
+    test_jar = file('test.jar')
+    called = false
+    test_jar.enhance do
+      write 'test.jar'
+      called = true
+    end
+    artifact = artifact('group:id:jar:1.0').from(test_jar)
+    artifact.invoke
+    unless called 
+      raise "The file task was not called."
+    end
+  end
+  
+  it 'should not invoke the artifact associated file task if the file already exists' do
+    test_jar = file('test.jar')
+    test_jar.enhance do
+      raise 'the test.jar file is created again!'
+    end
+    write 'test.jar'
+    artifact = artifact('group:id:jar:1.0').from(test_jar)
+    artifact.invoke
+  end
 
   it 'should reference artifacts defined on build.yaml by using ruby symbols' do
     write 'build.yaml', <<-YAML