On Fri, Feb 18, 2011 at 8:13 AM, Carlos Sanchez <[email protected]> wrote:

> I was wondering if buildr could be used to download artifacts from a
> Maven repository from any ruby script. I need to download them using
> ruby and thought about giving a try to buildr before going for jruby
> or something more complicated.
>
> Something along the lines of
>
> require 'rubygems'
> require 'buildr'
>
> artifact('org.apache.openjpa:openjpa:jar:1.2.1').invoke
>
> which of course doesn't work.
>
> Any suggestions?
>

If you don't mind a little hack, the following works on recent versions of
buildr:

require 'rubygems'
require 'buildr'

class << Buildr.application
  def rakefile; __FILE__; end
end

Buildr.repositories.remote << "http://www.ibiblio.org/maven2/";

artifact('org.apache.openjpa:openjpa:jar:1.2.1').invoke

I think it was possible to use buildr as a library without this little hack
at some point... and I wouldn't mind explicitly supporting this since it's
pretty convenient to do things outside the scope of a buildfile for certain
use-case.

alex

Reply via email to