ivy4r 0.9.15 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,32 @@
1
+ === 0.10.0 / 2010-03-30
2
+
3
+ * Add caching support to ivy4r. Ivy4r has now an optional parameter to a caching directory where it
4
+ stores results from calls to the tasks for each parameter set. If caching is enabled and a call
5
+ with the same parameters is done the cached result is used instead of executing the task again. This
6
+ should speed up local development because long running tasks like "ivy:resolve" are cached.
7
+ Caching can be enabled in buildr with:
8
+ * add this to your build.yaml or the [home]/.buildr/settings.yaml:
9
+ ivy:
10
+ caching.enabled: true
11
+ * add a marker file to your project under the path project.path_to('use_ivy_caching') Note that this is
12
+ a marker file only the existence of the file is checked not the content!! If the file exists caching
13
+ will be used!
14
+
15
+
16
+ === 0.9.15 / 2010-03-20
17
+
18
+ * Revert changes from 0.9.14 because the fix does not work in all environments. Use the old code again
19
+ till a fix is found that circumvents the circular dependency issue and keeps the functionality of the tasks.
20
+
21
+ === 0.9.14 / 2010-03-14
22
+
23
+ * Do not use Buildr.projects because of a circular dependency issue with the new buildr thanks to
24
+ Pepijn Van Eeckhoudt: He has bumped into an issue in the ivy4r buildr extension that triggers
25
+ circular dependency exceptions. The culprit is the call to Buildr.projects in add_copy_tasks_for_publish.
26
+ This can cause a call to project.invoke on the project being defined itself. He has checked with the
27
+ buildr devs and they told me that Buildr.projects should probably not be called from before/after
28
+ define callbacks.
29
+
1
30
  === 0.9.13 / 2010-02-16
2
31
 
3
32
  * Fix problems with Facets and ActiveSupport. We now only include the required core extensions,
data/README.txt CHANGED
@@ -1,7 +1,6 @@
1
1
  = ivy4r
2
2
 
3
3
  * http://github.com/klaas1979/ivy4r/tree/master
4
- * http://hamburgrb.rubyforge.org/
5
4
 
6
5
  == DESCRIPTION:
7
6
 
