Class: Ivy4r
- Inherits:
-
Object
- Object
- Ivy4r
- Defined in:
- lib/ivy4r.rb,
lib/ivy4r/version.rb,
lib/ivy4r_java_extensions.rb
Overview
Simple wrapper that maps the ant ivy targets one to one to ruby. See the Apache Ivy for more informations about the parameters for a call. All ivy ant targets have the equivalent name in this class.
The standard parameters are provided as Hash, i.e.:
<ivy:configure file="settings.xml" settingsId="my.id" />
is
ivy4r.configure :file => "settings.xml", :settingsId => 'my.id'
You can use nested options via the nested attribute:
<ivy:buildlist reference="testpath">
<fileset dir="target/p1" includes="buildfile" />
</ivy:buildlist>
is
@ivy4r.buildlist :reference => 'testpath', :nested => {
:fileset => {:dir => 'target/p1', :includes => 'buildfile'}
}
you can nest more than on element of the same type using an array:
<ivy:buildlist reference="testpath">
<fileset dir="target/sub" includes="**/buildfile" />
<fileset dir="target/p1" includes="buildfile" />
</ivy:buildlist>
is
@ivy4r.buildlist :reference => 'testpath', :nested => {
:fileset => [
{:dir => 'target/sub', :includes => '**/buildfile'},
{:dir => 'target/p1', :includes => 'buildfile'}
]
}
Constant Summary collapse
- VERSION =
"0.12.11"
Instance Attribute Summary collapse
-
#ant ⇒ Object
Returns the __antwrap__ instance to use for all internal calls creates a default instance if no instance has been set before.
-
#ant_home ⇒ Object
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.
-
#cache_dir ⇒ Object
Donates the base directory for the cached files, if nil no caching is enabled.
-
#environment_property ⇒ Object
The ant property name to use for references to environment properties in ant and ivy, defaults to ‘env’.
-
#lib_dir ⇒ Object
Defines the directory to load ivy libs and its dependencies from.
-
#project_dir ⇒ Object
Optional ant variable
ivy.project.dir
to add to ant environment before loading ivy defaults to the lib_dir. -
#settings_file ⇒ Object
Access to ivy settings set via configure or settings method.
Instance Method Summary collapse
-
#ant_references ⇒ Object
Returns the ant references, note that this are java objects.
-
#artifactproperty(*params) ⇒ Object
Calls the __artifactproperty__ ivy target with given parameters and returns map with all defined properties.
-
#artifactreport(*params) ⇒ Object
Calls the __artifactreport__ ivy target with given parameters and returns the created xml.
-
#buildlist(*params) ⇒ Object
Calls the __buildlist__ ivy target with given parameters and returns the resulting buildlist.
-
#buildnumber(*params) ⇒ Object
Calls the __buildnumber__ ivy target with given parameters and returns info as hash.
-
#cachepath(*params) ⇒ Object
Calls the __cachepath__ ivy target with given parameters and returns array containing absolute file paths to all artifacts contained in result.
-
#cleancache(*params) ⇒ Object
Calls the __cleancache__ ivy target with given parameters.
-
#configure(*params) ⇒ Object
Calls the __configure__ ivy target with given parameters.
-
#findrevision(*params) ⇒ Object
Calls the __findrevision__ ivy target with given parameters and returns array containing absolute file paths to all artifacts contained in result.
-
#info(*params) ⇒ Object
Calls the __info__ ivy target with given parameters and returns info as hash.
-
#initialize(ant_instance = nil, &block) ⇒ Ivy4r
constructor
Initalizes ivy4r with optional ant wrapper object.
-
#install(*params) ⇒ Object
Calls the __install__ ivy target with given parameters always returns nil.
-
#ivy_instance ⇒ Object
Returns the ivy instance for underlying ant project with the current ivy settings.
-
#listmodules(*params) ⇒ Object
Calls the __listmodules__ ivy target with given parameters and returns info as hash.
-
#makepom(*params) ⇒ Object
Calls the __makepom__ ivy target with given parameters and returns pom content.
-
#property ⇒ Object
Used to get or set ant properties.
-
#publish(*params) ⇒ Object
Calls the __publish__ ivy target with given parameters.
-
#report(*params) ⇒ Object
Calls the __report__ ivy target with given parameters.
-
#resolve(*params) ⇒ Object
Calls the __resolve__ ivy target with given parameters and returns info as hash.
-
#retrieve(*params) ⇒ Object
Calls the __retrieve__ ivy target with given parameters.
-
#settings(*params) ⇒ Object
Calls the __settings__ ivy target with given parameters.
Constructor Details
#initialize(ant_instance = nil, &block) ⇒ Ivy4r
Initalizes ivy4r with optional ant wrapper object. Sets ant home dir and ivy lib dir to default values from Ivy4rJars gem.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ivy4r.rb', line 67 def initialize(ant_instance = nil, &block) @ant_home = ::Ivy4rJars.ant_home_dir @lib_dir = ::Ivy4rJars.lib_dir @project_dir = @lib_dir @environment_property = 'env' @ant = ant_instance if block if block.arity > 1 raise ArgumentError, "To many arguments expected=1 given=#{block.arity}" elsif block.arity == 1 yield self else instance_eval(&block) end end end |
Instance Attribute Details
#ant ⇒ Object
Returns the __antwrap__ instance to use for all internal calls creates a default instance if no instance has been set before.
57 58 59 |
# File 'lib/ivy4r.rb', line 57 def ant @ant end |
#ant_home ⇒ Object
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.
43 44 45 |
# File 'lib/ivy4r.rb', line 43 def ant_home @ant_home end |
#cache_dir ⇒ Object
Donates the base directory for the cached files, if nil no caching is enabled
63 64 65 |
# File 'lib/ivy4r.rb', line 63 def cache_dir @cache_dir end |
#environment_property ⇒ Object
The ant property name to use for references to environment properties in ant and ivy, defaults to ‘env’
54 55 56 |
# File 'lib/ivy4r.rb', line 54 def environment_property @environment_property end |
#lib_dir ⇒ Object
Defines the directory to load ivy libs and its dependencies from
46 47 48 |
# File 'lib/ivy4r.rb', line 46 def lib_dir @lib_dir end |
#project_dir ⇒ Object
Optional ant variable ivy.project.dir
to add to ant environment before loading ivy defaults to the lib_dir
50 51 52 |
# File 'lib/ivy4r.rb', line 50 def project_dir @project_dir end |
#settings_file ⇒ Object
Access to ivy settings set via configure or settings method.
60 61 62 |
# File 'lib/ivy4r.rb', line 60 def settings_file @settings_file end |
Instance Method Details
#ant_references ⇒ Object
Returns the ant references, note that this are java objects.
27 28 29 |
# File 'lib/ivy4r_java_extensions.rb', line 27 def ant_references ant.project.references end |
#artifactproperty(*params) ⇒ Object
Calls the __artifactproperty__ ivy target with given parameters and returns map with all defined properties
160 161 162 |
# File 'lib/ivy4r.rb', line 160 def artifactproperty(*params) Ivy::Artifactproperty.new(ant, cache_dir).execute(*params) end |
#artifactreport(*params) ⇒ Object
Calls the __artifactreport__ ivy target with given parameters and returns the created xml.
172 173 174 |
# File 'lib/ivy4r.rb', line 172 def artifactreport(*params) Ivy::Artifactreport.new(ant, cache_dir).execute(*params) end |
#buildlist(*params) ⇒ Object
Calls the __buildlist__ ivy target with given parameters and returns the resulting buildlist
166 167 168 |
# File 'lib/ivy4r.rb', line 166 def buildlist(*params) Ivy::Buildlist.new(ant, cache_dir).execute(*params) end |
#buildnumber(*params) ⇒ Object
Calls the __buildnumber__ ivy target with given parameters and returns info as hash.
112 113 114 |
# File 'lib/ivy4r.rb', line 112 def buildnumber(*params) Ivy::Buildnumber.new(ant, cache_dir).execute(*params) end |
#cachepath(*params) ⇒ Object
Calls the __cachepath__ ivy target with given parameters and returns array containing absolute file paths to all artifacts contained in result
143 144 145 |
# File 'lib/ivy4r.rb', line 143 def cachepath(*params) Ivy::Cachepath.new(ant, cache_dir).execute(*params) end |
#cleancache(*params) ⇒ Object
Calls the __cleancache__ ivy target with given parameters.
86 87 88 |
# File 'lib/ivy4r.rb', line 86 def cleancache(*params) Ivy::Cleancache.new(ant, cache_dir).execute(*params) end |
#configure(*params) ⇒ Object
Calls the __configure__ ivy target with given parameters.
99 100 101 102 103 104 |
# File 'lib/ivy4r.rb', line 99 def configure(*params) configure_task = Ivy::Configure.new(ant, nil) # do not cache configure result = configure_task.execute(*params) @settings_file = configure_task.params[:file] result end |
#findrevision(*params) ⇒ Object
Calls the __findrevision__ ivy target with given parameters and returns array containing absolute file paths to all artifacts contained in result
149 150 151 |
# File 'lib/ivy4r.rb', line 149 def findrevision(*params) Ivy::Findrevision.new(ant, cache_dir).execute(*params) end |
#info(*params) ⇒ Object
Calls the __info__ ivy target with given parameters and returns info as hash.
107 108 109 |
# File 'lib/ivy4r.rb', line 107 def info(*params) Ivy::Info.new(ant, cache_dir).execute(*params) end |
#install(*params) ⇒ Object
Calls the __install__ ivy target with given parameters always returns nil
154 155 156 |
# File 'lib/ivy4r.rb', line 154 def install(*params) Ivy::Install.new(ant, cache_dir).execute(*params) end |
#ivy_instance ⇒ Object
Returns the ivy instance for underlying ant project with the current ivy settings.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ivy4r_java_extensions.rb', line 10 def ivy_instance unless @ivy_instance variable_container = Java::OrgApacheIvyAnt::IvyAntVariableContainer.new(ant.project) settings_file = find_settings_file(variable_container) unless settings_file raise "no settings file set and no default settings found, cannot create ivy instance" unless settings_file raise "settings file does not exist: #{settings_file}" unless File.exists? settings_file settings = Java::OrgApacheIvyCoreSettings::IvySettings.new(variable_container) settings.base_dir = ant.project.base_dir @ivy_instance = Java::OrgApacheIvy::Ivy.new_instance(settings) @ivy_instance.configure(Java::JavaIo::File.new(settings_file)) end @ivy_instance end |
#listmodules(*params) ⇒ Object
Calls the __listmodules__ ivy target with given parameters and returns info as hash.
117 118 119 |
# File 'lib/ivy4r.rb', line 117 def listmodules(*params) #:nodoc: Ivy::Listmodules.new(ant, cache_dir).execute(*params) end |
#makepom(*params) ⇒ Object
Calls the __makepom__ ivy target with given parameters and returns pom content.
122 123 124 |
# File 'lib/ivy4r.rb', line 122 def makepom(*params) Ivy::Makepom.new(ant, cache_dir).execute(*params) end |
#property ⇒ Object
Used to get or set ant properties.
- set
-
property['name'] = value
sets the ant property with name to given value no overwrite - get
-
property[matcher]
gets property that is equal via case equality operator (===
)
184 185 186 |
# File 'lib/ivy4r.rb', line 184 def property AntPropertyHelper.new(ant, ant_properties) end |
#publish(*params) ⇒ Object
Calls the __publish__ ivy target with given parameters.
137 138 139 |
# File 'lib/ivy4r.rb', line 137 def publish(*params) Ivy::Publish.new(ant, cache_dir).execute(*params) end |
#report(*params) ⇒ Object
Calls the __report__ ivy target with given parameters
177 178 179 |
# File 'lib/ivy4r.rb', line 177 def report(*params) Ivy::Report.new(ant, cache_dir).execute(*params) end |
#resolve(*params) ⇒ Object
Calls the __resolve__ ivy target with given parameters and returns info as hash.
127 128 129 |
# File 'lib/ivy4r.rb', line 127 def resolve(*params) Ivy::Resolve.new(ant, cache_dir).execute(*params) end |
#retrieve(*params) ⇒ Object
Calls the __retrieve__ ivy target with given parameters.
132 133 134 |
# File 'lib/ivy4r.rb', line 132 def retrieve(*params) Ivy::Retrieve.new(ant, cache_dir).execute(*params) end |
#settings(*params) ⇒ Object
Calls the __settings__ ivy target with given parameters.
91 92 93 94 95 96 |
# File 'lib/ivy4r.rb', line 91 def settings(*params) settings_task = Ivy::Settings.new(ant, nil) # do not cache settings result = settings_task.execute(*params) @settings_file = settings_task.params[:file] result end |