ivy4r 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -0
- data/Manifest.txt +36 -0
- data/README.txt +92 -0
- data/Rakefile +25 -0
- data/bin/ivy4r +3 -0
- data/lib/buildr/ivy_extension.rb +566 -0
- data/lib/ivy/artifactproperty.rb +34 -0
- data/lib/ivy/artifactreport.rb +24 -0
- data/lib/ivy/buildlist.rb +37 -0
- data/lib/ivy/buildnumber.rb +34 -0
- data/lib/ivy/cachepath.rb +30 -0
- data/lib/ivy/cleancache.rb +20 -0
- data/lib/ivy/configure.rb +29 -0
- data/lib/ivy/findrevision.rb +34 -0
- data/lib/ivy/info.rb +36 -0
- data/lib/ivy/listmodules.rb +35 -0
- data/lib/ivy/makepom.rb +23 -0
- data/lib/ivy/publish.rb +37 -0
- data/lib/ivy/report.rb +33 -0
- data/lib/ivy/resolve.rb +44 -0
- data/lib/ivy/retrieve.rb +27 -0
- data/lib/ivy/settings.rb +15 -0
- data/lib/ivy/target.rb +128 -0
- data/lib/ivy/targets.rb +49 -0
- data/lib/ivy4r.rb +176 -0
- data/test/buildlist/p1/buildfile +0 -0
- data/test/buildlist/p1/ivy.xml +7 -0
- data/test/buildlist/sub/p2/buildfile +0 -0
- data/test/buildlist/sub/p2/ivy.xml +11 -0
- data/test/buildlist/sub/p3/buildfile +0 -0
- data/test/buildlist/sub/p3/ivy.xml +11 -0
- data/test/ivy/ivysettings.xml +11 -0
- data/test/ivy/ivytest.xml +18 -0
- data/test/ivy/test_target.rb +97 -0
- data/test/ivy/test_targets.rb +36 -0
- data/test/test_ivy4r.rb +196 -0
- metadata +113 -0
@@ -0,0 +1,566 @@
|
|
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
|
+
=begin rdoc
|
373
|
+
The Ivy Buildr extension adding the new tasks for ivy.
|
374
|
+
|
375
|
+
To use ivy in a +buildfile+ do something like:
|
376
|
+
ENV['BUILDR_EXT_DIR'] ||= '../Ivy'
|
377
|
+
require 'buildr/ivy_extension'
|
378
|
+
define 'ivy_project' do
|
379
|
+
[...]
|
380
|
+
ivy.compile_conf('compile').test_conf('test').package_conf('prod', 'server')
|
381
|
+
[...]
|
382
|
+
end
|
383
|
+
|
384
|
+
- This will add the +compile+ configuration to compile and test tasks
|
385
|
+
- Add the +test+ configuration to test compilation and execution
|
386
|
+
- include the artifacts from +prod+ and +server+ to any generated war or ear
|
387
|
+
- The ENV variable is needed to automatically configure the load path for ivy libs.
|
388
|
+
It assumes that you have the following dir structure <tt>[BUILDR_EXT_DIR]/ivy-home/jars</tt>
|
389
|
+
|
390
|
+
For more configuration options see IvyConfig.
|
391
|
+
=end
|
392
|
+
module IvyExtension
|
393
|
+
include Buildr::Extension
|
394
|
+
|
395
|
+
class << self
|
396
|
+
def add_ivy_deps_to_java_tasks(project)
|
397
|
+
resolve_target = project.ivy.file_project.task('ivy:resolve')
|
398
|
+
project.task :compiledeps => resolve_target do
|
399
|
+
compile_conf = [project.ivy.compile_conf].flatten
|
400
|
+
project.compile.with project.ivy.deps(compile_conf)
|
401
|
+
info "Ivy adding compile dependencies '#{compile_conf.join(', ')}' to project '#{project.name}'"
|
402
|
+
end
|
403
|
+
project.task :compile => "#{project.name}:compiledeps"
|
404
|
+
|
405
|
+
project.task :testdeps => resolve_target do
|
406
|
+
confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq
|
407
|
+
project.test.with project.ivy.deps(confs)
|
408
|
+
info "Ivy adding test dependencies '#{confs.join(', ')}' to project '#{project.name}'"
|
409
|
+
end
|
410
|
+
project.task "test:compile" => "#{project.name}:testdeps"
|
411
|
+
|
412
|
+
project.task :javadocdeps => resolve_target do
|
413
|
+
confs = [project.ivy.test_conf, project.ivy.compile_conf].flatten.uniq
|
414
|
+
project.javadoc.with project.ivy.deps(confs)
|
415
|
+
info "Ivy adding javadoc dependencies '#{confs.join(', ')}' to project '#{project.name}'"
|
416
|
+
end
|
417
|
+
project.task :javadoc => "#{project.name}:javadocdeps"
|
418
|
+
end
|
419
|
+
|
420
|
+
def add_manifest_to_distributeables(project)
|
421
|
+
pkgs = project.packages.find_all { |pkg| [:jar, :war, :ear].member? pkg.type }
|
422
|
+
pkgs.each do |pkg|
|
423
|
+
name = "#{pkg.name}manifest"
|
424
|
+
task = project.task name => project.ivy.file_project.task('ivy:resolve') do
|
425
|
+
pkg.with :manifest => project.manifest.merge(project.ivy.manifest)
|
426
|
+
info "Adding manifest entries to package '#{pkg.name}'"
|
427
|
+
end
|
428
|
+
project.task :build => task
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
def add_prod_libs_to_distributeables(project)
|
433
|
+
includes = project.ivy.package_include
|
434
|
+
excludes = project.ivy.package_exclude
|
435
|
+
pkgs = project.packages.find_all { |pkg| [:war, :ear].member? pkg.type }
|
436
|
+
pkgs.each do |pkg|
|
437
|
+
name = "#{pkg.name}deps"
|
438
|
+
task = project.task name => project.ivy.file_project.task('ivy:resolve') do
|
439
|
+
confs = project.ivy.package_conf
|
440
|
+
libs = project.ivy.deps(confs).find_all do |lib|
|
441
|
+
lib = File.basename(lib)
|
442
|
+
use = includes.any? {|include| include === lib } && !excludes.any? {|exclude| exclude === lib}
|
443
|
+
verbose "Including '#{lib}' from package '#{pkg}' in project '#{project.name}'" if use
|
444
|
+
info "Excluding '#{lib}' from package '#{pkg}' in project '#{project.name}'" unless use
|
445
|
+
use
|
446
|
+
end
|
447
|
+
pkg.with :libs => libs
|
448
|
+
info "Adding production libs from conf '#{confs.join(', ')}' to package '#{pkg.name}' in project '#{project.name}'"
|
449
|
+
end
|
450
|
+
project.task :build => task
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
def add_copy_tasks_for_publish(project)
|
455
|
+
if project.ivy.own_file?
|
456
|
+
Buildr.projects.each do |current|
|
457
|
+
current.packages.each do |pkg|
|
458
|
+
target_file = current.ivy.name[pkg] || File.basename(pkg.name).gsub(/-#{project.version}/, '')
|
459
|
+
taskname = current.path_to(project.ivy.publish_from, target_file)
|
460
|
+
if taskname != pkg.name
|
461
|
+
project.file taskname => pkg.name do
|
462
|
+
verbose "Ivy copying '#{pkg.name}' to '#{taskname}' for publishing"
|
463
|
+
FileUtils.mkdir File.dirname(taskname) unless File.directory?(File.dirname(taskname))
|
464
|
+
FileUtils.cp pkg.name, taskname
|
465
|
+
end
|
466
|
+
end
|
467
|
+
project.task 'ivy:publish' => taskname
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
# Returns the +ivy+ configuration for the project. Use this to configure Ivy.
|
475
|
+
# see IvyConfig for more details about configuration options.
|
476
|
+
def ivy
|
477
|
+
@ivy_config ||= IvyConfig.new(self)
|
478
|
+
end
|
479
|
+
|
480
|
+
first_time do
|
481
|
+
namespace 'ivy' do
|
482
|
+
desc 'Resolves the ivy dependencies'
|
483
|
+
task :resolve
|
484
|
+
|
485
|
+
desc 'Publish the artifacts to ivy repository as defined by environment'
|
486
|
+
task :publish
|
487
|
+
|
488
|
+
desc 'Creates a dependency report for the project'
|
489
|
+
task :report
|
490
|
+
|
491
|
+
desc 'Clean the local Ivy cache and the local ivy repository'
|
492
|
+
task :clean
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
before_define do |project|
|
497
|
+
if project.parent.nil? && project.ivy.enabled?
|
498
|
+
info = project.ivy.info
|
499
|
+
project.version = info['ivy.revision']
|
500
|
+
project.group = "#{info['ivy.organisation']}.#{info['ivy.module']}"
|
501
|
+
end
|
502
|
+
end
|
503
|
+
|
504
|
+
after_define do |project|
|
505
|
+
if project.ivy.enabled?
|
506
|
+
IvyExtension.add_ivy_deps_to_java_tasks(project)
|
507
|
+
IvyExtension.add_manifest_to_distributeables(project)
|
508
|
+
IvyExtension.add_prod_libs_to_distributeables(project)
|
509
|
+
IvyExtension.add_copy_tasks_for_publish(project)
|
510
|
+
|
511
|
+
task :clean do
|
512
|
+
# TODO This is redundant, refactor ivy_ant_wrap and this to use a single config object
|
513
|
+
info "Cleaning ivy reports"
|
514
|
+
rm_rf project.path_to(:reports, 'ivy')
|
515
|
+
end
|
516
|
+
|
517
|
+
namespace 'ivy' do
|
518
|
+
task :configure do
|
519
|
+
project.ivy.configure
|
520
|
+
end
|
521
|
+
|
522
|
+
task :resolve => "#{project.name}:ivy:configure" do
|
523
|
+
project.ivy.resolve
|
524
|
+
end
|
525
|
+
|
526
|
+
task :report => "#{project.name}:ivy:resolve" do
|
527
|
+
project.ivy.report
|
528
|
+
end
|
529
|
+
|
530
|
+
task :publish => "#{project.name}:ivy:resolve" do
|
531
|
+
project.ivy.publish
|
532
|
+
end
|
533
|
+
end
|
534
|
+
end
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
# Global targets that are not bound to a project
|
539
|
+
namespace 'ivy' do
|
540
|
+
task :clean do
|
541
|
+
info "Cleaning local ivy cache"
|
542
|
+
Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
|
543
|
+
project.ivy.ant.clean
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
task :resolve do
|
548
|
+
info "Resolving all distinct ivy files"
|
549
|
+
Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
|
550
|
+
project.task('ivy:resolve').invoke
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
task :publish => :package do
|
555
|
+
info "Publishing all distinct ivy files"
|
556
|
+
Buildr.projects.find_all{ |p| p.ivy.own_file? }.each do |project|
|
557
|
+
project.task('ivy:publish').invoke
|
558
|
+
end
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
class Buildr::Project # :nodoc:
|
563
|
+
include IvyExtension
|
564
|
+
end
|
565
|
+
end
|
566
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'ivy/target'
|
2
|
+
|
3
|
+
module Ivy
|
4
|
+
class Artifactproperty < Ivy::Target
|
5
|
+
def parameter
|
6
|
+
[
|
7
|
+
Parameter.new(:name, true),
|
8
|
+
Parameter.new(:value, true),
|
9
|
+
Parameter.new(:conf, false),
|
10
|
+
Parameter.new(:haltonfailure, false),
|
11
|
+
Parameter.new(:validate, false),
|
12
|
+
Parameter.new(:overwrite, false),
|
13
|
+
Parameter.new(:settingsRef, false),
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
def before_hook
|
19
|
+
@cached_property_names = ant_properties.map {|key, value| key }
|
20
|
+
end
|
21
|
+
|
22
|
+
def after_hook
|
23
|
+
@cached_property_names = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
def execute_ivy
|
27
|
+
call_nested :ivy_artifactproperty => params
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_return_values
|
31
|
+
ant_properties.reject { |key, value| @cached_property_names.member? key }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'ivy/target'
|
2
|
+
|
3
|
+
module Ivy
|
4
|
+
class Artifactreport < Ivy::Target
|
5
|
+
def parameter
|
6
|
+
[
|
7
|
+
Parameter.new(:tofile, true),
|
8
|
+
Parameter.new(:pattern, false),
|
9
|
+
Parameter.new(:conf, false),
|
10
|
+
Parameter.new(:haltonfailure, false),
|
11
|
+
Parameter.new(:settingsRef, false)
|
12
|
+
]
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
def execute_ivy
|
17
|
+
call_nested :ivy_artifactreport => params
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_return_values
|
21
|
+
IO.read(params[:tofile])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'ivy/target'
|
2
|
+
|
3
|
+
module Ivy
|
4
|
+
class Buildlist < Ivy::Target
|
5
|
+
def parameter
|
6
|
+
[
|
7
|
+
Parameter.new(:reference, false),
|
8
|
+
Parameter.new(:nested, true),
|
9
|
+
Parameter.new(:ivyfilepath, false),
|
10
|
+
Parameter.new(:root, false),
|
11
|
+
Parameter.new(:excluderoot, false),
|
12
|
+
Parameter.new(:leaf, false),
|
13
|
+
Parameter.new(:onlydirectdep, false),
|
14
|
+
Parameter.new(:delimiter, false),
|
15
|
+
Parameter.new(:excludeleaf, false),
|
16
|
+
Parameter.new(:haltonerror, false),
|
17
|
+
Parameter.new(:skipbuildwithoutivy, false),
|
18
|
+
Parameter.new(:onMissingDescriptor, false),
|
19
|
+
Parameter.new(:reverse, false),
|
20
|
+
Parameter.new(:restartFrom, false),
|
21
|
+
Parameter.new(:settingsRef, false)
|
22
|
+
]
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
def execute_ivy
|
27
|
+
params[:reference] = "path-#{rand.to_s}" unless params[:reference]
|
28
|
+
call_nested :ivy_buildlist => params
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_return_values
|
32
|
+
path = ant_references.find { |current| params[:reference] == current[0] }[1]
|
33
|
+
raise "Could not get path for params #{params.inspect}" unless path && path.respond_to?(:list)
|
34
|
+
path.list.map {|a| a.to_s }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'ivy/target'
|
2
|
+
|
3
|
+
module Ivy
|
4
|
+
class Buildnumber < Ivy::Target
|
5
|
+
def parameter
|
6
|
+
[
|
7
|
+
Parameter.new(:organisation, true),
|
8
|
+
Parameter.new(:module, true),
|
9
|
+
Parameter.new(:branch, false),
|
10
|
+
Parameter.new(:revision, false),
|
11
|
+
Parameter.new(:default, false),
|
12
|
+
Parameter.new(:defaultBuildNumber, false),
|
13
|
+
Parameter.new(:revSep, false),
|
14
|
+
Parameter.new(:prefix, false),
|
15
|
+
Parameter.new(:settingsRef, false),
|
16
|
+
Parameter.new(:resolver, false)
|
17
|
+
]
|
18
|
+
end
|
19
|
+
|
20
|
+
def result_property_values
|
21
|
+
[
|
22
|
+
ResultValue.new("ivy.revision", nil),
|
23
|
+
ResultValue.new("ivy.new.revision", nil),
|
24
|
+
ResultValue.new("ivy.build.number", nil),
|
25
|
+
ResultValue.new("ivy.new.build.number", nil)
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
30
|
+
def execute_ivy
|
31
|
+
call_nested :ivy_buildnumber => params
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|