klaas1979-ivy4r 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,5 +1,12 @@
1
+ === 0.2.0 / 2009-06-18
2
+
3
+ * added the Buildr ivy_extension to include ivy in buildr for dependency managment
4
+ * small improvements in documentation
5
+
6
+
1
7
  === 0.1.0 / 2009-06-17
2
8
 
3
9
  * initial release
4
10
  * support for nearly all basic IVY Ant targets
5
11
  * basic validation of parameters
12
+
data/Manifest.txt CHANGED
@@ -2,6 +2,8 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
+ bin/ivy4r
6
+ lib/buildr/ivy_extension.rb
5
7
  lib/ivy/artifactproperty.rb
6
8
  lib/ivy/artifactreport.rb
7
9
  lib/ivy/buildlist.rb
@@ -32,4 +34,3 @@ test/ivy/ivytest.xml
32
34
  test/ivy/test_target.rb
33
35
  test/ivy/test_targets.rb
34
36
  test/test_ivy4r.rb
35
-
data/README.txt CHANGED
@@ -1,11 +1,16 @@
1
1
  = ivy4r
2
2
 
3
3
  * http://github.com/klaas1979/ivy4r/tree/master
4
+ * http://ivy4r.rubyforge.org/
4
5
 
5
6
  == DESCRIPTION:
6
7
 
