Class: Rake::Ivy::IvyConfig
- Inherits:
-
Object
- Object
- Rake::Ivy::IvyConfig
- Defined in:
- lib/rake/ivy_extension.rb
Instance Attribute Summary collapse
-
#extension_dir ⇒ Object
The extension directory containing ivy settings, the local repository and cache.
-
#lib_dir ⇒ Object
The directory to load ivy jars and its dependencies from, leave __nil__ to use default.
-
#resolved ⇒ Object
readonly
Returns the resolve result.
Instance Method Summary collapse
-
#__publish__ ⇒ Object
Publishs the project as defined in ivy file if it has not been published already.
-
#__resolve__ ⇒ Object
Resolves the configured file once.
-
#ant ⇒ Object
Returns the correct ant instance to use.
-
#configure ⇒ Object
Configures the ivy instance with additional properties and loading the settings file if it was provided.
-
#deps(*confs) ⇒ Object
Returns the artifacts for given configurations as array.
- #file ⇒ Object
- #home ⇒ Object
-
#info ⇒ Object
Returns ivy info for configured ivy file.
-
#initialize(application) ⇒ IvyConfig
constructor
Store the current rake application and initialize ivy ant wrapper.
-
#local_repository(*local_repository) ⇒ Object
Sets the local repository for ivy files.
-
#properties(*properties) ⇒ Object
Sets the additional properties for the ivy process use a Hash with the properties to set.
-
#publish_from(*publish_dir) ⇒ Object
Sets the directory to publish artifacts from.
-
#publish_options(*options, &block) ⇒ Object
Sets the publish options to use for the project.
-
#report ⇒ Object
Creates the standard ivy dependency report.
-
#report_dir(*report_dir) ⇒ Object
Sets the directory to create dependency reports in.
-
#revision(*revision, &block) ⇒ Object
Sets the revision to use for the project, this is useful for development revisions that have an appended timestamp or any other dynamic revisioning.
- #settings ⇒ Object
-
#status(*status, &block) ⇒ Object
Sets the status to use for the project, this is useful for custom status handling like integration, alpha, gold.
Constructor Details
#initialize(application) ⇒ IvyConfig
Store the current rake application and initialize ivy ant wrapper
21 22 23 24 |
# File 'lib/rake/ivy_extension.rb', line 21 def initialize(application) @application = application @extension_dir = File.join("#{@application.original_dir}", "#{ENV['IVY_EXT_DIR']}") end |
Instance Attribute Details
#extension_dir ⇒ Object
The extension directory containing ivy settings, the local repository and cache
15 16 17 |
# File 'lib/rake/ivy_extension.rb', line 15 def extension_dir @extension_dir end |
#lib_dir ⇒ Object
The directory to load ivy jars and its dependencies from, leave __nil__ to use default
12 13 14 |
# File 'lib/rake/ivy_extension.rb', line 12 def lib_dir @lib_dir end |
#resolved ⇒ Object (readonly)
Returns the resolve result
18 19 20 |
# File 'lib/rake/ivy_extension.rb', line 18 def resolved @resolved end |
Instance Method Details
#__publish__ ⇒ Object
Publishs the project as defined in ivy file if it has not been published already
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rake/ivy_extension.rb', line 72 def __publish__ unless @published = {:artifactspattern => "#{publish_from}/[artifact].[ext]"} [:pubrevision] = revision if revision [:status] = status if status = * ant.publish @published = true end end |
#__resolve__ ⇒ Object
Resolves the configured file once.
60 61 62 63 64 |
# File 'lib/rake/ivy_extension.rb', line 60 def __resolve__ unless @resolved @resolved = ant.resolve :file => file end end |
#ant ⇒ Object
Returns the correct ant instance to use.
27 28 29 30 31 32 33 34 |
# File 'lib/rake/ivy_extension.rb', line 27 def ant unless @ant @ant = ::Ivy4r.new @ant.lib_dir = lib_dir if lib_dir @ant.project_dir = @extension_dir end @ant end |
#configure ⇒ Object
Configures the ivy instance with additional properties and loading the settings file if it was provided
50 51 52 53 54 55 56 57 |
# File 'lib/rake/ivy_extension.rb', line 50 def configure unless @configured ant.property['ivy.status'] = status ant.property['ivy.home'] = home properties.each {|key, value| ant.property[key.to_s] = value } @configured = ant.settings :file => settings if settings end end |
#deps(*confs) ⇒ Object
Returns the artifacts for given configurations as array
37 38 39 40 41 |
# File 'lib/rake/ivy_extension.rb', line 37 def deps(*confs) configure pathid = "ivy.deps." + confs.join('.') ant.cachepath :conf => confs.join(','), :pathid => pathid end |
#file ⇒ Object
91 92 93 |
# File 'lib/rake/ivy_extension.rb', line 91 def file @ivy_file ||= 'ivy.xml' end |
#home ⇒ Object
83 84 85 |
# File 'lib/rake/ivy_extension.rb', line 83 def home @ivy_home_dir ||= "#{@extension_dir}/ivy-home" end |
#info ⇒ Object
Returns ivy info for configured ivy file.
44 45 46 47 |
# File 'lib/rake/ivy_extension.rb', line 44 def info ant.settings :id => 'ivy.info.settingsref' ant.info :file => file, :settingsRef => 'ivy.info.settingsref' end |
#local_repository(*local_repository) ⇒ Object
Sets the local repository for ivy files
184 185 186 187 188 189 190 191 192 |
# File 'lib/rake/ivy_extension.rb', line 184 def local_repository(*local_repository) if local_repository.empty? @local_repository ||= "#{home}/repository" else raise "local_repository value invalid #{local_repository.join(', ')}" unless local_repository.size == 1 @local_repository = local_repository[0] self end end |
#properties(*properties) ⇒ Object
Sets the additional properties for the ivy process use a Hash with the properties to set.
173 174 175 176 177 178 179 180 181 |
# File 'lib/rake/ivy_extension.rb', line 173 def properties(*properties) if properties.empty? @properties ||= {} else raise "properties value invalid #{properties.join(', ')}" unless properties.size == 1 @properties = properties[0] self end end |
#publish_from(*publish_dir) ⇒ Object
Sets the directory to publish artifacts from.
195 196 197 198 199 200 201 202 203 |
# File 'lib/rake/ivy_extension.rb', line 195 def publish_from(*publish_dir) if publish_dir.empty? @publish_from ||= @application.original_dir else raise "publish_from value invalid #{publish_dir.join(', ')}" unless publish_dir.size == 1 @publish_from = publish_dir[0] self end end |
#publish_options(*options, &block) ⇒ Object
Sets the publish options to use for the project. The options are merged with the default options including value set via #publish_from and overwrite all of them.
To set the options this method can be used in different ways.
-
project.ivy.publish_options(options) to set the options directly
-
project.ivy.publish_options { |ivy| [calculate options] } use the block for dynamic calculation of options. You can access ivy4r via
ivy.ant.[method]
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/rake/ivy_extension.rb', line 152 def (*, &block) raise "Invalid call with parameters and block!" if .size > 0 && block if .empty? && block.nil? if @publish_options_calc @publish_options ||= @publish_options_calc.call(self) else @publish_options ||= {} end else if .size > 0 && block.nil? raise "publish options value invalid #{.join(', ')}" unless .size == 1 @publish_options = [0] self else @publish_options_calc = block self end end end |
#report ⇒ Object
Creates the standard ivy dependency report
67 68 69 |
# File 'lib/rake/ivy_extension.rb', line 67 def report ant.report :todir => report_dir end |
#report_dir(*report_dir) ⇒ Object
Sets the directory to create dependency reports in.
206 207 208 209 210 211 212 213 214 |
# File 'lib/rake/ivy_extension.rb', line 206 def report_dir(*report_dir) if report_dir.empty? @report_dir ||= @application.original_dir else raise "publish_from value invalid #{report_dir.join(', ')}" unless report_dir.size == 1 @report_dir = report_dir[0] self end end |
#revision(*revision, &block) ⇒ Object
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.
-
project.ivy.revision(revision) to set the revision directly
-
project.ivy.revision { |ivy| [calculate revision] } use the block for dynamic calculation of the revision. You can access ivy4r via
ivy.ant.[method]
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/rake/ivy_extension.rb', line 102 def revision(*revision, &block) raise "Invalid call with parameters and block!" if revision.size > 0 && block if revision.empty? && block.nil? if @revision_calc @revision ||= @revision_calc.call(self) else @revision end elsif block.nil? raise "revision value invalid #{revision.join(', ')}" unless revision.size == 1 @revision = revision[0] self else @revision_calc = block self end end |
#settings ⇒ Object
87 88 89 |
# File 'lib/rake/ivy_extension.rb', line 87 def settings @settings ||= "#{@extension_dir}/ant-scripts/ivysettings.xml" end |
#status(*status, &block) ⇒ Object
Sets the status to use for the project, this is useful for custom status handling like integration, alpha, gold.
To set a different status this method can be used in different ways.
-
project.ivy.status(status) to set the status directly
-
project.ivy.status { |ivy| [calculate status] } use the block for dynamic calculation of the status. You can access ivy4r via
ivy.ant.[method]
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/rake/ivy_extension.rb', line 127 def status(*status, &block) raise "Invalid call with parameters and block!" if status.size > 0 && block if status.empty? && block.nil? if @status_calc @status ||= @status_calc.call(self) else @status end elsif status.empty? && block.nil? raise "status value invalid #{status.join(', ')}" unless status.size == 1 @status = status[0] self else @status_calc = block self end end |