ivy4r 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.9.10 / 2009-12-21
2
+
3
+ * Better support for Rake targets using the deps mechanism from buildr support.
4
+
1
5
  === 0.9.9 / 2009-12-10
2
6
 
3
7
  * Fixed setting of ant properties, properties are really sets and cannot be overwritten afterwards.
data/lib/ivy4r.rb CHANGED
@@ -35,7 +35,7 @@ is
35
35
  }
36
36
  =end
37
37
  class Ivy4r
38
- VERSION = '0.9.9'
38
+ VERSION = '0.9.10'
39
39
 
40
40
  # Set the ant home directory to load ant classes from if no custom __antwrap__ is provided
41
41
  # and the default provided ant version 1.7.1 should not be used.
@@ -16,56 +16,82 @@ module Rake
16
16
 
17
17
  # Returns the resolve result
18
18
  attr_reader :resolved
19
+
20
+ attr_reader :post_resolve_tasks
19
21
 
20
22
  # Store the current rake application and initialize ivy ant wrapper
21
23
  def initialize(application)
22
24
  @application = application
23
25
  @extension_dir = File.join("#{@application.original_dir}", "#{ENV['IVY_EXT_DIR']}")
26
+ @post_resolve_tasks = []
24
27
  end
25
28
 
26
29
  # Returns the correct ant instance to use.
27
- def ant
28
- unless @ant
29
- @ant = ::Ivy4r.new
30
- @ant.lib_dir = lib_dir if lib_dir
31
- @ant.project_dir = @extension_dir
30
+ def ivy4r
31
+ unless @ivy4r
32
+ @ivy4r = ::Ivy4r.new
33
+ @ivy4r.lib_dir = lib_dir if lib_dir
34
+ @ivy4r.project_dir = @extension_dir
32
35
  end
33
- @ant
36
+ @ivy4r
34
37
  end
35
38
 
36
39
  # Returns the artifacts for given configurations as array
37
- def deps(*confs)
38
- configure
39
- pathid = "ivy.deps." + confs.join('.')
40
- ant.cachepath :conf => confs.join(','), :pathid => pathid
40
+ # this is a post resolve task.
41
+ # the arguments are checked for the following:
42
+ # 1. if an Hash is given :conf is used for confs and :type is used for types
43
+ # 2. if exactly two arrays are given args[0] is used for confs and args[1] is used for types
44
+ # 3. if not exactly two arrays all args are used as confs
45
+ def deps(*args)
46
+ if args.size == 1 && args[0].kind_of?(Hash)
47
+ confs, types = [args[0][:conf]].flatten, [args[0][:type]].flatten
48
+ elsif args.size == 2 && args[0].kind_of?(Array) && args[1].kind_of?(Array)
49
+ confs, types = args[0], args[1]
50
+ else
51
+ confs, types = args.flatten, []
52
+ end
53
+
54
+ [confs, types].each do |t|
55
+ t.reject! {|c| c.nil? || c.blank? }
56
+ end
57
+
58
+ unless confs.empty?
59
+ pathid = "ivy.deps." + confs.join('.') + '.' + types.join('.')
60
+ params = {:conf => confs.join(','), :pathid => pathid}
61
+ params[:type] = types.join(',') unless types.nil? || types.size == 0
62
+
63
+ ivy4r.cachepath params
64
+ end
41
65
  end
42
66
 
43
67
  # Returns ivy info for configured ivy file.
44
68
  def info
45
- ant.settings :id => 'ivy.info.settingsref'
46
- ant.info :file => file, :settingsRef => 'ivy.info.settingsref'
69
+ ivy4r.settings :id => 'ivy.info.settingsref'
70
+ ivy4r.info :file => file, :settingsRef => 'ivy.info.settingsref'
47
71
  end
48
72
 
49
73
  # Configures the ivy instance with additional properties and loading the settings file if it was provided
50
74
  def configure
51
75
  unless @configured
52
- ant.property['ivy.status'] = status
53
- ant.property['ivy.home'] = home
54
- properties.each {|key, value| ant.property[key.to_s] = value }
55
- @configured = ant.settings :file => settings if settings
76
+ ivy4r.property['ivy.status'] = status
77
+ ivy4r.property['ivy.home'] = home
78
+ properties.each {|key, value| ivy4r.property[key.to_s] = value }
79
+ @configured = ivy4r.settings :file => settings if settings
56
80
  end
57
81
  end
58
82
 
59
83
  # Resolves the configured file once.
60
84
  def __resolve__
61
85
  unless @resolved
62
- @resolved = ant.resolve :file => file
86
+ @resolved = ivy4r.resolve :file => file
87
+ post_resolve_tasks.each { |p| p.call(self) }
63
88
  end
89
+ @resolved
64
90
  end