7
- Apache Ivy dependency manager wrapper for ruby (see http://ant.apache.org/ivy/index.html for more information).Use Ivy via a ruby wrapper without the need to use Apache Ant.
8
- The wrapper uses Antwrap (see http://antwrap.rubyforge.org/) to interface with Ivy.
8
+ Apache Ivy dependency manager wrapper for ruby (see {Apache Ivy}[http://ant.apache.org/ivy/index.html] for more information).
9
+ Use {Apache Ivy}[http://ant.apache.org/ivy/index.html] via a ruby wrapper without the need to use Apache Ant.
10
+ The wrapper uses Antwrap[http://antwrap.rubyforge.org/] to interface with Ivy.
11
+
12
+ Includes a Extension for Buildr[http://buildr.apache.org/] to use {Apache Ivy}[http://ant.apache.org/ivy/index.html]
13
+ for dependency management.
9
14
 
10
15
  == FEATURES/PROBLEMS:
11
16
 
@@ -46,19 +51,15 @@ Supports most standard Ivy Ant targets via Antwrap.
46
51
  == SYNOPSIS:
47
52
 
48
53
  To init a new Ivy4r instance set the ANT_HOME and the Ivy lib dir
49
- <tt>
50
54
  ivy4r = Ivy4r.new
51
55
  ivy4r.ant_home = 'PATH TO YOUR ANTHME'
52
56
  ivy4r.lib_dir = 'PATH TO IVY LIB DIR'
53
- </tt>
54
57
  as an alternative to setting the ANT_HOME you can set an +Antwrap+ instance directly:
55
- <tt>
56
58
  ivy4r.ant = Buildr.ant('ivy')
57
- </tt>
58
59
 
59
60
  == REQUIREMENTS:
60
61
 
61
- * Installed Apache Ant, to call Ivy via Antwrap.
62
+ * Installed Apache Ant, to call Ivy via Antwrap
62
63
  * Ivy and dependencies in a single directory. Dependencies depends on used features, see the ivy homepage for more information.
63
64
 
64
65
  == INSTALL:
data/bin/ivy4r CHANGED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ abort "makes no sense for ivy4r!"
@@ -0,0 +1,547 @@
1
+ require 'ivy4r'
2
+
3
+ module Buildr
4
+ module Ivy
5
+
6
+ # TODO extend extension to download ivy stuff with dependencies automatically
7
+ # VERSION = '2.1.0-rc1'
8
+
9
+ class << self
10
+
11
+ def setting(*keys)
12
+ setting = Buildr.settings.build['ivy']
13
+ keys.each { |key| setting = setting[key] unless setting.nil? }
14
+ setting
15
+ end
16
+
17
+ # def version
18
+ # setting['version'] || VERSION
19
+ # end
20
+ # def dependencies
21
+ # @dependencies ||= [
22
+ # "org.apache.ivy:ivy:jar:#{version}",
23
+ # 'com.jcraft:jsch:jar:1.41',
24
+ # 'oro:oro:jar:2.08'
25
+ # ]
26
+ # end
27
+ end
28
+
29
+ class IvyConfig
30
+
31
+ attr_accessor :extension_dir, :resolved
32
+
33
+ # Store the current project and initialize ivy ant wrapper
34
+ def initialize(project)
35
+ @project = project
36
+ if project.parent.nil?
37
+ @extension_dir = File.join("#{@project.base_dir}", "#{ENV['BUILDR_EXT_DIR']}")
38
+ else
39
+ @extension_dir = @project.parent.ivy.extension_dir
40
+ @base_ivy = @project.parent.ivy unless own_file?
41
+ end
42
+ end
43
+
44
+ def enabled?
45
+ @enabled ||= Ivy.setting('enabled') || true
46
+ end
47
+
48
+ def own_file?
49
+ @own_file ||= File.exists?(@project.path_to(file))
50
+ end
51
+
52
+ # Returns the correct ant instance to use, if project has its own ivy file uses the ivy file
53
+ # of project, if not uses the ivy file of parent project.
54
+ def ant
55
+ unless @ant
56
+ if own_file?
57
+ @ant = ::Ivy4r.new(@project.ant('ivy'))
58
+ @ant.lib_dir = lib_dir
59
+ @ant.project_dir = @extension_dir
60
+ else
61
+ @ant = @project.parent.ivy.ant
62
+ end
63
+ end
64
+ @ant
65
+ end
66
+
67
+ # Returns name of publish target to use for this project
68
+ def file_project
69
+ own_file? ? @project : @base_ivy.file_project
70
+ end
71
+
72
+ # Returns the artifacts for given configurations as array
73
+ def deps(*confs)
74
+ configure
75
+ pathid = "ivy.deps." + confs.join('.')
76
+ ant.cachepath :conf => confs.join(','), :pathid => pathid
77
+ end
78
+
79
+ # Returns ivy info for configured ivy file.
80
+ def info
81
+ if @base_ivy
82
+ @base_ivy.info
83
+ else
84
+ ant.settings :id => 'ivy.info.settingsref'
85
+ ant.info :file => file, :settingsRef => 'ivy.info.settingsref'
86
+ end
87
+ end
88
+
89
+ # Configures the ivy instance with additional properties and loading the settings file if it was provided
90
+ def configure
91
+ if @base_ivy
92
+ @base_ivy.configure
93
+ else
94
+ unless @configured
95
+ ant.property['ivy.status'] = status
96
+ ant.property['ivy.home'] = home
97
+ properties.each {|key, value| ant.property[key.to_s] = value }
98
+ @configured = ant.settings :file => settings if settings
99
+ end
100
+ end
101
+ end
102
+
103
+ # Resolves the configured file once.
104
+ def resolve
105
+ if @base_ivy
106
+ @base_ivy.resolve
107
+ else
108
+ unless @resolved
109
+ @resolved = ant.resolve :file => file
110
+ end
111
+ end
112
+ end
113
+
114
+ # Returns the additional infos for the manifest file.
115
+ def manifest
116
+ if @base_ivy
117
+ @base_ivy.manifest
118
+ else
119
+ {
120
+ 'organisation' => @resolved['ivy.organisation'],
121
+ 'module' => @resolved['ivy.organisation'],
122
+ 'revision' => revision
123
+ }
124
+ end
125
+ end
126
+
127
+ # Creates the standard ivy dependency report
128
+ def report
129
+ ant.report :todir => report_dir
130
+ end
131
+
132
+ # Publishs the project as defined in ivy file if it has not been published already
133
+ def publish
134
+ if @base_ivy
135
+ @base_ivy.publish
136
+ else
137
+ unless @published
138
+ options = {:status => status, :pubrevision => revision, :artifactspattern => "#{publish_from}/[artifact].[ext]"}
139
+ options = publish_options * options
140
+ ant.publish options
141
+ @published = true
142
+ end
143
+ end
144
+ end
145
+
146
+ def home
147
+ @ivy_home_dir ||= Ivy.setting('home.dir') || "#{@extension_dir}/ivy-home"
148
+ end
149
+
150
+ def lib_dir
151
+ @lib_dir ||= Ivy.setting('lib.dir') || "#{home}/jars"
152
+ end
153
+
154
+ def settings
155
+ @settings ||= Ivy.setting('settings.file') || "#{@extension_dir}/ant-scripts/ivysettings.xml"
156
+ end
157
+
158
+ def file
159
+ @ivy_file ||= Ivy.setting('ivy.file') || 'ivy.xml'
160
+ end
161
+
162
+ # Sets the revision to use for the project, this is useful for development revisions that
163
+ # have an appended timestamp or any other dynamic revisioning.
164
+ #
165
+ # To set a different revision this method can be used in different ways.
166
+ # 1. project.ivy.revision(revision) to set the revision directly
167
+ # 2. project.ivy.revision { |ivy| [calculate revision] } use the block for dynamic
168
+ # calculation of the revision. You can access ivy4r via <tt>ivy.ant.[method]</tt>
169
+ def revision(*revision, &block)
170
+ raise "Invalid call with parameters and block!" if revision.size > 0 && block
171
+ if revision.empty? && block.nil?
172
+ if @revision_calc
173
+ @revision ||= @revision_calc.call(self)
174
+ else
175
+ @revision ||= @project.version
176
+ end
177
+ elsif block.nil?
178
+ raise "revision value invalid #{revision.join(', ')}" unless revision.size == 1
179
+ @revision = revision[0]
180
+ self
181
+ else
182
+ @revision_calc = block
183
+ self
184
+ end
185
+ end
186
+
187
+ # Sets the status to use for the project, this is useful for custom status handling
188
+ # like integration, alpha, gold.
189
+ #
190
+ # To set a different status this method can be used in different ways.
191
+ # 1. project.ivy.status(status) to set the status directly
192
+ # 2. project.ivy.status { |ivy| [calculate status] } use the block for dynamic
193
+ # calculation of the status. You can access ivy4r via <tt>ivy.ant.[method]</tt>
194
+ def status(*status, &block)
195
+ raise "Invalid call with parameters and block!" if status.size > 0 && block
196
+ if status.empty? && block.nil?
197
+ if @status_calc
198
+ @status ||= @status_calc.call(self)
199
+ else
200
+ @status ||= Ivy.setting('status') || 'integration'
201
+ end
202
+ elsif status.empty? && block.nil?
203
+ raise "status value invalid #{status.join(', ')}" unless status.size == 1
204
+ @status = status[0]
205
+ self
206
+ else
207
+ @status_calc = block
208
+ self
209
+ end
210
+ end
211
+
212
+ # Sets the publish options to use for the project. The options are merged with the default
213
+ # options including value set via #publish_from and overwrite all of them.
214
+ #
215
+ # To set the options this method can be used in different ways.
216
+ # 1. project.ivy.publish_options(options) to set the options directly
217
+ # 2. project.ivy.publish_options { |ivy| [calculate options] } use the block for dynamic
218
+ # calculation of options. You can access ivy4r via <tt>ivy.ant.[method]</tt>
219
+ def publish_options(*options, &block)
220
+ raise "Invalid call with parameters and block!" if options.size > 0 && block
221
+ if options.empty? && block.nil?
222
+ if @publish_options_calc
223
+ @publish_options ||= @publish_options_calc.call(self)
224
+ else
225
+ @publish_options ||= Ivy.setting('publish.options')
226
+ end
227
+ else
228
+ raise "Could not set 'publish_options' for '#{@project.name}' without own ivy file!" unless own_file?
229
+ if options.size > 0 && block.nil?
230
+ raise "publish options value invalid #{options.join(', ')}" unless options.size == 1
231
+ @publish_options = options[0]
232
+ self
233
+ else
234
+ @publish_options_calc = block
235
+ self
236
+ end
237
+ end
238
+ end
239
+
240
+ # Sets the additional properties for the ivy process use a Hash with the properties to set.
241
+ def properties(*properties)
242
+ if properties.empty?
243
+ @properties ||= {}
244
+ else
245
+ raise "properties value invalid #{properties.join(', ')}" unless properties.size == 1
246
+ @properties = properties[0]
247
+ self
248
+ end
249
+ end
250
+
251
+ # Sets the local repository for ivy files
252
+ def local_repository(*local_repository)
253
+ if local_repository.empty?
254
+ if own_file?
255
+ @local_repository ||= Ivy.setting('local.repository.dir') || "#{home}/repository"
256
+ else
257
+ @project.parent.ivy.local_repository
258
+ end
259
+ else
260
+ raise "Could not set 'local_repository' for '#{@project.name}' without own ivy file!" unless own_file?
261
+ raise "local_repository value invalid #{local_repository.join(', ')}" unless local_repository.size == 1
262
+ @local_repository = local_repository[0]
263
+ self
264
+ end
265
+ end
266
+
267
+ # Maps a package to a different name for publishing. This name is used instead of the default name
268
+ # for publishing use a hash with the +package+ as key and the newly mapped name as value. I.e.
269
+ # <tt>ivy.name(package(:jar) => 'new_name_without_version_number.jar')</tt>
270
+ # Note that this method is additive, a second call adds the names to the first.
271
+ def name(*name_mappings)
272
+ if name_mappings.empty?
273
+ @name_mappings ||= {}
274
+ else
275
+ raise "name_mappings value invalid #{name_mappings.join(', ')}" unless name_mappings.size == 1
276
+ @name_mappings = @name_mappings ? @name_mappings + name_mappings[0] : name_mappings[0].dup
277
+ self
278
+ end
279
+ end
280
+
281
+ # Sets the directory to publish artifacts from.
282
+ def publish_from(*publish_dir)
283
+ if publish_dir.empty?
284
+ if own_file?
285
+ @publish_from ||= Ivy.setting('publish.from') || @project.path_to(:target)
286
+ else
287
+ @project.parent.ivy.publish_from
288
+ end
289
+ else
290
+ raise "Could not set 'publish_from' for '#{@project.name}' without own ivy file!" unless own_file?
291
+ raise "publish_from value invalid #{publish_dir.join(', ')}" unless publish_dir.size == 1
292
+ @publish_from = publish_dir[0]
293
+ self
294
+ end
295
+ end
296
+
297
+ # Sets the directory to create dependency reports in.
298
+ def report_dir(*report_dir)
299
+ if report_dir.empty?
300
+ if own_file?
301
+ @report_dir ||= Ivy.setting('report.dir') || @project.path_to(:reports, 'ivy')
302
+ else
303
+ @project.parent.ivy.report_dir
304
+ end
305
+ else
306
+ raise "Could not set 'report_dir' for '#{@project.name}' without own ivy file!" unless own_file?
307
+ raise "publish_from value invalid #{report_dir.join(', ')}" unless report_dir.size == 1
308
+ @report_dir = report_dir[0]
309
+ self
310
+ end
311
+ end
312
+
313
+ # Set the configuration artifacts to use in package tasks like +:war+ or +:ear+.
314
+ # <tt>project.ivy.package_conf('server', 'client')</tt>
315
+ # or
316
+ # <tt>project.ivy.package_conf(['server', 'client'])</tt>
317
+ def package_conf(*package_conf)
318
+ if package_conf.empty?
319
+ @package_conf ||= [Ivy.setting('package.conf') || 'prod'].flatten.uniq
320
+ else
321
+ @package_conf = [package_conf].flatten.uniq
322
+ self
323
+ end
324
+ end
325
+
326
+ # Sets the includes pattern(s) to use for packages. I.e.
327
+ # <tt>project.ivy.package_include(/\.jar/, /\.gz/)</tt>
328
+ def package_include(*includes)
329
+ if includes.empty?
330
+ @package_include ||= [Ivy.setting('package.include') || /\.jar/].flatten.uniq
331
+ else
332
+ @package_include = [includes].flatten.uniq
333
+ self
334
+ end
335
+ end
336
+
337
+ # Sets the exclude pattern(s) to use for packages. I.e.
338
+ # <tt>project.ivy.package_exclude(/\.zip/, /\.tar/)</tt>
339
+ def package_exclude(*excludes)
340
+ if excludes.empty?
341
+ @package_exclude ||= [Ivy.setting('package.exlude') || ''].flatten.uniq
342
+ else
343
+ @package_exclude = [excludes].flatten.uniq
344
+ self
345
+ end
346
+ end
347
+
348
+ # Set the configuration artifacts to use for compile tasks, added to <tt>compile.with</tt>
349
+ # <tt>project.ivy.compile_conf('server', 'client')</tt>
350
+ def compile_conf(*compile_conf)
351
+ if compile_conf.empty?
352
+ @compile_conf ||= [Ivy.setting('compile.conf') || 'compile'].flatten.uniq
353
+ else
354
+ @compile_conf = [compile_conf].flatten.uniq
355
+ self
356
+ end
357
+ end
358
+
359
+ # Set the configuration artifacts to use for test tasks, added to <tt>test.compile.with</tt>
360
+ # and <tt>test.with</tt>. Note that all artifacts from #compile_conf are added automatically.
361
+ # <tt>project.ivy.test_conf('server', 'test')</tt>
362
+ def test_conf(*test_conf)
363
+ if test_conf.empty?
364
+ @test_conf ||= [Ivy.setting('test.conf') || 'test'].flatten.uniq
365
+ else
366
+ @test_conf = [test_conf].flatten.uniq
367
+ self
368
+ end
369
+ end
370
+ end
371
+
372
+ # The Ivy Buildr extension adding the new tasks for ivy.
373
+ module IvyExtension
374
+ include Buildr::Extension
375
+
376
+ class << self
377
+ def add_ivy_deps_to_java_tasks(project)
378
+ resolve_target = project.ivy.file_project.task('ivy:resolve')
379
+ project.task :compiledeps => resolve_target do
380
+ compile_conf = [project.ivy.compile_conf].flatten
381
+ project.compile.with project.ivy.deps(compile_conf)
382
+ info "Ivy adding compile dependencies '#{compile_conf.join(', ')}' to project '#{project.name}'"
383
+ end
384
+ project.task :compile => "#{project.name}:compiledeps"
385
+
386
+ project.task :testdeps => resolve_target do
387
+ confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq
388
+ project.test.with project.ivy.deps(confs)
389
+ info "Ivy adding test dependencies '#{confs.join(', ')}' to project '#{project.name}'"
390
+ end
391
+ project.task "test:compile" => "#{project.name}:testdeps"
392
+
393
+ project.task :javadocdeps => resolve_target do
394
+ confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq
395
+ project.javadoc.with project.ivy.deps(confs)
396
+ info "Ivy adding javadoc dependencies '#{confs.join(', ')}' to project '#{project.name}'"
397
+ end
398
+ project.task :javadoc => "#{project.name}:javadocdeps"
399
+ end
400
+
401
+ def add_manifest_to_distributeables(project)
402
+ pkgs = project.packages.find_all { |pkg| [:jar, :war, :ear].member? pkg.type }
403
+ pkgs.each do |pkg|
404
+ name = "#{pkg.name}manifest"
405
+ task = project.task name => project.ivy.file_project.task('ivy:resolve') do
406
+ pkg.with :manifest => project.manifest.merge(project.ivy.manifest)
407
+ info "Adding manifest entries to package '#{pkg.name}'"
408
+ end
409
+ project.task :build => task
410
+ end
411
+ end
412
+
413
+ def add_prod_libs_to_distributeables(project)
414
+ includes = project.ivy.package_include
415
+ excludes = project.ivy.package_exclude
416
+ pkgs = project.packages.find_all { |pkg| [:war, :ear].member? pkg.type }
417
+ pkgs.each do |pkg|
418
+ name = "#{pkg.name}deps"
419
+ task = project.task name => project.ivy.file_project.task('ivy:resolve') do
420
+ confs = project.ivy.package_conf
421
+ libs = project.ivy.deps(confs).find_all do |lib|
422
+ lib = File.basename(lib)
423
+ use = includes.any? {|include| include === lib } && !excludes.any? {|exclude| exclude === lib}
424
+ verbose "Including '#{lib}' from package '#{pkg}' in project '#{project.name}'" if use
425
+ info "Excluding '#{lib}' from package '#{pkg}' in project '#{project.name}'" unless use
426
+ use
427
+ end
428
+ pkg.with :libs => libs
429
+ info "Adding production libs from conf '#{confs.join(', ')}' to package '#{pkg.name}' in project '#{project.name}'"
430
+ end
431
+ project.task :build => task
432
+ end
433
+ end
434
+
435
+ def add_copy_tasks_for_publish(project)
436
+ if project.ivy.own_file?
437
+ Buildr.projects.each do |current|
438
+ current.packages.each do |pkg|
439
+ target_file = current.ivy.name[pkg] || File.basename(pkg.name).gsub(/-#{project.version}/, '')
440
+ taskname = current.path_to(project.ivy.publish_from, target_file)
441
+ if taskname != pkg.name
442
+ project.file taskname => pkg.name do
443
+ verbose "Ivy copying '#{pkg.name}' to '#{taskname}' for publishing"
444
+ FileUtils.mkdir File.dirname(taskname) unless File.directory?(File.dirname(taskname))
445
+ FileUtils.cp pkg.name, taskname
446
+ end
447
+ end
448
+ project.task 'ivy:publish' => taskname
449
+ end
450
+ end
451
+ end
452
+ end
453
+ end
454
+
455
+ # Returns the +ivy+ configuration for the project. Use this to configure Ivy.
456
+ # see IvyConfig for more details about configuration options.
457
+ def ivy
458
+ @ivy_config ||= IvyConfig.new(self)
459
+ end
460
+
461
+ first_time do
462
+ namespace 'ivy' do
463
+ desc 'Resolves the ivy dependencies'
464
+ task :resolve
465
+
466
+ desc 'Publish the artifacts to ivy repository as defined by environment'
467
+ task :publish
468
+
469
+ desc 'Creates a dependency report for the project'
470
+ task :report
471
+
472
+ desc 'Clean the local Ivy cache and the local ivy repository'
473
+ task :clean
474
+ end
475
+ end
476
+
477
+ before_define do |project|
478
+ if project.parent.nil? && project.ivy.enabled?
479
+ info = project.ivy.info
480
+ project.version = info['ivy.revision']
481
+ project.group = "#{info['ivy.organisation']}.#{info['ivy.module']}"
482
+ end
483
+ end
484
+
485
+ after_define do |project|
486
+ if project.ivy.enabled?
487
+ IvyExtension.add_ivy_deps_to_java_tasks(project)
488
+ IvyExtension.add_manifest_to_distributeables(project)
489
+ IvyExtension.add_prod_libs_to_distributeables(project)
490
+ IvyExtension.add_copy_tasks_for_publish(project)
491
+
492
+ task :clean do
493
+ # TODO This is redundant, refactor ivy_ant_wrap and this to use a single config object
494
+ info "Cleaning ivy reports"
495
+ rm_rf project.path_to(:reports, 'ivy')
496
+ end
497
+
498
+ namespace 'ivy' do
499
+ task :configure do
500
+ project.ivy.configure
501
+ end
502
+
503
+ task :resolve => "#{project.name}:ivy:configure" do
504
+ project.ivy.resolve
505
+ end
506
+
507
+ task :report => "#{project.name}:ivy:resolve" do
508
+ project.ivy.report
509
+ end
510
+
511
+ task :publish => "#{project.name}:ivy:resolve" do
512
+ project.ivy.publish
513
+ end
514
+ end
515
+ end
516
+ end
517
+ end
518
+
519
+ # Global targets that are not bound to a project
520
+ namespace 'ivy' do
521
+ task :clean do
522
+ info "Cleaning local ivy cache"
523
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
524
+ project.ivy.ant.clean
525
+ end
526
+ end
527
+
528
+ task :resolve do
529
+ info "Resolving all distinct ivy files"
530
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
531
+ project.task('ivy:resolve').invoke
532
+ end
533
+ end
534
+
535
+ task :publish => :package do
536
+ info "Publishing all distinct ivy files"
537
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
538
+ project.task('ivy:publish').invoke
539
+ end
540
+ end
541
+ end
542
+
543
+ class Buildr::Project # :nodoc:
544
+ include IvyExtension
545
+ end
546
+ end
547
+ end
data/lib/ivy/target.rb CHANGED
@@ -2,19 +2,7 @@ require 'facets'
2
2
 
3
3
  module Ivy
4
4
 
5
- COMMA_SPLITTER = Proc.new {|value| value.to_s.split(',').map(&:strip)}
6
-
7
- Parameter = Struct.new(:symbol, :mandatory) do
8
- def mandatory?
9
- mandatory
10
- end
11
- end
12
-
13
- ResultValue = Struct.new(:matcher, :parser) do
14
- def parse(value)
15
- parser ? parser.call(value) : value
16
- end
17
- end
5
+ # Base class with general logic to call a Ivy ant target
18
6
  class Target
19
7
  attr_reader :params
20
8
 
@@ -22,11 +10,16 @@ module Ivy
22
10
  @ant = ant
23
11
  end
24
12
 
25
- # Executes this ivy target with given parameters returning a result where appropriate
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>
26
19
  def execute(*params)
27
20
  @params = {}
28
21
  params.pop.each { |key, value| @params[key] = value } if Hash === params.last
29
- params.each { |key| @params[key] = true }
22
+ params.each { |key| @params[key.to_s] = true }
30
23
 
31
24
  validate
32
25
  before_hook
@@ -118,5 +111,18 @@ module Ivy
118
111
  @ant.project.references
119
112
  end
120
113
  end
121
-
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
122
128
  end
data/lib/ivy4r.rb CHANGED
@@ -2,7 +2,7 @@ require 'antwrap'
2
2
  require 'ivy/targets'
3
3
 
4
4
  class Ivy4r
5
- VERSION = '0.1.0'
5
+ VERSION = '0.2.0'
6
6
 
7
7
  # Set the ant home directory to load ant classes from if no custom __antwrap__ is provided
8
8
  attr_accessor :ant_home
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klaas1979-ivy4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaas Prause
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-17 00:00:00 -07:00
12
+ date: 2009-06-18 00:00:00 -07:00
13
13
  default_executable: ivy4r
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.1.0
34
34
  version:
35
- description: Apache Ivy dependency manager wrapper for ruby (see http://ant.apache.org/ivy/index.html for more information).Use Ivy via a ruby wrapper without the need to use Apache Ant. The wrapper uses Antwrap (see http://antwrap.rubyforge.org/) to interface with Ivy.
35
+ description: Apache Ivy dependency manager wrapper for ruby (see {Apache Ivy}[http://ant.apache.org/ivy/index.html] for more information). Use {Apache Ivy}[http://ant.apache.org/ivy/index.html] via a ruby wrapper without the need to use Apache Ant. The wrapper uses Antwrap[http://antwrap.rubyforge.org/] to interface with Ivy. Includes a Extension for Buildr[http://buildr.apache.org/] to use {Apache Ivy}[http://ant.apache.org/ivy/index.html] for dependency management.
36
36
  email:
37
37
  - klaas.prause@googlemail.com
38
38
  executables:
@@ -48,6 +48,8 @@ files:
48
48
  - Manifest.txt
49
49
  - README.txt
50
50
  - Rakefile
51
+ - bin/ivy4r
52
+ - lib/buildr/ivy_extension.rb
51
53
  - lib/ivy/artifactproperty.rb
52
54
  - lib/ivy/artifactreport.rb
53
55
  - lib/ivy/buildlist.rb
@@ -105,7 +107,7 @@ rubyforge_project: ivy4r
105
107
  rubygems_version: 1.2.0
106
108
  signing_key:
107
109
  specification_version: 3
108
- summary: Apache Ivy dependency manager wrapper for ruby (see http://ant.apache.org/ivy/index.html for more information).Use Ivy via a ruby wrapper without the need to use Apache Ant
110
+ summary: Apache Ivy dependency manager wrapper for ruby (see {Apache Ivy}[http://ant.apache.org/ivy/index.html] for more information)
109
111
  test_files:
110
112
  - test/test_ivy4r.rb
111
113
  - test/ivy/test_target.rb