@@ -9,12 +8,14 @@ Apache Ivy dependency manager wrapper for ruby (see {Apache Ivy}[http://ant.apac
9
8
  Use {Apache Ivy}[http://ant.apache.org/ivy/index.html] via a ruby wrapper without the need to use Apache Ant.
10
9
  The wrapper uses Antwrap[http://antwrap.rubyforge.org/] to interface with Ivy.
11
10
 
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.
11
+ Includes a Extension for Buildr[http://buildr.apache.org/] and Rake[http://rake.rubyforge.org] to use
12
+ {Apache Ivy}[http://ant.apache.org/ivy/index.html] for dependency management.
14
13
 
15
14
  == FEATURES/PROBLEMS:
16
15
 
17
- Supports most standard Ivy Ant targets via Antwrap.
16
+ Supports most standard Ivy Ant targets via Antwrap. Provides a caching feature so that long running ivy tasks
17
+ like resolve can be cached and are not rerun for local builds. For more information about caching see the History.txt
18
+ and checkout the source of buildr/ivy_extension.rb and rake/ivy_extension.rb.
18
19
 
19
20
  === Supported Ivy targets:
20
21
  * info
@@ -48,11 +49,19 @@ Supports most standard Ivy Ant targets via Antwrap.
48
49
  * cachefileset
49
50
  * var
50
51
 
52
+ === Caching of Ivy results:
53
+ For Buildr the targets ivy:enableresultcache, ivy:disableresultcache and ivy:cleanresultcache have been added.
54
+ Additionally the result cache can be enabled via the build.yaml or the global buildr settings.yaml by setting
55
+ the variable "ivy: caching.enabled: true".
56
+
57
+ For Rake the targets ivy:enableresultcache, ivy:disableresultcache and ivy:cleanresultcache have been added as
58
+ well. For Rake there is no other way to enable the caching beside this targets.
59
+
51
60
  == SYNOPSIS:
52
61
 
53
62
  To init a new Ivy4r instance set the ANT_HOME and the Ivy lib dir
54
63
  ivy4r = Ivy4r.new
55
- ivy4r.ant_home = 'PATH TO YOUR ANTHME'
64
+ ivy4r.ant_home = 'PATH TO YOUR ANTHOME'
56
65
  ivy4r.lib_dir = 'PATH TO IVY LIB DIR'
57
66
  as an alternative to setting the ANT_HOME you can set an +Antwrap+ instance directly:
58
67
  ivy4r.ant = Buildr.ant('ivy')
@@ -2,7 +2,7 @@ require 'ivy4r'
2
2
 
3
3
  module Buildr
4
4
  module Ivy
5
-
5
+
6
6
  class << self
7
7
  def setting(*keys)
8
8
  setting = Buildr.settings.build['ivy']
@@ -14,14 +14,14 @@ module Buildr
14
14
  class IvyConfig
15
15
  TARGETS = [:compile, :test, :package]
16
16
  TYPES = [:conf, :type, :include, :exclude]
17
-
17
+
18
18
  attr_accessor :extension_dir, :resolved
19
-
19
+
20
20
  attr_reader :post_resolve_task_list
21
21
 
22
22
  # Hash of all artifacts to publish with mapping from artifact name to ivy publish name
23
23
  attr_reader :publish_mappings
24
-
24
+
25
25
  # Store the current project and initialize ivy ant wrapper
26
26
  def initialize(project)
27
27
  @project = project
@@ -36,22 +36,28 @@ module Buildr
36
36
  |hash, key| hash[key] = {}
37
37
  end
38
38
  end
39
-
39
+
40
40
  def enabled?
41
41
  @enabled ||= Ivy.setting('enabled') || true
42
42
  end
43
-
43
+
44
44
  def own_file?
45
45
  @own_file ||= File.exists?(@project.path_to(file))
46
46
  end
47
-
47
+
48
48
  # Returns the correct ivy4r instance to use, if project has its own ivy file uses the ivy file
49
49
  # of project, if not uses the ivy file of parent project.
50
50
  # Use this for low-level access to ivy functions as needed, i.e. in +post_resolve+
51
51
  def ivy4r
52
52
  unless @ivy4r
53
53
  if own_file?
54
- @ivy4r = ::Ivy4r.new(@project.ant('ivy'))
54
+ @ivy4r = ::Ivy4r.new do |i|
55
+ i.ant = @project.ant('ivy')
56
+ if caching_enabled?
57
+ i.cache_dir = result_cache_dir
58
+ @project.send(:info, "Using IVY result caching in dir '#{i.cache_dir}'")
59
+ end
60
+ end
55
61
  @ivy4r.lib_dir = lib_dir if lib_dir
56
62
  @ivy4r.project_dir = @extension_dir
57
63
  else
@@ -60,12 +66,30 @@ module Buildr
60
66
  end
61
67
  @ivy4r
62
68
  end
63
-
69
+
70
+ # Returns if ivy result caching is enabled via build or user properties or by existence of the
71
+ # marker file.
72
+ def caching_enabled?
73
+ Buildr.settings.user['ivy']['caching.enabled'] || Ivy.setting('caching.enabled') || File.exists?(caching_marker)
74
+ end
75
+
76
+ # Returns the use ivy result caching marker file
77
+ def caching_marker
78
+ project.path_to('use_ivy_caching')
79
+ end
80
+
81
+ # Returns the dir to store ivy caching results in.
82
+ def result_cache_dir
83
+ dir = @project.path_to('target', 'ivycaching')
84
+ FileUtils.mkdir_p dir
85
+ dir
86
+ end
87
+
64
88
  # Returns name of the project the ivy file belongs to.
65
89
  def file_project
66
90
  own_file? ? @project : @base_ivy.file_project
67
91
  end
68
-
92
+
69
93
  # Returns the artifacts for given configurations as array
70
94
  # this is a post resolve task.
71
95
  # the arguments are checked for the following:
@@ -89,11 +113,11 @@ module Buildr
89
113
  pathid = "ivy.deps." + confs.join('.') + '.' + types.join('.')
90
114
  params = {:conf => confs.join(','), :pathid => pathid}
91
115
  params[:type] = types.join(',') unless types.nil? || types.size == 0
92
-
116
+
93
117
  ivy4r.cachepath params
94
118
  end
95
119
  end
96
-
120
+
97
121
  # Returns ivy info for configured ivy file using a new ivy4r instance.
98
122
  def info
99
123
  if @base_ivy
@@ -105,7 +129,7 @@ module Buildr
105
129
  result
106
130
  end
107
131
  end
108
-
132
+
109
133
  # Configures the ivy instance with additional properties and loading the settings file if it was provided
110
134
  def configure
111
135
  if @base_ivy
@@ -119,7 +143,7 @@ module Buildr
119
143
  end
120
144
  end
121
145
  end
122
-
146
+
123
147
  # Resolves the configured file once.
124
148
  def __resolve__
125
149
  if @base_ivy
@@ -132,7 +156,7 @@ module Buildr
132
156
  end
133
157
  end
134
158
  end
135
-
159
+
136
160
  # Returns the additional infos for the manifest file.
137
161
  def manifest
138
162
  if @base_ivy
@@ -145,18 +169,18 @@ module Buildr
145
169
  }
146
170
  end
147
171
  end
148
-
172
+
149
173
  # Creates the standard ivy dependency report
150
174
  def report
151
175
  ivy4r.report :todir => report_dir
152
176
  end
153
-
177
+
154
178
  # Cleans the ivy cache
155
179
  def cleancache
156
180
  ivy4r.cleancache
157
181
  end
158
-
159
-
182
+
183
+
160
184
  # Publishs the project as defined in ivy file if it has not been published already
161
185
  def __publish__
162
186
  if @base_ivy
@@ -170,11 +194,11 @@ module Buildr
170
194
  end
171
195
  end
172
196
  end
173
-
197
+
174
198
  def home
175
199
  @ivy_home_dir ||= Ivy.setting('home.dir') || "#{@extension_dir}/ivy-home"
176
200
  end
177
-
201
+
178
202
  def lib_dir
179
203
  @lib_dir ||= Ivy.setting('lib.dir')
180
204
  end
@@ -182,11 +206,11 @@ module Buildr
182
206
  def settings
183
207
  @settings ||= Ivy.setting('settings.file') || "#{@extension_dir}/ant-scripts/ivysettings.xml"
184
208
  end
185
-
209
+
186
210
  def file
187
211
  @ivy_file ||= Ivy.setting('ivy.file') || 'ivy.xml'
188
212
  end
189
-
213
+
190
214
  # Sets the revision to use for the project, this is useful for development revisions that
191
215
  # have an appended timestamp or any other dynamic revisioning.
192
216
  #
@@ -211,7 +235,7 @@ module Buildr
211
235
  self
212
236
  end
213
237
  end
214
-
238
+
215
239
  # Sets the status to use for the project, this is useful for custom status handling
216
240
  # like integration, alpha, gold.
217
241
  #
@@ -236,7 +260,7 @@ module Buildr
236
260
  self
237
261
  end
238
262
  end
239
-
263
+
240
264
  # Sets the publish options to use for the project. The options are merged with the default
241
265
  # options including value set via #publish_from and overwrite all of them.
242
266
  #
@@ -264,7 +288,7 @@ module Buildr
264
288
  end
265
289
  end
266
290
  end
267
-
291
+
268
292
  # Sets the additional properties for the ivy process use a Hash with the properties to set.
269
293
  def properties(*properties)
270
294
  if properties.empty?
@@ -275,7 +299,7 @@ module Buildr
275
299
  self
276
300
  end
277
301
  end
278
-
302
+
279
303
  # Sets the local repository for ivy files
280
304
  def local_repository(*local_repository)
281
305
  if local_repository.empty?
@@ -291,7 +315,7 @@ module Buildr
291
315
  self
292
316
  end
293
317
  end
294
-
318
+
295
319
  # :call-seq:
296
320
  # ivy.publish(package(:jar) => 'new_name_without_version_number.jar')
297
321
  # #deprecated! ivy.name(package(:jar) => 'new_name_without_version_number.jar')
@@ -314,7 +338,7 @@ module Buildr
314
338
  puts "name(*args) is deprecated use publish(*args)!"
315
339
  publish(*args)
316
340
  end
317
-
341
+
318
342
  # Sets the directory to publish artifacts from.
319
343
  def publish_from(*publish_dir)
320
344
  if publish_dir.empty?
@@ -330,7 +354,7 @@ module Buildr
330
354
  self
331
355
  end
332
356
  end
333
-
357
+
334
358
  # Sets the directory to create dependency reports in.
335
359
  def report_dir(*report_dir)
336
360
  if report_dir.empty?
@@ -346,14 +370,14 @@ module Buildr
346
370
  self
347
371
  end
348
372
  end
349
-
373
+
350
374
  # Adds given block as post resolve action that is executed directly after #resolve has been called.
351
375
  # Yields this ivy config object into block.
352
376
  # <tt>project.ivy.post_resolve { |ivy| p "all deps:" + ivy.deps('all').join(", ") }</tt>
353
377
  def post_resolve(&block)
354
378
  post_resolve_tasks << block if block
355
379
  end
356
-
380
+
357
381
  # Filter artifacts for given configuration with provided filter values, this is a post resolve
358
382
  # task like #deps.
359
383
  # <tt>project.ivy.filter('server', 'client', :include => /b.*.jar/, :exclude => [/a\.jar/, /other.*\.jar/])</tt>
@@ -363,7 +387,7 @@ module Buildr
363
387
  raise ArgumentError, "Invalid filter use :include and/or :exclude only: given #{filter.keys.inspect}"
364
388
  end
365
389
  includes, excludes, types = filter[:include] || [], filter[:exclude] || [], filter[:type] || []
366
-
390
+
367
391
  artifacts = deps(confs.flatten, types.flatten)
368
392
  if artifacts
369
393
  artifacts = artifacts.find_all do |lib|
@@ -373,10 +397,10 @@ module Buildr
373
397
  should_include && !excludes.any? {|exclude| exclude === lib}
374
398
  end
375
399
  end
376
-
400
+
377
401
  artifacts
378
402
  end
379
-
403
+
380
404
  # :call-seq:
381
405
  # for types:
382
406
  # project.ivy.include(:compile => [/\.jar/, /\.gz/], :package => 'cglib.jar')
@@ -419,41 +443,41 @@ module Buildr
419
443
  t = targets.to_s.split('_').find { |target| TARGETS.member? target.to_sym }
420
444
  t ? t.to_sym : nil
421
445
  end
422
-
446
+
423
447
  def type(types)
424
448
  t = types.to_s.split('_').find { |type| TYPES.member? type.to_sym }
425
449
  t ? t.to_sym : nil
426
450
  end
427
-
451
+
428
452
  def valid_config_call?(method_name)
429
453
  valid_calls = []
430
454
  TYPES.each do|type|
431
- TARGETS.each do|target|
432
- valid_calls << type.to_s << target.to_s << "#{type}_#{target}" << "#{target}_#{type}"
433
- end
434
- end
435
- valid_calls.member? method_name.to_s
436
- end
437
-
438
- # Sets a variable for given basename and type to given values. If values are empty returns the
439
- # current value.
440
- # I.e. <tt>handle_variable(:package, :include, /blua.*\.jar/, /da.*\.jar/)</tt>
441
- def handle_variable(target, type, *values)
442
- unless TARGETS.member?(target) && TYPES.member?(type)
443
- raise ArgumentError, "Unknown config value for target #{target.inspect} and type #{type.inspect}"
444
- end
445
- if values.empty?
446
- @target_config[target][type] ||= [Ivy.setting("#{target.to_s}.#{type.to_s}") || ''].flatten.uniq
447
- else
448
- @target_config[target][type] = [values].flatten.uniq
449
- self
450
- end
451
- end
452
-
453
- def post_resolve_tasks
454
- @base_ivy ? @base_ivy.post_resolve_task_list : post_resolve_task_list
455
+ TARGETS.each do|target|
456
+ valid_calls << type.to_s << target.to_s << "#{type}_#{target}" << "#{target}_#{type}"
455
457
  end
456
458
  end
459
+ valid_calls.member? method_name.to_s
460
+ end
461
+
462
+ # Sets a variable for given basename and type to given values. If values are empty returns the
463
+ # current value.
464
+ # I.e. <tt>handle_variable(:package, :include, /blua.*\.jar/, /da.*\.jar/)</tt>
465
+ def handle_variable(target, type, *values)
466
+ unless TARGETS.member?(target) && TYPES.member?(type)
467
+ raise ArgumentError, "Unknown config value for target #{target.inspect} and type #{type.inspect}"
468
+ end
469
+ if values.empty?
470
+ @target_config[target][type] ||= [Ivy.setting("#{target.to_s}.#{type.to_s}") || ''].flatten.uniq
471
+ else
472
+ @target_config[target][type] = [values].flatten.uniq
473
+ self
474
+ end
475
+ end
476
+
477
+ def post_resolve_tasks
478
+ @base_ivy ? @base_ivy.post_resolve_task_list : post_resolve_task_list
479
+ end
480
+ end
457
481
 
458
482
  =begin rdoc
459
483
  The Ivy Buildr extension adding the new tasks for ivy.
@@ -475,229 +499,271 @@ To use ivy in a +buildfile+ do something like:
475
499
 
476
500
  For more configuration options see IvyConfig.
477
501
  =end
478
- module IvyExtension
479
- include Buildr::Extension
480
-
481
- class << self
482
-
483
- def add_ivy_deps_to_java_tasks(project)
484
- resolve_target = project.ivy.file_project.task('ivy:resolve')
485
- project.task :compiledeps => resolve_target do
486
- includes = project.ivy.compile_include
487
- excludes = project.ivy.compile_exclude
488
- types = project.ivy.compile_type
489
- confs = [project.ivy.compile_conf].flatten
490
- if deps = project.ivy.filter(confs, :type => types, :include => includes, :exclude => excludes)
491
- project.compile.with [deps, project.compile.dependencies].flatten
492
- sort_dependencies(project.compile.dependencies, deps, project.path_to(''))
493
- info "Ivy adding compile dependencies '#{confs.join(', ')}' to project '#{project.name}'"
494
- end
495
- end
496
-
497
- project.task :compile => "#{project.name}:compiledeps"
498
-
499
- project.task :testdeps => resolve_target do
500
- includes = project.ivy.test_include
501
- excludes = project.ivy.test_exclude
502
- types = project.ivy.test_type
503
- confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq
504
- if deps = project.ivy.filter(confs, :type => types, :include => includes, :exclude => excludes)
505
- project.test.with [deps, project.test.dependencies].flatten
506
- sort_dependencies(project.test.dependencies, deps, project.path_to(''))
507
- sort_dependencies(project.test.compile.dependencies, deps, project.path_to(''))
508
- info "Ivy adding test dependencies '#{confs.join(', ')}' to project '#{project.name}'"
509
- end
510
- end
511
- project.task "test:compile" => "#{project.name}:testdeps"
512
-
513
- project.task :javadocdeps => resolve_target do
514
- confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq
515
- if deps = project.ivy.deps(confs)
516
- project.javadoc.with deps
517
- info "Ivy adding javadoc dependencies '#{confs.join(', ')}' to project '#{project.name}'"
518
- end
519
- end
520
- project.task :javadoc => "#{project.name}:javadocdeps"
521
-
522
- [project.task(:eclipse), project.task(:idea), project.task(:idea7x)].each do |task|
523
- task.prerequisites.each{|p| p.enhance ["#{project.name}:compiledeps", "#{project.name}:testdeps"]}
524
- end
502
+ module IvyExtension
503
+ include Buildr::Extension
504
+
505
+ class << self
506
+
507
+ def add_ivy_deps_to_java_tasks(project)
508
+ resolve_target = project.ivy.file_project.task('ivy:resolve')
509
+ project.task :compiledeps => resolve_target do
510
+ includes = project.ivy.compile_include
511
+ excludes = project.ivy.compile_exclude
512
+ types = project.ivy.compile_type
513
+ confs = [project.ivy.compile_conf].flatten
514
+ if deps = project.ivy.filter(confs, :type => types, :include => includes, :exclude => excludes)
515
+ project.compile.with [deps, project.compile.dependencies].flatten
516
+ sort_dependencies(project.compile.dependencies, deps, project.path_to(''))
517
+ info "Ivy adding compile dependencies '#{confs.join(', ')}' to project '#{project.name}'"
525
518
  end
526
-
527
- # Sorts the dependencies in #deps replacing the old order.
528
- # Sorting is done as follows:
529
- # 1. all dependencies that belong to the project identified by #project_path,
530
- # .i.e. instrumented-classes, resources in the order the are contained in the array
531
- # 2. all ivy dependencies identified by #ivy_deps
532
- # 3. all dependencies added automatically by buildr
533
- def sort_dependencies(deps, ivy_deps, project_path)
534
- old_deps = deps.dup
535
- belongs_to_project = /#{project_path}/
536
- deps.sort! do |a, b|
537
- a_belongs_to_project = belongs_to_project.match(a.to_s)
538
- b_belongs_to_project = belongs_to_project.match(b.to_s)
539
- a_ivy = ivy_deps.member? a
540
- b_ivy = ivy_deps.member? b
541
-
542
- if a_belongs_to_project && !b_belongs_to_project
543
- -1
544
- elsif !a_belongs_to_project && b_belongs_to_project
545
- 1
546
- elsif a_ivy && !b_ivy
547
- -1
548
- elsif !a_ivy && b_ivy
549
- 1
550
- else
551
- old_deps.index(a) <=> old_deps.index(b)
552
- end
553
- end
519
+ end
520
+
521
+ project.task :compile => "#{project.name}:compiledeps"
522
+
523
+ project.task :testdeps => resolve_target do
524
+ includes = project.ivy.test_include
525
+ excludes = project.ivy.test_exclude
526
+ types = project.ivy.test_type
527
+ confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq
528
+ if deps = project.ivy.filter(confs, :type => types, :include => includes, :exclude => excludes)
529
+ project.test.with [deps, project.test.dependencies].flatten
530
+ sort_dependencies(project.test.dependencies, deps, project.path_to(''))
531
+ sort_dependencies(project.test.compile.dependencies, deps, project.path_to(''))
532
+ info "Ivy adding test dependencies '#{confs.join(', ')}' to project '#{project.name}'"
533
+ end
534
+ end
535
+ project.task "test:compile" => "#{project.name}:testdeps"
536
+
537
+ project.task :javadocdeps => resolve_target do
538
+ confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq
539
+ if deps = project.ivy.deps(confs)
540
+ project.javadoc.with deps
541
+ info "Ivy adding javadoc dependencies '#{confs.join(', ')}' to project '#{project.name}'"
554
542
  end
555
-
556
- def add_manifest_to_distributeables(project)
557
- pkgs = project.packages.find_all { |pkg| ['jar', 'war', 'ear'].member? pkg.type.to_s }
558
- pkgs.each do |pkg|
559
- name = "#{pkg.name}manifest"
560
- task = project.task name => project.ivy.file_project.task('ivy:resolve') do
561
- pkg.with :manifest => pkg.manifest.merge(project.manifest.merge(project.ivy.manifest))
562
- info "Adding manifest entries to package '#{pkg.name}'"
563
- end
564
- project.task :build => task
565
- end
543
+ end
544
+ project.task :javadoc => "#{project.name}:javadocdeps"
545
+
546
+ [project.task(:eclipse), project.task(:idea), project.task(:idea7x)].each do |task|
547
+ task.prerequisites.each{|p| p.enhance ["#{project.name}:compiledeps", "#{project.name}:testdeps"]}
548
+ end
549
+ end
550
+
551
+ # Sorts the dependencies in #deps replacing the old order.
552
+ # Sorting is done as follows:
553
+ # 1. all dependencies that belong to the project identified by #project_path,
554
+ # .i.e. instrumented-classes, resources in the order the are contained in the array
555
+ # 2. all ivy dependencies identified by #ivy_deps
556
+ # 3. all dependencies added automatically by buildr
557
+ def sort_dependencies(deps, ivy_deps, project_path)
558
+ old_deps = deps.dup
559
+ belongs_to_project = /#{project_path}/
560
+ deps.sort! do |a, b|
561
+ a_belongs_to_project = belongs_to_project.match(a.to_s)
562
+ b_belongs_to_project = belongs_to_project.match(b.to_s)
563
+ a_ivy = ivy_deps.member? a
564
+ b_ivy = ivy_deps.member? b
565
+
566
+ if a_belongs_to_project && !b_belongs_to_project
567
+ -1
568
+ elsif !a_belongs_to_project && b_belongs_to_project
569
+ 1
570
+ elsif a_ivy && !b_ivy
571
+ -1
572
+ elsif !a_ivy && b_ivy
573
+ 1
574
+ else
575
+ old_deps.index(a) <=> old_deps.index(b)
566
576
  end
567
-
568
- def add_prod_libs_to_distributeables(project)
569
- pkgs = project.packages.find_all { |pkg| ['war'].member? pkg.type.to_s }
570
- pkgs.each do |pkg|
571
- task = project.task "#{pkg.name}deps" => project.ivy.file_project.task('ivy:resolve') do
572
- includes = project.ivy.package_include
573
- excludes = project.ivy.package_exclude
574
- types = project.ivy.package_type
575
- confs = project.ivy.package_conf
576
- if deps = project.ivy.filter(confs, :type => types, :include => includes, :exclude => excludes)
577
- pkg.with :libs => [deps, pkg.libs].flatten
578
- info "Adding production libs from conf '#{confs.join(', ')}' to WAR '#{pkg.name}' in project '#{project.name}'"
579
- end
580
- end
581
- project.task :build => task
582
- end
583
-
584
- pkgs = project.packages.find_all { |pkg| ['ear'].member? pkg.type.to_s }
585
- pkgs.each do |pkg|
586
- task = project.task "#{pkg.name}deps" => project.ivy.file_project.task('ivy:resolve') do
587
- includes = project.ivy.package_include
588
- excludes = project.ivy.package_exclude
589
- types = project.ivy.package_type
590
- confs = project.ivy.package_conf
591
- if deps = project.ivy.filter(confs, :type => types, :include => includes, :exclude => excludes)
592
- pkg.add deps, :type => :lib, :path => ''
593
- info "Adding production libs from conf '#{confs.join(', ')}' to EAR '#{pkg.name}' in project '#{project.name}'"
594
- end
595
- end
596
- project.task :build => task
597
- end
577
+ end
578
+ end
579
+
580
+ def add_manifest_to_distributeables(project)
581
+ pkgs = project.packages.find_all { |pkg| ['jar', 'war', 'ear'].member? pkg.type.to_s }
582
+ pkgs.each do |pkg|
583
+ name = "#{pkg.name}manifest"
584
+ task = project.task name => project.ivy.file_project.task('ivy:resolve') do
585
+ pkg.with :manifest => pkg.manifest.merge(project.manifest.merge(project.ivy.manifest))
586
+ info "Adding manifest entries to package '#{pkg.name}'"
598
587
  end
599
-
600
- def add_copy_tasks_for_publish(project)
601
- if project.ivy.own_file?
602
- Buildr.projects.each do |current|
603
- current.packages.each do |pkg|
604
- target_file = current.ivy.name[pkg] || File.basename(pkg.name).gsub(/-#{project.version}/, '')
605
- taskname = current.path_to(project.ivy.publish_from, target_file)
606
- if taskname != pkg.name
607
- project.file taskname => pkg.name do
608
- verbose "Ivy copying '#{pkg.name}' to '#{taskname}' for publishing"
609
- FileUtils.mkdir File.dirname(taskname) unless File.directory?(File.dirname(taskname))
610
- FileUtils.cp pkg.name, taskname
611
- end
612
- end
613
- project.task 'ivy:publish' => taskname
614
- end
615
- end
588
+ project.task :build => task
589
+ end
590
+ end
591
+
592
+ def add_prod_libs_to_distributeables(project)
593
+ pkgs = project.packages.find_all { |pkg| ['war'].member? pkg.type.to_s }
594
+ pkgs.each do |pkg|
595
+ task = project.task "#{pkg.name}deps" => project.ivy.file_project.task('ivy:resolve') do
596
+ includes = project.ivy.package_include
597
+ excludes = project.ivy.package_exclude
598
+ types = project.ivy.package_type
599
+ confs = project.ivy.package_conf
600
+ if deps = project.ivy.filter(confs, :type => types, :include => includes, :exclude => excludes)
601
+ pkg.with :libs => [deps, pkg.libs].flatten
602
+ info "Adding production libs from conf '#{confs.join(', ')}' to WAR '#{pkg.name}' in project '#{project.name}'"
616
603
  end
617
604
  end
605
+ project.task :build => task
618
606
  end
619
-
620
- # Returns the +ivy+ configuration for the project. Use this to configure Ivy.
621
- # see IvyConfig for more details about configuration options.
622
- def ivy
623
- @ivy_config ||= IvyConfig.new(self)
624
- end
625
-
626
- first_time do
627
- namespace 'ivy' do
628
- desc 'Resolves the ivy dependencies'
629
- task :resolve
630
-
631
- desc 'Publish the artifacts to ivy repository as defined by environment'
632
- task :publish
633
-
634
- desc 'Creates a dependency report for the project'
635
- task :report
636
607
 
637
- desc 'Clean the local Ivy cache and the local ivy repository'
638
- task :clean
608
+ pkgs = project.packages.find_all { |pkg| ['ear'].member? pkg.type.to_s }
609
+ pkgs.each do |pkg|
610
+ task = project.task "#{pkg.name}deps" => project.ivy.file_project.task('ivy:resolve') do
611
+ includes = project.ivy.package_include
612
+ excludes = project.ivy.package_exclude
613
+ types = project.ivy.package_type
614
+ confs = project.ivy.package_conf
615
+ if deps = project.ivy.filter(confs, :type => types, :include => includes, :exclude => excludes)
616
+ pkg.add deps, :type => :lib, :path => ''
617
+ info "Adding production libs from conf '#{confs.join(', ')}' to EAR '#{pkg.name}' in project '#{project.name}'"
618
+ end
639
619
  end
620
+ project.task :build => task
640
621
  end
641
-
642
- after_define do |project|
643
- if project.ivy.enabled?
644
- IvyExtension.add_ivy_deps_to_java_tasks(project)
645
- IvyExtension.add_manifest_to_distributeables(project)
646
- IvyExtension.add_prod_libs_to_distributeables(project)
647
- IvyExtension.add_copy_tasks_for_publish(project)
648
-
649
- namespace 'ivy' do
650
- task :configure do
651
- project.ivy.configure
652
- end
653
-
654
- task :clean => :configure do
655
- # TODO This is redundant, refactor ivy_ant_wrap and this to use a single config object
656
- rm_rf project.path_to(:reports, 'ivy')
657
- project.ivy.cleancache
658
- end
659
-
660
- task :resolve => "#{project.name}:ivy:configure" do
661
- project.ivy.__resolve__
662
- end
663
-
664
- task :report => "#{project.name}:ivy:resolve" do
665
- project.ivy.report
666
- end
667
-
668
- task :publish => "#{project.name}:ivy:resolve" do
669
- project.ivy.__publish__
622
+ end
623
+
624
+ def add_copy_tasks_for_publish(project)
625
+ if project.ivy.own_file?
626
+ Buildr.projects.each do |current|
627
+ current.packages.each do |pkg|
628
+ target_file = current.ivy.name[pkg] || File.basename(pkg.name).gsub(/-#{project.version}/, '')
629
+ taskname = current.path_to(project.ivy.publish_from, target_file)
630
+ if taskname != pkg.name
631
+ project.file taskname => pkg.name do
632
+ verbose "Ivy copying '#{pkg.name}' to '#{taskname}' for publishing"
633
+ FileUtils.mkdir File.dirname(taskname) unless File.directory?(File.dirname(taskname))
634
+ FileUtils.cp pkg.name, taskname
635
+ end
670
636
  end
637
+ project.task 'ivy:publish' => taskname
671
638
  end
672
639
  end
673
640
  end
674
641
  end
675
-
676
- # Global targets that are not bound to a project
642
+ end
643
+
644
+ # Returns the +ivy+ configuration for the project. Use this to configure Ivy.
645
+ # see IvyConfig for more details about configuration options.
646
+ def ivy
647
+ @ivy_config ||= IvyConfig.new(self)
648
+ end
649
+
650
+ first_time do
677
651
  namespace 'ivy' do
678
- task :clean do
679
- Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
680
- project.task('ivy:clean').invoke
652
+ desc 'Resolves the ivy dependencies'
653
+ task :resolve
654
+
655
+ desc 'Publish the artifacts to ivy repository as defined by environment'
656
+ task :publish
657
+
658
+ desc 'Creates a dependency report for the project'
659
+ task :report
660
+
661
+ desc 'Clean the local Ivy cache and the local ivy repository'
662
+ task :clean
663
+
664
+ desc 'Clean the local Ivy result cache to force execution of ivy targets'
665
+ task :cleanresultcache
666
+
667
+ desc 'Enable the local Ivy result cache by creating the marker file'
668
+ task :enableresultcache
669
+
670
+ desc 'Disable the local Ivy result cache by removing the marker file'
671
+ task :disableresultcache
672
+ end
673
+ end
674
+
675
+ after_define do |project|
676
+ if project.ivy.enabled?
677
+ IvyExtension.add_ivy_deps_to_java_tasks(project)
678
+ IvyExtension.add_manifest_to_distributeables(project)
679
+ IvyExtension.add_prod_libs_to_distributeables(project)
680
+ IvyExtension.add_copy_tasks_for_publish(project)
681
+
682
+ namespace 'ivy' do
683
+ task :configure do
684
+ project.ivy.configure
681
685
  end
682
- end
683
-
684
- task :resolve do
685
- info "Resolving all distinct ivy files"
686
- Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
687
- project.task('ivy:resolve').invoke
686
+
687
+ task :clean => :configure do
688
+ # TODO This is redundant, refactor ivy_ant_wrap and this to use a single config object
689
+ rm_rf project.path_to(:reports, 'ivy')
690
+ project.ivy.cleancache
688
691
  end
689
- end
690
-
691
- task :publish => :package do
692
- info "Publishing all distinct ivy files"
693
- Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
694
- project.task('ivy:publish').invoke
692
+
693
+ task :cleanresultcache do
694
+ project.send(:info, "Deleting IVY result cache dir '#{project.ivy.result_cache_dir}'")
695
+ rm_rf project.ivy.result_cache_dir
696
+ end
697
+
698
+ task :enableresultcache do
699
+ project.send(:info, "Creating IVY caching marker file '#{project.ivy.caching_marker}'")
700
+ touch project.ivy.caching_marker
701
+ end
702
+
703
+ task :disableresultcache do
704
+ project.send(:info, "Deleting IVY aching marker file '#{project.ivy.caching_marker}'")
705
+ rm_f project.ivy.caching_marker
706
+ end
707
+
708
+ task :resolve => "#{project.name}:ivy:configure" do
709
+ project.ivy.__resolve__
710
+ end
711
+
712
+ task :report => "#{project.name}:ivy:resolve" do
713
+ project.ivy.report
714
+ end
715
+
716
+ task :publish => "#{project.name}:ivy:resolve" do
717
+ project.ivy.__publish__
695
718
  end
696
719
  end
697
720
  end
721
+ end
722
+ end
698
723
 
699
- class Buildr::Project # :nodoc:
700
- include IvyExtension
724
+ # Global targets that are not bound to a project
725
+ namespace 'ivy' do
726
+ task :clean do
727
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
728
+ project.task('ivy:clean').invoke
729
+ end
730
+ end
731
+
732
+ task :cleanresultcache do
733
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
734
+ project.task('ivy:cleanresultcache').invoke
701
735
  end
702
736
  end
737
+
738
+ task :enableresultcache do
739
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
740
+ project.task('ivy:enableresultcache').invoke
741
+ end
742
+ end
743
+
744
+ task :disableresultcache do
745
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
746
+ project.task('ivy:disableresultcache').invoke
747
+ end
748
+ end
749
+
750
+ task :resolve do
751
+ info "Resolving all distinct ivy files"
752
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
753
+ project.task('ivy:resolve').invoke
754
+ end
755
+ end
756
+
757
+ task :publish => :package do
758
+ info "Publishing all distinct ivy files"
759
+ Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
760
+ project.task('ivy:publish').invoke
761
+ end
762
+ end
763
+ end
764
+
765
+ class Buildr::Project # :nodoc:
766
+ include IvyExtension
767
+ end
768
+ end
703
769
  end