lib/buildr/ivy_extension.rb in ivy4r-0.10.5 vs lib/buildr/ivy_extension.rb in ivy4r-0.11.0

- old
+ new

@@ -33,28 +33,26 @@ attr_reader :publish_mappings # Store the current project and initialize ivy ant wrapper def initialize(project) @project = project - if project.parent.nil? - @extension_dir = @project.base_dir - @post_resolve_task_list = [] - else - @extension_dir = @project.parent.ivy.extension_dir - @base_ivy = @project.parent.ivy unless own_file? - end + @post_resolve_task_list = [] + @extension_dir = project.parent.nil? ? @project.base_dir : @project.parent.ivy.extension_dir + @base_ivy = @project.parent.ivy unless own_file? @target_config = Hash.new do |hash, key| hash[key] = {} end + end def enabled? - @enabled ||= Ivy.setting('enabled') || true + setting = Ivy.setting('enabled') + @enabled ||= setting.nil? ? true : setting end def own_file? - @own_file ||= File.exists?(@project.path_to(file)) + @own_file ||= File.exists?(file) end # Returns the correct ivy4r instance to use, if project has its own ivy file uses the ivy file # of project, if not uses the ivy file of parent project. # Use this for low-level access to ivy functions as needed, i.e. in +post_resolve+ @@ -158,11 +156,11 @@ def __resolve__ if @base_ivy @base_ivy.__resolve__ else unless @resolved - @resolved = ivy4r.resolve :file => file + @resolved = ivy4r.resolve :file => file @project.send(:info, "Calling '#{post_resolve_tasks.size}' post_resolve tasks for '#{@project.name}'") post_resolve_tasks.each { |p| p.call(self) } end end end @@ -195,12 +193,12 @@ def __publish__ if @base_ivy @base_ivy.__publish__ else unless @published - options = {:status => status, :pubrevision => revision, :artifactspattern => "#{publish_from}/[artifact].[ext]"} - options = publish_options * options + base_options = {:status => status, :pubrevision => revision, :artifactspattern => "#{publish_from}/[artifact].[ext]"} + options = publish_options * base_options ivy4r.publish options @published = true end end end @@ -215,14 +213,21 @@ def settings @settings ||= Ivy.setting('settings.file') || "#{@extension_dir}/ant-scripts/ivysettings.xml" end - def file + # The basic file name to use in project dir as ivy.xml file. Normally this should be __ivy.xml__ + # If the file resides in a sub directory the relative path from project can be set with this method + def ivy_xml_filename @ivy_file ||= Ivy.setting('ivy.file') || 'ivy.xml' end + # Returns the absolute ivy file path to use + def file + @project.path_to(ivy_xml_filename) + end + # Sets the revision to use for the project, this is useful for development revisions that # have an appended timestamp or any other dynamic revisioning. # # To set a different revision this method can be used in different ways. # 1. project.ivy.revision(revision) to set the revision directly @@ -282,10 +287,10 @@ raise "Invalid call with parameters and block!" if options.size > 0 && block if options.empty? && block.nil? if @publish_options_calc @publish_options ||= @publish_options_calc.call(self) else - @publish_options ||= Ivy.setting('publish.options') + @publish_options ||= Ivy.setting('publish.options') || {} end else raise "Could not set 'publish_options' for '#{@project.name}' without own ivy file!" unless own_file? if options.size > 0 && block.nil? raise "publish options value invalid #{options.join(', ')}" unless options.size == 1