You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@buildr.apache.org by Timo Rantalaiho <Ti...@ri.fi> on 2008/11/27 17:00:39 UTC
Where in the Buildr codebase does it determine that it needs to start retrieving a dependency jar?
Hello, all,
I was fiddling with Buildr sources from trunk to see how to
achieve automatically refreshing snapshot dependencies
https://issues.apache.org/jira/browse/BUILDR-212
But I'm unsure of when does Buildr determine whether or not
to start downloading.
First I tried hooking into the downloading code in
artifact.rb, but it never gets that far when the snapshot
jar already exists in the local maven repo. Then I run
buildr artifacts --trace which was showing "not_needed" and
found a neeeded? method in packaging.rb, but that doesn't
seem to get called neither when the snapshot jar is already
present.
Any hints are much appreciated!
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
Re: Where in the Buildr codebase does it determine that it needs to start retrieving a dependency jar?
Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Thu, 27 Nov 2008, Victor Hugo Borja wrote:
> The Artifact class inherits Rake::FileCreationTask, so I guess its actions
> only get called
> if its needed? method returns true ( rake.rb:794 returns !File.exist?(name)
> )
> So if the artifact exists on your local repo, then its actions/prerequisites
> are not executed.
Cheers! This was exactly the missing piece that I needed to
get forward. Overriding FileCreationTask.needed? was the hook
I was looking for.
Unfortunately my ruby skills only got me so far, so it would be
great to get some help in this
https://issues.apache.org/jira/browse/BUILDR-212
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
Re: Where in the Buildr codebase does it determine that it needs to start retrieving a dependency jar?
Posted by Victor Hugo Borja <vi...@gmail.com>.
On Thu, Nov 27, 2008 at 1:12 PM, Timo Rantalaiho <Ti...@ri.fi>wrote:
> This is what I thought initially, but as far as I can tell,
> it doesn't get even that far if the artifact already exists.
> There must be some other check somewhere before that.
>
The Artifact class inherits Rake::FileCreationTask, so I guess its actions
only get called
if its needed? method returns true ( rake.rb:794 returns !File.exist?(name)
)
So if the artifact exists on your local repo, then its actions/prerequisites
are not executed.
Re: Where in the Buildr codebase does it determine that it needs to start retrieving a dependency jar?
Posted by Timo Rantalaiho <Ti...@ri.fi>.
Thankyou for the prompt reply!
On Thu, 27 Nov 2008, Victor Hugo Borja wrote:
> The Artifact#initialize function defined on artifact.rb has a File.exist?
> validation at line 313
> if the artifact doesnt exist, the download method is called. Note that the
> block given to
> task.enhance is executed once the artifact task is invoked:
> artifact("arti:fact:1.0:jar").invoke
> which is done by rake for any task depending on an artifact.
This is what I thought initially, but as far as I can tell,
it doesn't get even that far if the artifact already exists.
There must be some other check somewhere before that.
I added info "Hello world" to that place to see if it's invoked
or not
task.enhance do
info "Hello world"
unless File.exist?(name)
info "Downloading #{to_spec}"
download
pom.invoke rescue nil if pom && pom != self
end
end
and it's not, here's the output
thrantal@poro:~/work/leiri333/trunk$ ~/work/buildr/trunk/_buildr artifacts
(in /home/work/leiri333/trunk, development)
Completed in 0.007s
But if I delete some dependencies from the local maven repo,
it goes there and outputs the debug output for each _missing_
artifact.
thrantal@poro:~/work/leiri333/trunk$ ~/work/buildr/trunk/_buildr artifacts
(in /home/work/leiri333/trunk, development)
Hello world
Downloading org.jdave:jdave-wicket-webdriver:jar:1.1-SNAPSHOT
getaddrinfo: Name or service not known
Downloading http://www.laughingpanda.org/maven2/snapshots/org/jdave/jdave-wicket-webdriver/1.1-SNAPSHOT/jdave-wicket-webdriver-1.1-SNAPSHOT.jar
jdave-wicket-w..: 100% |.......................| 32.4KB/32.4KB Time: 00:00:00
mkdir -p /home/thrantal/.m2/repository/org/jdave/jdave-wicket-webdriver/1.1-SNAPSHOT
Hello world
Downloading org.jdave:jdave-wicket-webdriver:pom:1.1-SNAPSHOT
getaddrinfo: Name or service not known
Downloading http://www.laughingpanda.org/maven2/snapshots/org/jdave/jdave-wicket-webdriver/1.1-SNAPSHOT/jdave-wicket-webdriver-1.1-SNAPSHOT.pom
jdave-wicket-w..: 100% |........................| 3.2KB/3.2KB Time: 00:00:00
mkdir -p /home/thrantal/.m2/repository/org/jdave/jdave-wicket-webdriver/1.1-SNAPSHOT
Completed in 0.280s
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
Re: Where in the Buildr codebase does it determine that it needs to start retrieving a dependency jar?
Posted by Victor Hugo Borja <vi...@gmail.com>.
On Thu, Nov 27, 2008 at 10:00 AM, Timo Rantalaiho <Ti...@ri.fi>wrote:
> But I'm unsure of when does Buildr determine whether or not
> to start downloading.
>
> First I tried hooking into the downloading code in
> artifact.rb, but it never gets that far when the snapshot
> jar already exists in the local maven repo. Then I run
> buildr artifacts --trace which was showing "not_needed" and
> found a neeeded? method in packaging.rb, but that doesn't
> seem to get called neither when the snapshot jar is already
> present.
>
> Any hints are much appreciated!
>
The Artifact#initialize function defined on artifact.rb has a File.exist?
validation at line 313
if the artifact doesnt exist, the download method is called. Note that the
block given to
task.enhance is executed once the artifact task is invoked:
artifact("arti:fact:1.0:jar").invoke
which is done by rake for any task depending on an artifact.