ivy4r 0.9.15 → 0.10.0
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.
- data/History.txt +29 -0
- data/README.txt +14 -5
- data/lib/buildr/ivy_extension.rb +328 -262
- data/lib/ivy/target.rb +80 -50
- data/lib/ivy4r.rb +62 -49
- data/lib/rake/ivy_extension.rb +89 -56
- metadata +4 -4
data/lib/ivy/target.rb
CHANGED
@@ -3,16 +3,20 @@ require 'facets/to_hash'
|
|
3
3
|
require 'facets/hash/op'
|
4
4
|
require 'facets/hash/update_values'
|
5
5
|
|
6
|
-
|
6
|
+
require 'digest/md5'
|
7
7
|
|
8
|
+
module Ivy
|
9
|
+
|
8
10
|
# Base class with general logic to call a Ivy ant target
|
9
11
|
class Target
|
10
12
|
attr_reader :params
|
11
|
-
|
12
|
-
def initialize(ant)
|
13
|
+
|
14
|
+
def initialize(ant, cache_dir = nil)
|
15
|
+
raise "Cache result directory does not exists '#{cache_dir}'" if cache_dir != nil && !File.directory?(cache_dir)
|
13
16
|
@ant = ant
|
17
|
+
@cache_dir = cache_dir
|
14
18
|
end
|
15
|
-
|
19
|
+
|
16
20
|
# Executes this ivy target with given parameters returning a result.
|
17
21
|
# __params__ can be a single Hash or an Array with or without a Hash as last value.
|
18
22
|
# every value in array will be converted to string and set to __true__.
|
@@ -23,7 +27,35 @@ module Ivy
|
|
23
27
|
@params = {}
|
24
28
|
params.pop.each { |key, value| @params[key] = value } if Hash === params.last
|
25
29
|
params.each { |key| @params[key.to_s] = true }
|
26
|
-
|
30
|
+
if caching_enabled? && File.exists?(cache_file_path)
|
31
|
+
load_from_yaml
|
32
|
+
else
|
33
|
+
result = execute_target
|
34
|
+
dump_to_yaml(result) if caching_enabled?
|
35
|
+
result
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def caching_enabled?
|
42
|
+
@cache_dir != nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def cache_file_path
|
46
|
+
@cache_file_path ||= File.expand_path(File.join(@cache_dir, Digest::MD5.hexdigest(self.class.to_s + @params.to_s) + '.yaml'))
|
47
|
+
end
|
48
|
+
|
49
|
+
def load_from_yaml
|
50
|
+
File.open(cache_file_path) {|f| YAML::load(f)}
|
51
|
+
end
|
52
|
+
|
53
|
+
def dump_to_yaml(result)
|
54
|
+
File.open(cache_file_path, 'w') {|f| YAML.dump(result, f)}
|
55
|
+
end
|
56
|
+
|
57
|
+
# The bare bone execution of this target without any crosscutting concerns.
|
58
|
+
def execute_target
|
27
59
|
validate
|
28
60
|
before_hook
|
29
61
|
execute_ivy
|
@@ -31,8 +63,6 @@ module Ivy
|
|
31
63
|
ensure
|
32
64
|
after_hook
|
33
65
|
end
|
34
|
-
|
35
|
-
protected
|
36
66
|
|
37
67
|
# Validates provided hash of parameters, raises an exception if any mandatory parameter is
|
38
68
|
# missing or an unknown parameter has been provided.
|
@@ -42,17 +72,17 @@ module Ivy
|
|
42
72
|
missing = symbols(mandatory_parameter).find_all { |p| params.keys.member?(p) == false }
|
43
73
|
raise ArgumentError, "Missing mandatory parameters '#{missing.join(', ')}' for #{self.class}" unless missing.empty?
|
44
74
|
end
|
45
|
-
|
75
|
+
|
46
76
|
# Hook method called after validation but before #execute_ivy
|
47
77
|
# overwrite for special actions needed
|
48
78
|
def before_hook
|
49
79
|
end
|
50
|
-
|
51
|
-
# After hook is always called for #
|
80
|
+
|
81
|
+
# After hook is always called for #execute_target within +ensure+ block
|
52
82
|
# overwrite for special clean up
|
53
83
|
def after_hook
|
54
84
|
end
|
55
|
-
|
85
|
+
|
56
86
|
# Helper to call the nested ant targets recursively if nessecary. Must be called within +do+ +end+
|
57
87
|
# block of ant target to work.
|
58
88
|
def call_nested(nested)
|
@@ -70,7 +100,7 @@ module Ivy
|
|
70
100
|
end
|
71
101
|
end
|
72
102
|
end
|
73
|
-
|
103
|
+
|
74
104
|
# Creates the result for the execution by default it iterates of the ant properties and fetches
|
75
105
|
# all properties that match the result properties for target as a hash. Overwrite to provide
|
76
106
|
# a different result
|
@@ -83,49 +113,49 @@ module Ivy
|
|
83
113
|
result = ant_properties.map do |p|
|
84
114
|
rp = result_property_values.find { |rp| rp.matcher === p[0] }
|
85
115
|
rp ? [p[0], rp.parse(p[1])].flatten : nil
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
116
|
+
end.compact.to_h(:multi)
|
117
|
+
result.update_values do |v|
|
118
|
+
case v.size
|
119
|
+
when 0
|
120
|
+
nil
|
121
|
+
when 1
|
122
|
+
v[0]
|
123
|
+
else
|
124
|
+
v
|
125
|
+
end
|
95
126
|
end
|
127
|
+
|
128
|
+
result
|
129
|
+
end
|
130
|
+
|
131
|
+
def mandatory_parameter
|
132
|
+
parameter.find_all {|p| p.mandatory? }
|
133
|
+
end
|
134
|
+
|
135
|
+
def symbols(params)
|
136
|
+
params.map{|p| p.symbol}
|
137
|
+
end
|
138
|
+
|
139
|
+
def ant_properties
|
140
|
+
@ant.project.properties
|
141
|
+
end
|
142
|
+
|
143
|
+
def ant_references
|
144
|
+
@ant.project.references
|
96
145
|
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
146
|
end
|
108
147
|
|
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
148
|
COMMA_SPLITTER = Proc.new {|value| value.to_s.split(',').map(&:strip)}
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
149
|
+
|
150
|
+
Parameter = Struct.new(:symbol, :mandatory) do
|
151
|
+
def mandatory?
|
152
|
+
mandatory
|
153
|
+
end
|
123
154
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
155
|
+
|
156
|
+
ResultValue = Struct.new(:matcher, :parser) do
|
157
|
+
def parse(value)
|
158
|
+
parser ? parser.call(value) : value
|
159
|
+
end
|
129
160
|
end
|
130
161
|
end
|
131
|
-
end
|
data/lib/ivy4r.rb
CHANGED
@@ -35,129 +35,142 @@ is
|
|
35
35
|
}
|
36
36
|
=end
|
37
37
|
class Ivy4r
|
38
|
-
VERSION = '0.
|
39
|
-
|
38
|
+
VERSION = '0.10.0'
|
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.
|
42
42
|
# Must be set before any call to method that uses the ivy is made.
|
43
43
|
attr_accessor :ant_home
|
44
|
-
|
44
|
+
|
45
45
|
# Defines the directory to load ivy libs and its dependencies from
|
46
46
|
attr_accessor :lib_dir
|
47
|
-
|
47
|
+
|
48
48
|
# Optional ant variable <tt>ivy.project.dir</tt> to add to ant environment before loading ivy
|
49
49
|
# defaults to the __lib_dir__
|
50
50
|
attr_accessor :project_dir
|
51
|
-
|
51
|
+
|
52
52
|
# The ant property name to use for references to environment properties in ant and ivy,
|
53
53
|
# defaults to 'env'
|
54
54
|
attr_accessor :environment_property
|
55
|
-
|
55
|
+
|
56
56
|
# To provide a custom __antwrap__ to use instead of default one
|
57
|
-
|
58
|
-
|
57
|
+
attr_accessor :ant
|
58
|
+
|
59
59
|
# Access to ivy settings set via configure or settings method.
|
60
60
|
attr_accessor :settings_file
|
61
|
-
|
61
|
+
|
62
|
+
# Donates the base directory for the cached files, if nil no caching is enabled
|
63
|
+
attr_accessor :cache_dir
|
64
|
+
|
62
65
|
# Initalizes ivy4r with optional ant wrapper object. Sets ant home dir and ivy lib dir
|
63
66
|
# to default values from __Ivy4rJars__ gem.
|
64
|
-
def initialize(
|
67
|
+
def initialize(ant_instance = nil, &block)
|
65
68
|
@ant_home = ::Ivy4rJars.ant_home_dir
|
66
69
|
@lib_dir = ::Ivy4rJars.lib_dir
|
67
70
|
@project_dir = @lib_dir
|
68
71
|
@environment_property = 'env'
|
69
|
-
@ant =
|
72
|
+
@ant = ant_instance
|
73
|
+
|
74
|
+
if block
|
75
|
+
if block.arity > 1
|
76
|
+
raise ArgumentError, "To many arguments expected=1 given=#{block.arity}"
|
77
|
+
elsif block.arity == 1
|
78
|
+
yield self
|
79
|
+
else
|
80
|
+
instance_eval(&block)
|
81
|
+
end
|
82
|
+
end
|
70
83
|
end
|
71
|
-
|
84
|
+
|
72
85
|
# Calls the __cleancache__ ivy target with given parameters.
|
73
86
|
def cleancache(*params)
|
74
|
-
Ivy::Cleancache.new(ant).execute(*params)
|
87
|
+
Ivy::Cleancache.new(ant, cache_dir).execute(*params)
|
75
88
|
end
|
76
|
-
|
89
|
+
|
77
90
|
# Calls the __settings__ ivy target with given parameters.
|
78
91
|
def settings(*params)
|
79
|
-
settings_task = Ivy::Settings.new(ant)
|
92
|
+
settings_task = Ivy::Settings.new(ant, nil) # do not cache settings
|
80
93
|
result = settings_task.execute(*params)
|
81
94
|
@settings_file = settings_task.params[:file]
|
82
95
|
result
|
83
96
|
end
|
84
|
-
|
97
|
+
|
85
98
|
# Calls the __configure__ ivy target with given parameters.
|
86
99
|
def configure(*params)
|
87
|
-
configure_task = Ivy::Configure.new(ant)
|
100
|
+
configure_task = Ivy::Configure.new(ant, nil) # do not cache configure
|
88
101
|
result = configure_task.execute(*params)
|
89
102
|
@settings_file = configure_task.params[:file]
|
90
103
|
result
|
91
104
|
end
|
92
|
-
|
105
|
+
|
93
106
|
# Calls the __info__ ivy target with given parameters and returns info as hash.
|
94
107
|
def info(*params)
|
95
|
-
Ivy::Info.new(ant).execute(*params)
|
108
|
+
Ivy::Info.new(ant, cache_dir).execute(*params)
|
96
109
|
end
|
97
|
-
|
110
|
+
|
98
111
|
# Calls the __buildnumber__ ivy target with given parameters and returns info as hash.
|
99
112
|
def buildnumber(*params)
|
100
|
-
Ivy::Buildnumber.new(ant).execute(*params)
|
113
|
+
Ivy::Buildnumber.new(ant, cache_dir).execute(*params)
|
101
114
|
end
|
102
|
-
|
115
|
+
|
103
116
|
# Calls the __listmodules__ ivy target with given parameters and returns info as hash.
|
104
117
|
def listmodules(*params) #:nodoc:
|
105
|
-
Ivy::Listmodules.new(ant).execute(*params)
|
118
|
+
Ivy::Listmodules.new(ant, cache_dir).execute(*params)
|
106
119
|
end
|
107
|
-
|
120
|
+
|
108
121
|
# Calls the __makepom__ ivy target with given parameters and returns pom content.
|
109
122
|
def makepom(*params)
|
110
|
-
Ivy::Makepom.new(ant).execute(*params)
|
123
|
+
Ivy::Makepom.new(ant, cache_dir).execute(*params)
|
111
124
|
end
|
112
|
-
|
125
|
+
|
113
126
|
# Calls the __resolve__ ivy target with given parameters and returns info as hash.
|
114
127
|
def resolve(*params)
|
115
|
-
Ivy::Resolve.new(ant).execute(*params)
|
128
|
+
Ivy::Resolve.new(ant, cache_dir).execute(*params)
|
116
129
|
end
|
117
|
-
|
130
|
+
|
118
131
|
# Calls the __retrieve__ ivy target with given parameters.
|
119
132
|
def retrieve(*params)
|
120
|
-
Ivy::Retrieve.new(ant).execute(*params)
|
133
|
+
Ivy::Retrieve.new(ant, cache_dir).execute(*params)
|
121
134
|
end
|
122
|
-
|
135
|
+
|
123
136
|
# Calls the __publish__ ivy target with given parameters.
|
124
137
|
def publish(*params)
|
125
|
-
Ivy::Publish.new(ant).execute(*params)
|
138
|
+
Ivy::Publish.new(ant, cache_dir).execute(*params)
|
126
139
|
end
|
127
|
-
|
140
|
+
|
128
141
|
# Calls the __cachepath__ ivy target with given parameters and returns
|
129
142
|
# array containing absolute file paths to all artifacts contained in result
|
130
143
|
def cachepath(*params)
|
131
|
-
Ivy::Cachepath.new(ant).execute(*params)
|
144
|
+
Ivy::Cachepath.new(ant, cache_dir).execute(*params)
|
132
145
|
end
|
133
|
-
|
146
|
+
|
134
147
|
# Calls the __findrevision__ ivy target with given parameters and returns
|
135
148
|
# array containing absolute file paths to all artifacts contained in result
|
136
149
|
def findrevision(*params)
|
137
|
-
Ivy::Findrevision.new(ant).execute(*params)
|
150
|
+
Ivy::Findrevision.new(ant, cache_dir).execute(*params)
|
138
151
|
end
|
139
|
-
|
152
|
+
|
140
153
|
# Calls the __artifactproperty__ ivy target with given parameters and returns
|
141
154
|
# map with all defined properties
|
142
155
|
def artifactproperty(*params)
|
143
|
-
Ivy::Artifactproperty.new(ant).execute(*params)
|
156
|
+
Ivy::Artifactproperty.new(ant, cache_dir).execute(*params)
|
144
157
|
end
|
145
|
-
|
158
|
+
|
146
159
|
# Calls the __buildlist__ ivy target with given parameters and returns
|
147
160
|
# the resulting buildlist
|
148
161
|
def buildlist(*params)
|
149
|
-
Ivy::Buildlist.new(ant).execute(*params)
|
162
|
+
Ivy::Buildlist.new(ant, cache_dir).execute(*params)
|
150
163
|
end
|
151
|
-
|
164
|
+
|
152
165
|
# Calls the __artifactreport__ ivy target with given parameters and returns
|
153
166
|
# the created xml.
|
154
167
|
def artifactreport(*params)
|
155
|
-
Ivy::Artifactreport.new(ant).execute(*params)
|
168
|
+
Ivy::Artifactreport.new(ant, cache_dir).execute(*params)
|
156
169
|
end
|
157
|
-
|
170
|
+
|
158
171
|
# Calls the __report__ ivy target with given parameters
|
159
172
|
def report(*params)
|
160
|
-
Ivy::Report.new(ant).execute(*params)
|
173
|
+
Ivy::Report.new(ant, cache_dir).execute(*params)
|
161
174
|
end
|
162
175
|
|
163
176
|
# Used to get or set ant properties.
|
@@ -166,7 +179,7 @@ class Ivy4r
|
|
166
179
|
def property
|
167
180
|
AntPropertyHelper.new(ant, ant_properties)
|
168
181
|
end
|
169
|
-
|
182
|
+
|
170
183
|
# Returns the __antwrap__ instance to use for all internal calls creates a default
|
171
184
|
# instance if no instance has been set before.
|
172
185
|
def ant
|
@@ -175,12 +188,12 @@ class Ivy4r
|
|
175
188
|
init(@ant) if should_init?
|
176
189
|
@ant
|
177
190
|
end
|
178
|
-
|
191
|
+
|
179
192
|
private
|
180
193
|
def should_init?
|
181
194
|
@init_done.nil? || @init_done == false
|
182
195
|
end
|
183
|
-
|
196
|
+
|
184
197
|
def init(ant)
|
185
198
|
@init_done = true
|
186
199
|
ant.property :environment => environment_property
|
@@ -188,7 +201,7 @@ class Ivy4r
|
|
188
201
|
ant.path :id => 'ivy.lib.path' do
|
189
202
|
ant.fileset :dir => lib_dir, :includes => '*.jar'
|
190
203
|
end
|
191
|
-
|
204
|
+
|
192
205
|
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
206
|
ant.taskdef :name => "ivy_configure", :classname => "org.apache.ivy.ant.IvyConfigure", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
194
207
|
ant.taskdef :name => "ivy_resolve", :classname => "org.apache.ivy.ant.IvyResolve", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
@@ -215,7 +228,7 @@ class Ivy4r
|
|
215
228
|
ant.taskdef :name => "ivy_buildnumber", :classname => "org.apache.ivy.ant.IvyBuildNumber", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
216
229
|
ant.taskdef :name => "ivy_cleancache", :classname => "org.apache.ivy.ant.IvyCleanCache", :classpathref => "ivy.lib.path", :loaderRef => 'ivy.lib.path.loader'
|
217
230
|
end
|
218
|
-
|
231
|
+
|
219
232
|
# Returns the ant properties, note that this are java objects.
|
220
233
|
def ant_properties
|
221
234
|
ant.project.properties
|
@@ -226,7 +239,7 @@ AntPropertyHelper = Struct.new(:ant, :ant_properties) do #:nodoc:
|
|
226
239
|
def []=(name, value) #:nodoc:
|
227
240
|
ant.property :name => name, :value => value
|
228
241
|
end
|
229
|
-
|
242
|
+
|
230
243
|
def [](matcher) #:nodoc:
|
231
244
|
property = ant_properties.find {|p| matcher === p[0] }
|
232
245
|
property ? property[1] : nil
|
data/lib/rake/ivy_extension.rb
CHANGED
@@ -7,35 +7,50 @@ end
|
|
7
7
|
module Rake
|
8
8
|
module Ivy
|
9
9
|
class IvyConfig
|
10
|
-
|
10
|
+
|
11
11
|
# The directory to load ivy jars and its dependencies from, leave __nil__ to use default
|
12
12
|
attr_accessor :lib_dir
|
13
|
-
|
13
|
+
|
14
14
|
# The extension directory containing ivy settings, the local repository and cache
|
15
15
|
attr_accessor :extension_dir
|
16
|
-
|
16
|
+
|
17
17
|
# Returns the resolve result
|
18
18
|
attr_reader :resolved
|
19
19
|
|
20
20
|
attr_reader :post_resolve_tasks
|
21
|
-
|
21
|
+
|
22
22
|
# Store the current rake application and initialize ivy ant wrapper
|
23
23
|
def initialize(application)
|
24
24
|
@application = application
|
25
25
|
@extension_dir = File.join("#{@application.original_dir}", "#{ENV['IVY_EXT_DIR']}")
|
26
26
|
@post_resolve_tasks = []
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
# Returns the correct ant instance to use.
|
30
30
|
def ivy4r
|
31
31
|
unless @ivy4r
|
32
|
-
@ivy4r = ::Ivy4r.new
|
32
|
+
@ivy4r = ::Ivy4r.new do |i|
|
33
|
+
if caching_enabled?
|
34
|
+
end
|
35
|
+
end
|
33
36
|
@ivy4r.lib_dir = lib_dir if lib_dir
|
34
37
|
@ivy4r.project_dir = @extension_dir
|
35
38
|
end
|
36
39
|
@ivy4r
|
37
40
|
end
|
38
|
-
|
41
|
+
|
42
|
+
# Returns if ivy result caching is enabled by existence of the marker file.
|
43
|
+
def caching_enabled?
|
44
|
+
File.exists? 'use_ivy_caching'
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the dir to store ivy caching results in.
|
48
|
+
def result_cache_dir
|
49
|
+
dir = File.expand_path('ivycaching')
|
50
|
+
FileUtils.mkdir_p dir
|
51
|
+
dir
|
52
|
+
end
|
53
|
+
|
39
54
|
# Returns the artifacts for given configurations as array
|
40
55
|
# this is a post resolve task.
|
41
56
|
# the arguments are checked for the following:
|
@@ -59,17 +74,17 @@ module Rake
|
|
59
74
|
pathid = "ivy.deps." + confs.join('.') + '.' + types.join('.')
|
60
75
|
params = {:conf => confs.join(','), :pathid => pathid}
|
61
76
|
params[:type] = types.join(',') unless types.nil? || types.size == 0
|
62
|
-
|
77
|
+
|
63
78
|
ivy4r.cachepath params
|
64
79
|
end
|
65
80
|
end
|
66
|
-
|
81
|
+
|
67
82
|
# Returns ivy info for configured ivy file.
|
68
83
|
def info
|
69
84
|
ivy4r.settings :id => 'ivy.info.settingsref'
|
70
85
|
ivy4r.info :file => file, :settingsRef => 'ivy.info.settingsref'
|
71
86
|
end
|
72
|
-
|
87
|
+
|
73
88
|
# Configures the ivy instance with additional properties and loading the settings file if it was provided
|
74
89
|
def configure
|
75
90
|
unless @configured
|
@@ -79,7 +94,7 @@ module Rake
|
|
79
94
|
@configured = ivy4r.settings :file => settings if settings
|
80
95
|
end
|
81
96
|
end
|
82
|
-
|
97
|
+
|
83
98
|
# Resolves the configured file once.
|
84
99
|
def __resolve__
|
85
100
|
unless @resolved
|
@@ -88,12 +103,12 @@ module Rake
|
|
88
103
|
end
|
89
104
|
@resolved
|
90
105
|
end
|
91
|
-
|
106
|
+
|
92
107
|
# Creates the standard ivy dependency report
|
93
108
|
def report
|
94
109
|
ivy4r.report :todir => report_dir
|
95
110
|
end
|
96
|
-
|
111
|
+
|
97
112
|
# Publishs the project as defined in ivy file if it has not been published already
|
98
113
|
def __publish__
|
99
114
|
unless @published
|
@@ -105,19 +120,19 @@ module Rake
|
|
105
120
|
@published = true
|
106
121
|
end
|
107
122
|
end
|
108
|
-
|
123
|
+
|
109
124
|
def home
|
110
125
|
@ivy_home_dir ||= "#{@extension_dir}/ivy-home"
|
111
126
|
end
|
112
|
-
|
127
|
+
|
113
128
|
def settings
|
114
129
|
@settings ||= "#{@extension_dir}/ant-scripts/ivysettings.xml"
|
115
130
|
end
|
116
|
-
|
131
|
+
|
117
132
|
def file
|
118
133
|
@ivy_file ||= 'ivy.xml'
|
119
134
|
end
|
120
|
-
|
135
|
+
|
121
136
|
# Sets the revision to use for the project, this is useful for development revisions that
|
122
137
|
# have an appended timestamp or any other dynamic revisioning.
|
123
138
|
#
|
@@ -142,7 +157,7 @@ module Rake
|
|
142
157
|
self
|
143
158
|
end
|
144
159
|
end
|
145
|
-
|
160
|
+
|
146
161
|
# Sets the status to use for the project, this is useful for custom status handling
|
147
162
|
# like integration, alpha, gold.
|
148
163
|
#
|
@@ -167,7 +182,7 @@ module Rake
|
|
167
182
|
self
|
168
183
|
end
|
169
184
|
end
|
170
|
-
|
185
|
+
|
171
186
|
# Sets the publish options to use for the project. The options are merged with the default
|
172
187
|
# options including value set via #publish_from and overwrite all of them.
|
173
188
|
#
|
@@ -194,7 +209,7 @@ module Rake
|
|
194
209
|
end
|
195
210
|
end
|
196
211
|
end
|
197
|
-
|
212
|
+
|
198
213
|
# Sets the additional properties for the ivy process use a Hash with the properties to set.
|
199
214
|
def properties(*properties)
|
200
215
|
if properties.empty?
|
@@ -205,7 +220,7 @@ module Rake
|
|
205
220
|
self
|
206
221
|
end
|
207
222
|
end
|
208
|
-
|
223
|
+
|
209
224
|
# Sets the local repository for ivy files
|
210
225
|
def local_repository(*local_repository)
|
211
226
|
if local_repository.empty?
|
@@ -216,7 +231,7 @@ module Rake
|
|
216
231
|
self
|
217
232
|
end
|
218
233
|
end
|
219
|
-
|
234
|
+
|
220
235
|
# Sets the directory to publish artifacts from.
|
221
236
|
def publish_from(*publish_dir)
|
222
237
|
if publish_dir.empty?
|
@@ -227,7 +242,7 @@ module Rake
|
|
227
242
|
self
|
228
243
|
end
|
229
244
|
end
|
230
|
-
|
245
|
+
|
231
246
|
# Sets the directory to create dependency reports in.
|
232
247
|
def report_dir(*report_dir)
|
233
248
|
if report_dir.empty?
|
@@ -239,46 +254,46 @@ module Rake
|
|
239
254
|
end
|
240
255
|
end
|
241
256
|
end
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
257
|
+
|
258
|
+
# Adds given block as post resolve action that is executed directly after #resolve has been called.
|
259
|
+
# Yields this ivy config object into block.
|
260
|
+
# <tt>project.ivy.post_resolve { |ivy| p "all deps:" + ivy.deps('all').join(", ") }</tt>
|
261
|
+
def post_resolve(&block)
|
262
|
+
post_resolve_tasks << block if block
|
263
|
+
end
|
264
|
+
|
265
|
+
# Filter artifacts for given configuration with provided filter values, this is a post resolve
|
266
|
+
# task like #deps.
|
267
|
+
# <tt>project.ivy.filter('server', 'client', :include => /b.*.jar/, :exclude => [/a\.jar/, /other.*\.jar/])</tt>
|
268
|
+
def filter(*confs)
|
269
|
+
filter = confs.last.kind_of?(Hash) ? confs.pop : {}
|
270
|
+
unless (filter.keys - (TYPES - [:conf])).empty?
|
271
|
+
raise ArgumentError, "Invalid filter use :include and/or :exclude only: given #{filter.keys.inspect}"
|
248
272
|
end
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
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
|
273
|
+
includes, excludes, types = filter[:include] || [], filter[:exclude] || [], filter[:type] || []
|
274
|
+
|
275
|
+
artifacts = deps(confs.flatten, types.flatten)
|
276
|
+
if artifacts
|
277
|
+
artifacts = artifacts.find_all do |lib|
|
278
|
+
lib = File.basename(lib)
|
279
|
+
includes = includes.reject {|i| i.nil? || i.blank? }
|
280
|
+
should_include = includes.empty? || includes.any? {|include| include === lib }
|
281
|
+
should_include && !excludes.any? {|exclude| exclude === lib}
|
268
282
|
end
|
269
|
-
|
270
|
-
artifacts
|
271
283
|
end
|
272
|
-
|
284
|
+
|
285
|
+
artifacts
|
286
|
+
end
|
287
|
+
|
273
288
|
class Tasks < ::Rake::TaskLib
|
274
289
|
def initialize(ivy = nil, &block)
|
275
290
|
@ivy = ivy || Rake::Ivy::IvyConfig.new(Rake.application)
|
276
291
|
yield @ivy if block_given?
|
277
292
|
Rake.application.ivy = @ivy
|
278
|
-
|
293
|
+
|
279
294
|
define
|
280
295
|
end
|
281
|
-
|
296
|
+
|
282
297
|
private
|
283
298
|
def define
|
284
299
|
namespace 'ivy' do
|
@@ -290,21 +305,39 @@ module Rake
|
|
290
305
|
task :resolve => "ivy:configure" do
|
291
306
|
Rake.application.ivy.__resolve__
|
292
307
|
end
|
293
|
-
|
308
|
+
|
294
309
|
desc 'Publish the artifacts to ivy repository'
|
295
310
|
task :publish => "ivy:resolve" do
|
296
311
|
Rake.application.ivy.__publish__
|
297
312
|
end
|
298
|
-
|
313
|
+
|
299
314
|
desc 'Creates a dependency report for the project'
|
300
315
|
task :report => "ivy:resolve" do
|
301
316
|
Rake.application.ivy.report
|
302
317
|
end
|
303
|
-
|
318
|
+
|
304
319
|
desc 'Clean the local Ivy cache and the local ivy repository'
|
305
320
|
task :clean do
|
306
321
|
Rake.application.ivy.ivy4r.clean
|
307
322
|
end
|
323
|
+
|
324
|
+
desc 'Clean the local Ivy result cache to force execution of ivy targets'
|
325
|
+
task :cleanresultcache do
|
326
|
+
puts "Deleting IVY result cache dir '#{Rake.application.ivy.result_cache_dir}'"
|
327
|
+
rm_rf Rake.application.ivy.result_cache_dir
|
328
|
+
end
|
329
|
+
|
330
|
+
desc 'Enable the local Ivy result cache by creating the marker file'
|
331
|
+
task :enableresultcache do
|
332
|
+
puts "Creating IVY caching marker file '#{Rake.application.ivy.caching_marker}'"
|
333
|
+
touch Rake.application.ivy.caching_marker
|
334
|
+
end
|
335
|
+
|
336
|
+
desc 'Disable the local Ivy result cache by removing the marker file'
|
337
|
+
task :disableresultcache do
|
338
|
+
puts "Deleting IVY aching marker file '#{Rake.application.ivy.caching_marker}'"
|
339
|
+
rm_f Rake.application.ivy.caching_marker
|
340
|
+
end
|
308
341
|
end
|
309
342
|
end
|
310
343
|
end
|