ivy4r 0.9.12 → 0.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,128 +1,131 @@
1
- require 'facets'
2
-
3
- module Ivy
4
-
5
- # Base class with general logic to call a Ivy ant target
6
- class Target
7
- attr_reader :params
8
-
9
- def initialize(ant)
10
- @ant = ant
11
- end
12
-
13
- # Executes this ivy target with given parameters returning a result.
14
- # __params__ can be a single Hash or an Array with or without a Hash as last value.
15
- # every value in array will be converted to string and set to __true__.
16
- #
17
- # I.e. <tt>[:force, 'validate', {'name' => 'Blub'}]</tt>
18
- # results in parameters <tt>{'force'=>true, 'validate' => true, 'name'=>'Blub'}</tt>
19
- def execute(*params)
20
- @params = {}
21
- params.pop.each { |key, value| @params[key] = value } if Hash === params.last
22
- params.each { |key| @params[key.to_s] = true }
23
-
24
- validate
25
- before_hook
26
- execute_ivy
27
- create_return_values
28
- ensure
29
- after_hook
30
- end
31
-
32
- protected
33
-
34
- # Validates provided hash of parameters, raises an exception if any mandatory parameter is
35
- # missing or an unknown parameter has been provided.
36
- def validate
37
- unknown = params.keys - symbols(parameter)
38
- raise ArgumentError, "Unknown parameters '#{unknown.join(', ')}' for #{self.class}" unless unknown.empty?
39
- missing = symbols(mandatory_parameter).find_all { |p| params.keys.member?(p) == false }
40
- raise ArgumentError, "Missing mandatory parameters '#{missing.join(', ')}' for #{self.class}" unless missing.empty?
41
- end
42
-
43
- # Hook method called after validation but before #execute_ivy
44
- # overwrite for special actions needed
45
- def before_hook
46
- end
47
-
48
- # After hook is always called for #execute within +ensure+ block
49
- # overwrite for special clean up
50
- def after_hook
51
- end
52
-
53
- # Helper to call the nested ant targets recursively if nessecary. Must be called within +do+ +end+
54
- # block of ant target to work.
55
- def call_nested(nested)
56
- if nested
57
- nested.each do |method, paramlist|
58
- [paramlist].flatten.each do |params|
59
- if params.member? :nested
60
- p = params.dup
61
- nest = p.delete(:nested)
62
- @ant.send(method, p, &lambda {call_nested(nest)})
63
- else
64
- @ant.send(method, params)
65
- end
66
- end
67
- end
68
- end
69
- end
70
-
71
- # Creates the result for the execution by default it iterates of the ant properties and fetches
72
- # all properties that match the result properties for target as a hash. Overwrite to provide
73
- # a different result
74
- def create_return_values
75
- result_properties
76
- end
77
-
78
- # Fetches all result properties for called target and returns them as hash
79
- def result_properties
80
- result = ant_properties.map do |p|
81
- rp = result_property_values.find { |rp| rp.matcher === p[0] }
82
- rp ? [p[0], rp.parse(p[1])].flatten : nil
83
- end.compact.to_h(:multi)
84
- result.update_values do |v|
85
- case v.size
86
- when 0
87
- nil
88
- when 1
89
- v[0]
90
- else
91
- v
92
- end
93
- end
94
-
95
- result
96
- end
97
-
98
- def mandatory_parameter
99
- parameter.find_all {|p| p.mandatory? }
100
- end
101
-
102
- def symbols(params)
103
- params.map{|p| p.symbol}
104
- end
105
-
106
- def ant_properties
107
- @ant.project.properties
108
- end
109
-
110
- def ant_references
111
- @ant.project.references
112
- end
113
- end
114
-
115
- COMMA_SPLITTER = Proc.new {|value| value.to_s.split(',').map(&:strip)}
116
-
117
- Parameter = Struct.new(:symbol, :mandatory) do
118
- def mandatory?
119
- mandatory
120
- end
121
- end
122
-
123
- ResultValue = Struct.new(:matcher, :parser) do
124
- def parse(value)
125
- parser ? parser.call(value) : value
126
- end
127
- end
128
- end
1
+ require 'facets/blank'
2
+ require 'facets/to_hash'
3
+ require 'facets/hash/op'
4
+ require 'facets/hash/update_values'
5
+
6
+ module Ivy
7
+
8
+ # Base class with general logic to call a Ivy ant target
9
+ class Target
10
+ attr_reader :params
11
+
12
+ def initialize(ant)
13
+ @ant = ant
14
+ end
15
+
16
+ # Executes this ivy target with given parameters returning a result.
17
+ # __params__ can be a single Hash or an Array with or without a Hash as last value.
18
+ # every value in array will be converted to string and set to __true__.
19
+ #
20
+ # I.e. <tt>[:force, 'validate', {'name' => 'Blub'}]</tt>
21
+ # results in parameters <tt>{'force'=>true, 'validate' => true, 'name'=>'Blub'}</tt>
22
+ def execute(*params)
23
+ @params = {}
24
+ params.pop.each { |key, value| @params[key] = value } if Hash === params.last
25
+ params.each { |key| @params[key.to_s] = true }
26
+
27
+ validate
28
+ before_hook
29
+ execute_ivy
30
+ create_return_values
31
+ ensure
32
+ after_hook
33
+ end
34
+
35
+ protected
36
+
37
+ # Validates provided hash of parameters, raises an exception if any mandatory parameter is
38
+ # missing or an unknown parameter has been provided.
39
+ def validate
40
+ unknown = params.keys - symbols(parameter)
41
+ raise ArgumentError, "Unknown parameters '#{unknown.join(', ')}' for #{self.class}" unless unknown.empty?
42
+ missing = symbols(mandatory_parameter).find_all { |p| params.keys.member?(p) == false }
43
+ raise ArgumentError, "Missing mandatory parameters '#{missing.join(', ')}' for #{self.class}" unless missing.empty?
44
+ end
45
+
46
+ # Hook method called after validation but before #execute_ivy
47
+ # overwrite for special actions needed
48
+ def before_hook
49
+ end
50
+
51
+ # After hook is always called for #execute within +ensure+ block
52
+ # overwrite for special clean up
53
+ def after_hook
54
+ end
55
+
56
+ # Helper to call the nested ant targets recursively if nessecary. Must be called within +do+ +end+
57
+ # block of ant target to work.
58
+ def call_nested(nested)
59
+ if nested
60
+ nested.each do |method, paramlist|
61
+ [paramlist].flatten.each do |params|
62
+ if params.member? :nested
63
+ p = params.dup
64
+ nest = p.delete(:nested)
65
+ @ant.send(method, p, &lambda {call_nested(nest)})
66
+ else
67
+ @ant.send(method, params)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ # Creates the result for the execution by default it iterates of the ant properties and fetches
75
+ # all properties that match the result properties for target as a hash. Overwrite to provide
76
+ # a different result
77
+ def create_return_values
78
+ result_properties
79
+ end
80
+
81
+ # Fetches all result properties for called target and returns them as hash
82
+ def result_properties
83
+ result = ant_properties.map do |p|
84
+ rp = result_property_values.find { |rp| rp.matcher === p[0] }
85
+ rp ? [p[0], rp.parse(p[1])].flatten : nil
86
+ end.compact.to_h(:multi)
87
+ result.update_values do |v|
88
+ case v.size
89
+ when 0
90
+ nil
91
+ when 1
92
+ v[0]
93
+ else
94
+ v
95
+ end
96
+ end
97
+
98
+ result
99
+ end
100
+
101
+ def mandatory_parameter
102
+ parameter.find_all {|p| p.mandatory? }
103
+ end
104
+
105
+ def symbols(params)
106
+ params.map{|p| p.symbol}
107
+ end
108
+
109
+ def ant_properties
110
+ @ant.project.properties
111
+ end
112
+
113
+ def ant_references
114
+ @ant.project.references
115
+ end
116
+ end
117
+
118
+ COMMA_SPLITTER = Proc.new {|value| value.to_s.split(',').map(&:strip)}
119
+
120
+ Parameter = Struct.new(:symbol, :mandatory) do
121
+ def mandatory?
122
+ mandatory
123
+ end
124
+ end
125
+
126
+ ResultValue = Struct.new(:matcher, :parser) do
127
+ def parse(value)
128
+ parser ? parser.call(value) : value
129
+ end
130
+ end
131
+ end
@@ -1,234 +1,234 @@
1
- require 'ivy4r_jars'
2
- require 'antwrap'
3
- require 'ivy/targets'
4
-
5
- =begin rdoc
6
- Simple wrapper that maps the ant ivy targets one to one to ruby. See the {Apache Ivy}[http://ant.apache.org/ivy/index.html]
7
- for more informations about the parameters for a call. All ivy ant targets have the equivalent
8
- name in this class.
9
-
10
- The standard parameters are provided as Hash, i.e.:
11
- <ivy:configure file="settings.xml" settingsId="my.id" />
12
- is
13
- ivy4r.configure :file => "settings.xml", :settingsId => 'my.id'
14
-
15
- You can use nested options via the nested attribute:
16
- <ivy:buildlist reference="testpath">
17
- <fileset dir="target/p1" includes="buildfile" />
18
- </ivy:buildlist>
19
- is
20
- @ivy4r.buildlist :reference => 'testpath', :nested => {
21
- :fileset => {:dir => 'target/p1', :includes => 'buildfile'}
22
- }
23
-
24
- you can nest more than on element of the same type using an array:
25
- <ivy:buildlist reference="testpath">
26
- <fileset dir="target/sub" includes="**/buildfile" />
27
- <fileset dir="target/p1" includes="buildfile" />
28
- </ivy:buildlist>
29
- is
30
- @ivy4r.buildlist :reference => 'testpath', :nested => {
31
- :fileset => [
32
- {:dir => 'target/sub', :includes => '**/buildfile'},
33
- {:dir => 'target/p1', :includes => 'buildfile'}
34
- ]
35
- }
36
- =end
37
- class Ivy4r
38
- VERSION = '0.9.12'
39
-
40
- # Set the ant home directory to load ant classes from if no custom __antwrap__ is provided
41
- # and the default provided ant version 1.7.1 should not be used.
42
- # Must be set before any call to method that uses the ivy is made.
43
- attr_accessor :ant_home
44
-
45
- # Defines the directory to load ivy libs and its dependencies from
46
- attr_accessor :lib_dir
47
-
48
- # Optional ant variable <tt>ivy.project.dir</tt> to add to ant environment before loading ivy
49
- # defaults to the __lib_dir__
50
- attr_accessor :project_dir
51
-
52
- # The ant property name to use for references to environment properties in ant and ivy,
53
- # defaults to 'env'
54
- attr_accessor :environment_property
55
-
56
- # To provide a custom __antwrap__ to use instead of default one
57
- attr_writer :ant
58
-
59
- # Access to ivy settings set via configure or settings method.
60
- attr_accessor :settings_file
61
-
62
- # Initalizes ivy4r with optional ant wrapper object. Sets ant home dir and ivy lib dir
63
- # to default values from __Ivy4rJars__ gem.
64
- def initialize(ant = nil)
65
- @ant_home = ::Ivy4rJars.ant_home_dir
66
- @lib_dir = ::Ivy4rJars.lib_dir
67
- @project_dir = @lib_dir
68
- @environment_property = 'env'
69
- @ant = ant
70
- end
71
-
72
- # Calls the __cleancache__ ivy target with given parameters.
73
- def cleancache(*params)
74
- Ivy::Cleancache.new(ant).execute(*params)
75
- end
76
-
77
- # Calls the __settings__ ivy target with given parameters.
78
- def settings(*params)
79
- settings_task = Ivy::Settings.new(ant)
80
- result = settings_task.execute(*params)
81
- @settings_file = settings_task.params[:file]
82
- result
83
- end
84
-
85
- # Calls the __configure__ ivy target with given parameters.
86
- def configure(*params)
87
- configure_task = Ivy::Configure.new(ant)
88
- result = configure_task.execute(*params)
89
- @settings_file = configure_task.params[:file]
90
- result
91
- end
92
-
93
- # Calls the __info__ ivy target with given parameters and returns info as hash.
94
- def info(*params)
95
- Ivy::Info.new(ant).execute(*params)
96
- end
97
-
98
- # Calls the __buildnumber__ ivy target with given parameters and returns info as hash.
99
- def buildnumber(*params)
100
- Ivy::Buildnumber.new(ant).execute(*params)
101
- end
102
-
103
- # Calls the __listmodules__ ivy target with given parameters and returns info as hash.
104
- def listmodules(*params) #:nodoc:
105
- Ivy::Listmodules.new(ant).execute(*params)
106
- end
107
-
108
- # Calls the __makepom__ ivy target with given parameters and returns pom content.
109
- def makepom(*params)
110
- Ivy::Makepom.new(ant).execute(*params)
111
- end
112
-
113
- # Calls the __resolve__ ivy target with given parameters and returns info as hash.
114
- def resolve(*params)
115
- Ivy::Resolve.new(ant).execute(*params)
116
- end
117
-
118
- # Calls the __retrieve__ ivy target with given parameters.
119
- def retrieve(*params)
120
- Ivy::Retrieve.new(ant).execute(*params)
121
- end
122
-
123
- # Calls the __publish__ ivy target with given parameters.
124
- def publish(*params)
125
- Ivy::Publish.new(ant).execute(*params)
126
- end
127
-
128
- # Calls the __cachepath__ ivy target with given parameters and returns
129
- # array containing absolute file paths to all artifacts contained in result
130
- def cachepath(*params)
131
- Ivy::Cachepath.new(ant).execute(*params)
132
- end
133
-
134
- # Calls the __findrevision__ ivy target with given parameters and returns
135
- # array containing absolute file paths to all artifacts contained in result
136
- def findrevision(*params)
137
- Ivy::Findrevision.new(ant).execute(*params)
138
- end
139
-
140
- # Calls the __artifactproperty__ ivy target with given parameters and returns
141
- # map with all defined properties
142
- def artifactproperty(*params)
143
- Ivy::Artifactproperty.new(ant).execute(*params)
144
- end
145
-
146
- # Calls the __buildlist__ ivy target with given parameters and returns
147
- # the resulting buildlist
148
- def buildlist(*params)
149
- Ivy::Buildlist.new(ant).execute(*params)
150
- end
151
-
152
- # Calls the __artifactreport__ ivy target with given parameters and returns
153
- # the created xml.
154
- def artifactreport(*params)
155
- Ivy::Artifactreport.new(ant).execute(*params)
156
- end
157
-
158
- # Calls the __report__ ivy target with given parameters
159
- def report(*params)
160
- Ivy::Report.new(ant).execute(*params)
161
- end
162
-
163
- # Used to get or set ant properties.
164
- # [set] <tt>property['name'] = value</tt> sets the ant property with name to given value no overwrite
165
- # [get] <tt>property[matcher]</tt> gets property that is equal via case equality operator (<tt>===</tt>)
166
- def property
167
- AntPropertyHelper.new(ant, ant_properties)
168
- end
169
-
170
- # Returns the __antwrap__ instance to use for all internal calls creates a default
171
- # instance if no instance has been set before.
172
- def ant
173
- @ant ||= ::Antwrap::AntProject.new(:ant_home => ant_home,
174
- :name => "ivy-ant", :basedir => Dir.pwd, :declarative => true)
175
- init(@ant) if should_init?
176
- @ant
177
- end
178
-
179
- private
180
- def should_init?
181
- @init_done.nil? || @init_done == false
182
- end
183
-
184
- def init(ant)
185
- @init_done = true
186
- ant.property :environment => environment_property
187
- ant.property :name => 'ivy.project.dir', :value => project_dir
188
- ant.path :id => 'ivy.lib.path' do
189
- ant.fileset :dir => lib_dir, :includes => '*.jar'
190
- end
191
-
192
- ant.typedef :name => "ivy_settings", :classname => "org.apache.ivy.ant.IvyAntSettings", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader', :loaderRef => 'ivy.lib.path.loader'
193
- ant.taskdef :name => "ivy_configure", :classname => "org.apache.ivy.ant.IvyConfigure", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
194
- ant.taskdef :name => "ivy_resolve", :classname => "org.apache.ivy.ant.IvyResolve", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
195
- ant.taskdef :name => "ivy_retrieve", :classname => "org.apache.ivy.ant.IvyRetrieve", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
196
- ant.taskdef :name => "ivy_deliver", :classname => "org.apache.ivy.ant.IvyDeliver", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
197
- ant.taskdef :name => "ivy_publish", :classname => "org.apache.ivy.ant.IvyPublish", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
198
- ant.taskdef :name => "ivy_extract", :classname => "org.apache.ivy.ant.IvyExtractFromSources", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
199
- ant.taskdef :name => "ivy_cachepath", :classname => "org.apache.ivy.ant.IvyCachePath", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
200
- ant.taskdef :name => "ivy_cachefileset", :classname => "org.apache.ivy.ant.IvyCacheFileset", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
201
- ant.taskdef :name => "ivy_report", :classname => "org.apache.ivy.ant.IvyReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
202
- ant.taskdef :name => "ivy_repreport", :classname => "org.apache.ivy.ant.IvyRepositoryReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
203
- ant.taskdef :name => "ivy_var", :classname => "org.apache.ivy.ant.IvyVar", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
204
- ant.taskdef :name => "ivy_check", :classname => "org.apache.ivy.ant.IvyCheck", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
205
- ant.taskdef :name => "ivy_artifactproperty", :classname => "org.apache.ivy.ant.IvyArtifactProperty", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
206
- ant.taskdef :name => "ivy_buildlist", :classname => "org.apache.ivy.ant.IvyBuildList", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
207
- ant.taskdef :name => "ivy_install", :classname => "org.apache.ivy.ant.IvyInstall", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
208
- ant.taskdef :name => "ivy_convertpom", :classname => "org.apache.ivy.ant.IvyConvertPom", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
209
- ant.taskdef :name => "ivy_makepom", :classname => "org.apache.ivy.ant.IvyMakePom", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
210
- ant.taskdef :name => "ivy_artifactreport", :classname => "org.apache.ivy.ant.IvyArtifactReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
211
- ant.taskdef :name => "ivy_info", :classname => "org.apache.ivy.ant.IvyInfo", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
212
- ant.taskdef :name => "ivy_addpath", :classname => "org.apache.ivy.ant.AddPathTask", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
213
- ant.taskdef :name => "ivy_listmodules", :classname => "org.apache.ivy.ant.IvyListModules", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
214
- ant.taskdef :name => "ivy_findrevision", :classname => "org.apache.ivy.ant.IvyFindRevision", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
215
- ant.taskdef :name => "ivy_buildnumber", :classname => "org.apache.ivy.ant.IvyBuildNumber", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
216
- ant.taskdef :name => "ivy_cleancache", :classname => "org.apache.ivy.ant.IvyCleanCache", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
217
- end
218
-
219
- # Returns the ant properties, note that this are java objects.
220
- def ant_properties
221
- ant.project.properties
222
- end
223
- end
224
-
225
- AntPropertyHelper = Struct.new(:ant, :ant_properties) do #:nodoc:
226
- def []=(name, value) #:nodoc:
227
- ant.property :name => name, :value => value
228
- end
229
-
230
- def [](matcher) #:nodoc:
231
- property = ant_properties.find {|p| matcher === p[0] }
232
- property ? property[1] : nil
233
- end
234
- end
1
+ require 'ivy4r_jars'
2
+ require 'antwrap'
3
+ require 'ivy/targets'
4
+
5
+ =begin rdoc
6
+ Simple wrapper that maps the ant ivy targets one to one to ruby. See the {Apache Ivy}[http://ant.apache.org/ivy/index.html]
7
+ for more informations about the parameters for a call. All ivy ant targets have the equivalent
8
+ name in this class.
9
+
10
+ The standard parameters are provided as Hash, i.e.:
11
+ <ivy:configure file="settings.xml" settingsId="my.id" />
12
+ is
13
+ ivy4r.configure :file => "settings.xml", :settingsId => 'my.id'
14
+
15
+ You can use nested options via the nested attribute:
16
+ <ivy:buildlist reference="testpath">
17
+ <fileset dir="target/p1" includes="buildfile" />
18
+ </ivy:buildlist>
19
+ is
20
+ @ivy4r.buildlist :reference => 'testpath', :nested => {
21
+ :fileset => {:dir => 'target/p1', :includes => 'buildfile'}
22
+ }
23
+
24
+ you can nest more than on element of the same type using an array:
25
+ <ivy:buildlist reference="testpath">
26
+ <fileset dir="target/sub" includes="**/buildfile" />
27
+ <fileset dir="target/p1" includes="buildfile" />
28
+ </ivy:buildlist>
29
+ is
30
+ @ivy4r.buildlist :reference => 'testpath', :nested => {
31
+ :fileset => [
32
+ {:dir => 'target/sub', :includes => '**/buildfile'},
33
+ {:dir => 'target/p1', :includes => 'buildfile'}
34
+ ]
35
+ }
36
+ =end
37
+ class Ivy4r
38
+ VERSION = '0.9.13'
39
+
40
+ # Set the ant home directory to load ant classes from if no custom __antwrap__ is provided
41
+ # and the default provided ant version 1.7.1 should not be used.
42
+ # Must be set before any call to method that uses the ivy is made.
43
+ attr_accessor :ant_home
44
+
45
+ # Defines the directory to load ivy libs and its dependencies from
46
+ attr_accessor :lib_dir
47
+
48
+ # Optional ant variable <tt>ivy.project.dir</tt> to add to ant environment before loading ivy
49
+ # defaults to the __lib_dir__
50
+ attr_accessor :project_dir
51
+
52
+ # The ant property name to use for references to environment properties in ant and ivy,
53
+ # defaults to 'env'
54
+ attr_accessor :environment_property
55
+
56
+ # To provide a custom __antwrap__ to use instead of default one
57
+ attr_writer :ant
58
+
59
+ # Access to ivy settings set via configure or settings method.
60
+ attr_accessor :settings_file
61
+
62
+ # Initalizes ivy4r with optional ant wrapper object. Sets ant home dir and ivy lib dir
63
+ # to default values from __Ivy4rJars__ gem.
64
+ def initialize(ant = nil)
65
+ @ant_home = ::Ivy4rJars.ant_home_dir
66
+ @lib_dir = ::Ivy4rJars.lib_dir
67
+ @project_dir = @lib_dir
68
+ @environment_property = 'env'
69
+ @ant = ant
70
+ end
71
+
72
+ # Calls the __cleancache__ ivy target with given parameters.
73
+ def cleancache(*params)
74
+ Ivy::Cleancache.new(ant).execute(*params)
75
+ end
76
+
77
+ # Calls the __settings__ ivy target with given parameters.
78
+ def settings(*params)
79
+ settings_task = Ivy::Settings.new(ant)
80
+ result = settings_task.execute(*params)
81
+ @settings_file = settings_task.params[:file]
82
+ result
83
+ end
84
+
85
+ # Calls the __configure__ ivy target with given parameters.
86
+ def configure(*params)
87
+ configure_task = Ivy::Configure.new(ant)
88
+ result = configure_task.execute(*params)
89
+ @settings_file = configure_task.params[:file]
90
+ result
91
+ end
92
+
93
+ # Calls the __info__ ivy target with given parameters and returns info as hash.
94
+ def info(*params)
95
+ Ivy::Info.new(ant).execute(*params)
96
+ end
97
+
98
+ # Calls the __buildnumber__ ivy target with given parameters and returns info as hash.
99
+ def buildnumber(*params)
100
+ Ivy::Buildnumber.new(ant).execute(*params)
101
+ end
102
+
103
+ # Calls the __listmodules__ ivy target with given parameters and returns info as hash.
104
+ def listmodules(*params) #:nodoc:
105
+ Ivy::Listmodules.new(ant).execute(*params)
106
+ end
107
+
108
+ # Calls the __makepom__ ivy target with given parameters and returns pom content.
109
+ def makepom(*params)
110
+ Ivy::Makepom.new(ant).execute(*params)
111
+ end
112
+
113
+ # Calls the __resolve__ ivy target with given parameters and returns info as hash.
114
+ def resolve(*params)
115
+ Ivy::Resolve.new(ant).execute(*params)
116
+ end
117
+
118
+ # Calls the __retrieve__ ivy target with given parameters.
119
+ def retrieve(*params)
120
+ Ivy::Retrieve.new(ant).execute(*params)
121
+ end
122
+
123
+ # Calls the __publish__ ivy target with given parameters.
124
+ def publish(*params)
125
+ Ivy::Publish.new(ant).execute(*params)
126
+ end
127
+
128
+ # Calls the __cachepath__ ivy target with given parameters and returns
129
+ # array containing absolute file paths to all artifacts contained in result
130
+ def cachepath(*params)
131
+ Ivy::Cachepath.new(ant).execute(*params)
132
+ end
133
+
134
+ # Calls the __findrevision__ ivy target with given parameters and returns
135
+ # array containing absolute file paths to all artifacts contained in result
136
+ def findrevision(*params)
137
+ Ivy::Findrevision.new(ant).execute(*params)
138
+ end
139
+
140
+ # Calls the __artifactproperty__ ivy target with given parameters and returns
141
+ # map with all defined properties
142
+ def artifactproperty(*params)
143
+ Ivy::Artifactproperty.new(ant).execute(*params)
144
+ end
145
+
146
+ # Calls the __buildlist__ ivy target with given parameters and returns
147
+ # the resulting buildlist
148
+ def buildlist(*params)
149
+ Ivy::Buildlist.new(ant).execute(*params)
150
+ end
151
+
152
+ # Calls the __artifactreport__ ivy target with given parameters and returns
153
+ # the created xml.
154
+ def artifactreport(*params)
155
+ Ivy::Artifactreport.new(ant).execute(*params)
156
+ end
157
+
158
+ # Calls the __report__ ivy target with given parameters
159
+ def report(*params)
160
+ Ivy::Report.new(ant).execute(*params)
161
+ end
162
+
163
+ # Used to get or set ant properties.
164
+ # [set] <tt>property['name'] = value</tt> sets the ant property with name to given value no overwrite
165
+ # [get] <tt>property[matcher]</tt> gets property that is equal via case equality operator (<tt>===</tt>)
166
+ def property
167
+ AntPropertyHelper.new(ant, ant_properties)
168
+ end
169
+
170
+ # Returns the __antwrap__ instance to use for all internal calls creates a default
171
+ # instance if no instance has been set before.
172
+ def ant
173
+ @ant ||= ::Antwrap::AntProject.new(:ant_home => ant_home,
174
+ :name => "ivy-ant", :basedir => Dir.pwd, :declarative => true)
175
+ init(@ant) if should_init?
176
+ @ant
177
+ end
178
+
179
+ private
180
+ def should_init?
181
+ @init_done.nil? || @init_done == false
182
+ end
183
+
184
+ def init(ant)
185
+ @init_done = true
186
+ ant.property :environment => environment_property
187
+ ant.property :name => 'ivy.project.dir', :value => project_dir
188
+ ant.path :id => 'ivy.lib.path' do
189
+ ant.fileset :dir => lib_dir, :includes => '*.jar'
190
+ end
191
+
192
+ ant.typedef :name => "ivy_settings", :classname => "org.apache.ivy.ant.IvyAntSettings", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader', :loaderRef => 'ivy.lib.path.loader'
193
+ ant.taskdef :name => "ivy_configure", :classname => "org.apache.ivy.ant.IvyConfigure", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
194
+ ant.taskdef :name => "ivy_resolve", :classname => "org.apache.ivy.ant.IvyResolve", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
195
+ ant.taskdef :name => "ivy_retrieve", :classname => "org.apache.ivy.ant.IvyRetrieve", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
196
+ ant.taskdef :name => "ivy_deliver", :classname => "org.apache.ivy.ant.IvyDeliver", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
197
+ ant.taskdef :name => "ivy_publish", :classname => "org.apache.ivy.ant.IvyPublish", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
198
+ ant.taskdef :name => "ivy_extract", :classname => "org.apache.ivy.ant.IvyExtractFromSources", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
199
+ ant.taskdef :name => "ivy_cachepath", :classname => "org.apache.ivy.ant.IvyCachePath", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
200
+ ant.taskdef :name => "ivy_cachefileset", :classname => "org.apache.ivy.ant.IvyCacheFileset", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
201
+ ant.taskdef :name => "ivy_report", :classname => "org.apache.ivy.ant.IvyReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
202
+ ant.taskdef :name => "ivy_repreport", :classname => "org.apache.ivy.ant.IvyRepositoryReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
203
+ ant.taskdef :name => "ivy_var", :classname => "org.apache.ivy.ant.IvyVar", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
204
+ ant.taskdef :name => "ivy_check", :classname => "org.apache.ivy.ant.IvyCheck", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
205
+ ant.taskdef :name => "ivy_artifactproperty", :classname => "org.apache.ivy.ant.IvyArtifactProperty", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
206
+ ant.taskdef :name => "ivy_buildlist", :classname => "org.apache.ivy.ant.IvyBuildList", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
207
+ ant.taskdef :name => "ivy_install", :classname => "org.apache.ivy.ant.IvyInstall", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
208
+ ant.taskdef :name => "ivy_convertpom", :classname => "org.apache.ivy.ant.IvyConvertPom", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
209
+ ant.taskdef :name => "ivy_makepom", :classname => "org.apache.ivy.ant.IvyMakePom", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
210
+ ant.taskdef :name => "ivy_artifactreport", :classname => "org.apache.ivy.ant.IvyArtifactReport", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
211
+ ant.taskdef :name => "ivy_info", :classname => "org.apache.ivy.ant.IvyInfo", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
212
+ ant.taskdef :name => "ivy_addpath", :classname => "org.apache.ivy.ant.AddPathTask", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
213
+ ant.taskdef :name => "ivy_listmodules", :classname => "org.apache.ivy.ant.IvyListModules", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
214
+ ant.taskdef :name => "ivy_findrevision", :classname => "org.apache.ivy.ant.IvyFindRevision", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
215
+ ant.taskdef :name => "ivy_buildnumber", :classname => "org.apache.ivy.ant.IvyBuildNumber", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
216
+ ant.taskdef :name => "ivy_cleancache", :classname => "org.apache.ivy.ant.IvyCleanCache", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
217
+ end
218
+
219
+ # Returns the ant properties, note that this are java objects.
220
+ def ant_properties
221
+ ant.project.properties
222
+ end
223
+ end
224
+
225
+ AntPropertyHelper = Struct.new(:ant, :ant_properties) do #:nodoc:
226
+ def []=(name, value) #:nodoc:
227
+ ant.property :name => name, :value => value
228
+ end
229
+
230
+ def [](matcher) #:nodoc:
231
+ property = ant_properties.find {|p| matcher === p[0] }
232
+ property ? property[1] : nil
233
+ end
234
+ end