Return-Path: Delivered-To: apmail-buildr-users-archive@www.apache.org Received: (qmail 69307 invoked from network); 27 Feb 2010 13:30:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Feb 2010 13:30:43 -0000 Received: (qmail 15805 invoked by uid 500); 27 Feb 2010 13:30:43 -0000 Delivered-To: apmail-buildr-users-archive@buildr.apache.org Received: (qmail 15754 invoked by uid 500); 27 Feb 2010 13:30:43 -0000 Mailing-List: contact users-help@buildr.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@buildr.apache.org Delivered-To: mailing list users@buildr.apache.org Received: (qmail 15746 invoked by uid 99); 27 Feb 2010 13:30:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Feb 2010 13:30:42 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [209.85.219.214] (HELO mail-ew0-f214.google.com) (209.85.219.214) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Feb 2010 13:30:34 +0000 Received: by ewy6 with SMTP id 6so606438ewy.37 for ; Sat, 27 Feb 2010 05:30:11 -0800 (PST) Received: by 10.213.109.86 with SMTP id i22mr1234890ebp.51.1267277411656; Sat, 27 Feb 2010 05:30:11 -0800 (PST) Received: from mail-ew0-f214.google.com (mail-ew0-f214.google.com [209.85.219.214]) by mx.google.com with ESMTPS id 16sm715496ewy.3.2010.02.27.05.30.08 (version=SSLv3 cipher=RC4-MD5); Sat, 27 Feb 2010 05:30:10 -0800 (PST) Received: by ewy6 with SMTP id 6so606415ewy.37 for ; Sat, 27 Feb 2010 05:30:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.213.99.135 with SMTP id u7mr980697ebn.36.1267277408015; Sat, 27 Feb 2010 05:30:08 -0800 (PST) In-Reply-To: <4dcd15a91002260958v10a6642cr8dd61fa914469a85@mail.gmail.com> References: <4dcd15a91002260958v10a6642cr8dd61fa914469a85@mail.gmail.com> Date: Sat, 27 Feb 2010 14:30:07 +0100 Message-ID: Subject: Re: Patch for artifact.from From: Anders Janmyr To: users@buildr.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Ok, thanks, I'll take a look at it. Anders On Fri, Feb 26, 2010 at 6:58 PM, Alex Boisvert wr= ote: > Looking into it again this morning, I finally found the mysterious cause = of > the different behavior I was getting earlier. =A0Turns out that Rake's fi= le() > method returns a FileTask with a relative path whereas Buildr's file() > method returns a FileTask with an absolute path. =A0 So you get different > result if you call file() inside or outside of a project and pass this as > argument to artifact().from(). > > I've also fixed the issue about the artifact being re-downloaded every ti= me > even if it exists. > > For now, I've attached the patch to > http://issues.apache.org/jira/browse/BUILDR-383. =A0 I didn't commit it y= et > since I can't run the specs successfully on my laptop since my upgrade to > rubygems 1.3.6. =A0 I'll commit once I've tested it on a different system= . > > Could you give it a try to make sure it addresses your issue? > > thanks, > alex > > > On Fri, Feb 26, 2010 at 3:24 AM, Anders Janmyr = wrote: > >> Hi, >> >> I have made changes to allow you to write code like this >> >> =A0google_zip =3D download "target/google-collect-1.0.zip" =3D> >> =A0 =A0 =A0 =A0 =A0' >> http://google-collections.googlecode.com/files/google-collect-1.0.zip' >> =A0google_jar =3D file("target/zip/google-collect-1.0/google-collect-1.0= .jar" >> =3D> >> =A0 =A0 =A0 =A0 =A0unzip('target/zip'=3D>google_zip)) >> =A0google_artifact =3D >> artifact('google:google-collect:jar:1.0').from(google_jar) >> >> =A0define 'core' do >> =A0 =A0compile.with 'commons-lang:commons-lang:jar:2.4', google_artifact >> =A0 =A0package :jar >> =A0end >> >> instead of code like this. >> >> google_artifact =3D artifact('google:google-collect:jar:1.0').tap do |a| >> =A0 =A0unless a.exist? >> =A0 =A0 =A0google_zip =3D download "target/google-collect-1.0.zip" =3D> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0' >> http://google-collections.googlecode.com/files/google-collect-1.0.zip' >> =A0 =A0 =A0google_jar =3D >> file("target/zip/google-collect-1.0/google-collect-1.0.jar" =3D> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0unzip('target/zip'=3D>google_zip)) >> =A0 =A0 =A0a.from(google_jar) >> =A0 end >> =A0end >> >> >> I cannot however get the tests to work the way I want. >> >> >> The patch is below, I'll attach it to an issue, if you are interested >> in it. The failing tests are also in the patch. >> >> Anders >> >> From 5b0247315fceadb544af92812c269a0fa417c5b3 Mon Sep 17 00:00:00 2001 >> From: Anders Janmyr >> Date: Fri, 26 Feb 2010 12:12:48 +0100 >> Subject: [PATCH] artifact.from should only be invoked when needed. >> >> * It is only needed if the file it is dependent on is newer >> or if the artifact does not exist at all. >> * If the artifact exists, but the dependent file does not, >> skip the dependency. >> --- >> =A0lib/buildr/packaging/artifact.rb | =A0 26 ++++++++++++++++---------- >> =A0spec/packaging/artifact_spec.rb =A0| =A0 17 +++++++++++++++++ >> =A02 files changed, 33 insertions(+), 10 deletions(-) >> >> diff --git a/lib/buildr/packaging/artifact.rb >> b/lib/buildr/packaging/artifact.rb >> index e3ee045..6d3df6d 100644 >> --- a/lib/buildr/packaging/artifact.rb >> +++ b/lib/buildr/packaging/artifact.rb >> @@ -315,6 +315,10 @@ module Buildr >> =A0 =A0 =A0 end >> =A0 =A0 end >> >> + =A0 =A0def up_to_date_compared_to?(path) >> + =A0 =A0 =A0File.exists?(path) ? test(?<, path, name) : File.exist?(nam= e) >> + =A0 =A0end >> + >> =A0 =A0 # :call-seq: >> =A0 =A0 # =A0 from(path) =3D> self >> =A0 =A0 # >> @@ -324,16 +328,18 @@ module Buildr >> =A0 =A0 # See also Buildr#install and Buildr#upload. >> =A0 =A0 def from(path) >> =A0 =A0 =A0 path =3D File.expand_path(path.to_s) >> - =A0 =A0 =A0enhance [path] do >> - =A0 =A0 =A0 =A0mkpath File.dirname(name) >> - =A0 =A0 =A0 =A0pom.invoke unless type =3D=3D :pom >> - =A0 =A0 =A0 =A0cp path, name >> - =A0 =A0 =A0 =A0info "Installed #{path} as #{to_spec}" >> - =A0 =A0 =A0end >> - =A0 =A0 =A0unless type =3D=3D :pom >> - =A0 =A0 =A0 =A0pom.enhance do >> - =A0 =A0 =A0 =A0 =A0mkpath File.dirname(pom.name) >> - =A0 =A0 =A0 =A0 =A0File.open(pom.name, 'w') { |file| file.write pom.po= m_xml } >> + =A0 =A0 =A0unless up_to_date_compared_to?(path) >> + =A0 =A0 =A0 =A0enhance [path] do >> + =A0 =A0 =A0 =A0 =A0mkpath File.dirname(name) >> + =A0 =A0 =A0 =A0 =A0pom.invoke unless type =3D=3D :pom >> + =A0 =A0 =A0 =A0 =A0cp path, name >> + =A0 =A0 =A0 =A0 =A0info "Installed #{path} as #{to_spec}" >> + =A0 =A0 =A0 =A0end >> + =A0 =A0 =A0 =A0unless type =3D=3D :pom >> + =A0 =A0 =A0 =A0 =A0pom.enhance do >> + =A0 =A0 =A0 =A0 =A0 =A0mkpath File.dirname(pom.name) >> + =A0 =A0 =A0 =A0 =A0 =A0File.open(pom.name, 'w') { |file| file.write po= m.pom_xml } >> + =A0 =A0 =A0 =A0 =A0end >> =A0 =A0 =A0 =A0 end >> =A0 =A0 =A0 end >> =A0 =A0 =A0 self >> diff --git a/spec/packaging/artifact_spec.rb >> b/spec/packaging/artifact_spec.rb >> index 42e7b9c..45839f2 100644 >> --- a/spec/packaging/artifact_spec.rb >> +++ b/spec/packaging/artifact_spec.rb >> @@ -429,6 +429,23 @@ describe Buildr, '#artifact' do >> =A0 =A0 lambda { artifact.invoke }.should change { >> File.exist?(artifact.to_s) }.to(true) >> =A0 end >> >> + >> + =A0it 'should trigger from dependency if not installed' do >> + =A0 =A0file =3D 'test.jar' >> + =A0 =A0touch file >> + =A0 =A0artifact =3D artifact('group:id:jar:1.0').from(file) >> + =A0 =A0lambda { artifact.invoke }.should change { >> artifact.up_to_date_compared_to?(file) }.to(true) >> + =A0end >> + >> + =A0it 'should not trigger from dependency if installed' do >> + =A0 =A0file =3D 'test.jar' >> + =A0 =A0touch file >> + =A0 =A0artifact =3D artifact('group:id:jar:1.0').from(file) >> + =A0 =A0lambda { artifact.invoke }.should change { >> artifact.up_to_date_compared_to?(file) }.to(true) >> + =A0 =A0lambda { artifact.invoke }.should_not change { >> artifact.up_to_date_compared_to?(file) }.to(true) >> + =A0end >> + >> + >> =A0 it 'should reference artifacts defined on build.yaml by using ruby >> symbols' do >> =A0 =A0 write 'build.yaml', <<-YAML >> =A0 =A0 =A0 artifacts: >> -- >> 1.6.6 >> >> >> >> >> -- >> http://anders.janmyr.com/ >> > --=20 http://anders.janmyr.com/