lib/ivy4r.rb in ivy4r-0.3.0 vs lib/ivy4r.rb in ivy4r-0.5.1

- old
+ new

@@ -1,5 +1,6 @@ +require 'ivy4r_jars' require 'antwrap' require 'ivy/targets' =begin rdoc Simple wrapper that maps the ant ivy targets one to one to ruby. See the {Apache Ivy}[http://ant.apache.org/ivy/index.html] @@ -32,28 +33,34 @@ {:dir => 'target/p1', :includes => 'buildfile'} ] } =end class Ivy4r - VERSION = '0.3.0' + VERSION = '0.5.1' # Set the ant home directory to load ant classes from if no custom __antwrap__ is provided # and the default provided ant version 1.7.1 should not be used. # Must be set before any call to method that uses the ivy is made. attr_accessor :ant_home # Defines the directory to load ivy libs and its dependencies from attr_accessor :lib_dir + # Optional ant variable <tt>ivy.project.dir</tt> to add to ant environment before loading ivy + # defaults to the __lib_dir__ attr_accessor :project_dir # To provide a custom __antwrap__ to use instead of default one attr_writer :ant - def initialize(*opts) - @ant = opts[0] if opts.size == 1 - raise "To many parameters to create Ivy4r use none, or 1 to set ANT!" if opts.size > 1 + # Initalizes ivy4r with optional ant wrapper object. Sets ant home dir and ivy lib dir + # to default values from __Ivy4rJars__ gem. + def initialize(ant = nil) + @ant_home = ::Ivy4rJars.ant_home_dir + @lib_dir = ::Ivy4rJars.lib_dir + @project_dir = @lib_dir + @ant = ant end # Calls the __cleancache__ ivy target with given parameters. def cleancache(*params) Ivy::Cleancache.new(ant).execute(*params) @@ -147,10 +154,10 @@ end # Returns the __antwrap__ instance to use for all internal calls creates a default # instance if no instance has been set before. def ant - @ant ||= ::Antwrap::AntProject.new(:ant_home => ant_home || File.expand_path(File.join(File.dirname(__FILE__), '..', 'jars')), + @ant ||= ::Antwrap::AntProject.new(:ant_home => ant_home, :name => "ivy-ant", :basedir => Dir.pwd, :declarative => true) init(@ant) if should_init? @ant end