65
91
 
66
92
  # Creates the standard ivy dependency report
67
93
  def report
68
- ant.report :todir => report_dir
94
+ ivy4r.report :todir => report_dir
69
95
  end
70
96
 
71
97
  # Publishs the project as defined in ivy file if it has not been published already
@@ -75,7 +101,7 @@ module Rake
75
101
  options[:pubrevision] = revision if revision
76
102
  options[:status] = status if status
77
103
  options = publish_options * options
78
- ant.publish options
104
+ ivy4r.publish options
79
105
  @published = true
80
106
  end
81
107
  end
@@ -98,7 +124,7 @@ module Rake
98
124
  # To set a different revision this method can be used in different ways.
99
125
  # 1. project.ivy.revision(revision) to set the revision directly
100
126
  # 2. project.ivy.revision { |ivy| [calculate revision] } use the block for dynamic
101
- # calculation of the revision. You can access ivy4r via <tt>ivy.ant.[method]</tt>
127
+ # calculation of the revision. You can access ivy4r via <tt>ivy.ivy4r.[method]</tt>
102
128
  def revision(*revision, &block)
103
129
  raise "Invalid call with parameters and block!" if revision.size > 0 && block
104
130
  if revision.empty? && block.nil?
@@ -123,7 +149,7 @@ module Rake
123
149
  # To set a different status this method can be used in different ways.
124
150
  # 1. project.ivy.status(status) to set the status directly
125
151
  # 2. project.ivy.status { |ivy| [calculate status] } use the block for dynamic
126
- # calculation of the status. You can access ivy4r via <tt>ivy.ant.[method]</tt>
152
+ # calculation of the status. You can access ivy4r via <tt>ivy.ivy4r.[method]</tt>
127
153
  def status(*status, &block)
128
154
  raise "Invalid call with parameters and block!" if status.size > 0 && block
129
155
  if status.empty? && block.nil?
@@ -148,7 +174,7 @@ module Rake
148
174
  # To set the options this method can be used in different ways.
149
175
  # 1. project.ivy.publish_options(options) to set the options directly
150
176
  # 2. project.ivy.publish_options { |ivy| [calculate options] } use the block for dynamic
151
- # calculation of options. You can access ivy4r via <tt>ivy.ant.[method]</tt>
177
+ # calculation of options. You can access ivy4r via <tt>ivy.ivy4r.[method]</tt>
152
178
  def publish_options(*options, &block)
153
179
  raise "Invalid call with parameters and block!" if options.size > 0 && block
154
180
  if options.empty? && block.nil?
@@ -214,6 +240,35 @@ module Rake
214
240
  end
215
241
  end
216
242
 
243
+ # Adds given block as post resolve action that is executed directly after #resolve has been called.
244
+ # Yields this ivy config object into block.
245
+ # <tt>project.ivy.post_resolve { |ivy| p "all deps:" + ivy.deps('all').join(", ") }</tt>
246
+ def post_resolve(&block)
247
+ post_resolve_tasks << block if block
248
+ end
249
+
250
+ # Filter artifacts for given configuration with provided filter values, this is a post resolve
251
+ # task like #deps.
252
+ # <tt>project.ivy.filter('server', 'client', :include => /b.*.jar/, :exclude => [/a\.jar/, /other.*\.jar/])</tt>
253
+ def filter(*confs)
254
+ filter = confs.last.kind_of?(Hash) ? confs.pop : {}
255
+ unless (filter.keys - (TYPES - [:conf])).empty?
256
+ raise ArgumentError, "Invalid filter use :include and/or :exclude only: given #{filter.keys.inspect}"
257
+ end
258
+ includes, excludes, types = filter[:include] || [], filter[:exclude] || [], filter[:type] || []
259
+
260
+ artifacts = deps(confs.flatten, types.flatten)
261
+ if artifacts
262
+ artifacts = artifacts.find_all do |lib|
263
+ lib = File.basename(lib)
264
+ includes = includes.reject {|i| i.nil? || i.blank? }
265
+ should_include = includes.empty? || includes.any? {|include| include === lib }
266
+ should_include && !excludes.any? {|exclude| exclude === lib}
267
+ end
268
+ end
269
+
270
+ artifacts
271
+ end
217
272
 
218
273
  class Tasks < ::Rake::TaskLib
219
274
  def initialize(ivy = nil, &block)
@@ -248,7 +303,7 @@ module Rake
248
303
 
249
304
  desc 'Clean the local Ivy cache and the local ivy repository'
250
305
  task :clean do
251
- Rake.application.ivy.ant.clean
306
+ Rake.application.ivy.ivy4r.clean
252
307
  end
253
308
  end
254
309
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ivy4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
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-12-10 00:00:00 +01:00
12
+ date: 2009-12-21 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency