maven-tools 0.34.5 → 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/lib/maven/tools/artifact.rb +18 -12
  3. data/lib/maven/tools/dsl.rb +282 -121
  4. data/lib/maven/tools/gemfile_lock.rb +0 -6
  5. data/lib/maven/tools/model.rb +78 -69
  6. data/lib/maven/tools/pom.rb +8 -8
  7. data/lib/maven/tools/version.rb +1 -1
  8. data/lib/maven/tools/versions.rb +4 -4
  9. data/lib/maven/tools/visitor.rb +2 -2
  10. data/spec/gemfile_with_lock/bouncy-castle-version.rb +4 -0
  11. data/spec/pom_maven_alternative_style/pom.rb +116 -169
  12. data/spec/pom_maven_hash_style/pom.rb +134 -100
  13. data/spec/pom_maven_style/pom.rb +160 -163
  14. data/spec/pom_spec.rb +3 -1
  15. metadata +12 -90
  16. data/lib/maven/model/dependencies.rb +0 -249
  17. data/lib/maven/model/model.rb +0 -618
  18. data/lib/maven/model/utils.rb +0 -393
  19. data/lib/maven/tools/execute_in_phase.rb +0 -28
  20. data/lib/maven/tools/gem_project.rb +0 -513
  21. data/lib/maven/tools/maven_project.rb +0 -72
  22. data/lib/maven/tools/minimal_project.rb +0 -84
  23. data/lib/maven/tools/pom_generator.rb +0 -83
  24. data/lib/maven/tools/rails_project.rb +0 -133
  25. data/rspec/maven/model/dependencies_spec.rb +0 -260
  26. data/rspec/maven/model/model_spec.rb +0 -714
  27. data/rspec/maven/tools/Gemfile.gems +0 -11
  28. data/rspec/maven/tools/Gemfile.groups +0 -15
  29. data/rspec/maven/tools/Gemfile.ignored +0 -30
  30. data/rspec/maven/tools/Gemfile.lockfile +0 -8
  31. data/rspec/maven/tools/Gemfile.lockfile.lock +0 -53
  32. data/rspec/maven/tools/Gemfile.minimal +0 -1
  33. data/rspec/maven/tools/Gemfile.nolock +0 -1
  34. data/rspec/maven/tools/Gemfile.rails +0 -16
  35. data/rspec/maven/tools/Gemfile.simple +0 -7
  36. data/rspec/maven/tools/Gemfile.withlock +0 -1
  37. data/rspec/maven/tools/Gemfile.withlock.lock +0 -28
  38. data/rspec/maven/tools/Jarfile.with +0 -2
  39. data/rspec/maven/tools/Jarfile.with.lock +0 -1
  40. data/rspec/maven/tools/Jarfile.without +0 -2
  41. data/rspec/maven/tools/deps.gemspec +0 -8
  42. data/rspec/maven/tools/gem_project_spec.rb +0 -1126
  43. data/rspec/maven/tools/maven-tools.gemspec +0 -17
  44. data/rspec/maven/tools/minimal.gemspec +0 -5
  45. data/rspec/maven/tools/no-deps.gemspec +0 -27
  46. data/rspec/maven/tools/rails_project_spec.rb +0 -284
  47. data/rspec/maven/tools/spec_helper.rb +0 -22
@@ -1,618 +0,0 @@
1
- #
2
- # Copyright (C) 2013 Christian Meier
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
- # this software and associated documentation files (the "Software"), to deal in
6
- # the Software without restriction, including without limitation the rights to
7
- # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
- # the Software, and to permit persons to whom the Software is furnished to do so,
9
- # subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
- # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
- # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
- #
21
- # TODO make nice require after ruby-maven uses the same ruby files
22
- require File.join(File.dirname(__FILE__), 'dependencies.rb')
23
- #require 'maven/model/dependencies'
24
-
25
- module Maven
26
- module Model
27
-
28
- class Resource < Tag
29
-
30
- tags :directory, :includes, :excludes, :target_path, :filtering
31
-
32
- def includes(&block)
33
- @includes ||= NamedArray.new( 'includes' )
34
- if block
35
- block.call( @includes )
36
- end
37
- @includes
38
- end
39
-
40
- def excludes(&block)
41
- @excludes ||= NamedArray.new( 'excludes' )
42
- if block
43
- block.call(@excludes)
44
- end
45
- @excludes
46
- end
47
-
48
- end
49
-
50
- class TestResource < Resource
51
- tags :dummy
52
-
53
- def _name
54
- 'testResource'
55
- end
56
- end
57
-
58
- class Build < Tag
59
- tags :source_directory, :script_source_directory, :test_source_directory, :output_directory, :test_output_directory, :default_goal, :directory, :final_name, :plugins, :plugin_management, :resources, :test_resources
60
-
61
- def resources(&block)
62
- @resources ||= ResourceArray.new
63
- if block
64
- block.call(@resources)
65
- end
66
- @resources
67
- end
68
-
69
- def test_resources(&block)
70
- @test_resources ||= ResourceArray.new( 'testResources', TestResource )
71
- if block
72
- block.call(@test_resources)
73
- end
74
- @test_resources
75
- end
76
-
77
- def plugins(&block)
78
- @plugins ||= PluginHash.new
79
- if block
80
- block.call(@plugins)
81
- end
82
- @plugins
83
- end
84
-
85
- def plugin?(name)
86
- plugins.key?(name)
87
- end
88
-
89
- def plugin_management(&block)
90
- @plugin_management ||= PluginManagement.new
91
- if block
92
- block.call(@plugin_management)
93
- end
94
- @plugin_management
95
- end
96
-
97
- def to_xml(buf = "", indent = "")
98
- if @final_name.nil? && (@resources.nil? || @resources.size == 0) && (@test_resources.nil? || @test_resources.size == 0) && (@plugins.nil? || @plugins.size == 0) && @plugin_management.nil? #TODO check the rest
99
- ""
100
- else
101
- super
102
- end
103
- end
104
- end
105
-
106
- class PluginManagement < Tag
107
- tags :plugins
108
-
109
- def plugins(&block)
110
- @plugins ||= PluginHash.new
111
- if block
112
- block.call(@plugins)
113
- end
114
- @plugins
115
- end
116
-
117
- def plugin?(name)
118
- plugins.key?(name)
119
- end
120
-
121
- def to_xml(buf = "", indent = "")
122
- if @plugins.nil? || @plugins.size == 0
123
- ""
124
- else
125
- super
126
- end
127
- end
128
-
129
- def _name
130
- "pluginManagement"
131
- end
132
- end
133
-
134
- class Plugin < Coordinate
135
- tags :extensions, :configuration, :executions
136
-
137
- include Dependencies
138
-
139
- def initialize(*args, &block)
140
- super(*args)
141
- raise "plugin version must be a concrete version" if version =~ /^[\[\(].+,.*[\]\)]$/
142
- if block
143
- block.call(self)
144
- end
145
- self
146
- end
147
-
148
- def with(config)
149
- self.configuration config
150
- end
151
-
152
- def in_phase(phase, name = nil, &block)
153
- name = "in_phase_#{phase.to_s.gsub(/-/,'_')}" unless name
154
- self.executions.get(name) do |exe|
155
- exe.phase = phase
156
- block.call(exe) if block
157
- exe
158
- end
159
- end
160
-
161
- def execute_goal(goal)
162
- execution.execute_goal(goal)
163
- end
164
-
165
- def executions
166
- @executions ||= ModelHash.new(Execution)
167
- end
168
-
169
- def execution(name = nil, &block)
170
- executions.get(name, &block)
171
- end
172
-
173
- def configuration(c = nil)
174
- @configuration = Configuration.new(c) if c
175
- @configuration ||= Configuration.new({})
176
- end
177
- end
178
-
179
- class Execution < Tag
180
- tags :id, :phase, :goals, :inherited, :configuration
181
-
182
- def initialize(id = nil)
183
- self.id id if id
184
- end
185
-
186
- def configuration(c = nil)
187
- @configuration = Configuration.new(c) if c
188
- @configuration ||= Configuration.new({})
189
- end
190
-
191
- def execute_goal(g)
192
- self.goals = g
193
- self
194
- end
195
-
196
- def with(config)
197
- self.configuration config
198
- end
199
-
200
- def goals
201
- @goals ||= []
202
- end
203
-
204
- def goals=(goals)
205
- @goals = goals.is_a?(Array) ? goals: [goals]
206
- end
207
- end
208
-
209
- class DependencyManagement < Tag
210
-
211
- include Dependencies
212
-
213
- def _name
214
- "dependencyManagement"
215
- end
216
- end
217
-
218
- class Profile < Tag
219
- tags :id, :activation, :repositories, :plugin_repositories
220
-
221
- include Dependencies
222
-
223
- tags :dependency_management, :properties, :build
224
-
225
- def initialize(id, &block)
226
- self.id id
227
- if block
228
- block.call(self)
229
- end
230
- self
231
- end
232
-
233
- def properties
234
- @properties ||= Properties.new
235
- @properties.map
236
- end
237
-
238
- def properties=(props)
239
- if props.is_a? Hash
240
- @properties = Properties.new(props)
241
- else
242
- @properties = props
243
- end
244
- end
245
-
246
- def build
247
- @build ||= Build.new
248
- end
249
-
250
- def activation(name = nil, value = nil, &block)
251
- @activation ||= Activation.new
252
- if name || value
253
- warn "deprecated, use 'property_activation' instead"
254
- @activation.property(name, value)
255
- else
256
- block.call(@activation) if block
257
- @activation
258
- end
259
- end
260
-
261
- def repositories(&block)
262
- @repositories ||= ModelHash.new(Repository)
263
- if block
264
- block.call(@repositories)
265
- end
266
- @repositories
267
- end
268
-
269
- def repository(id, url = nil, &block)
270
- repo = repositories.get(id, &block)
271
- repo.url = url if url
272
- repo
273
- end
274
-
275
- def plugin_repositories(&block)
276
- @plugin_repositories ||= ModelHash.new(PluginRepository)
277
- if block
278
- block.call(@plugin_repositories)
279
- end
280
- @plugin_repositories
281
- end
282
-
283
- def plugin_repository(id, url = nil, &block)
284
- repo = plugin_repositories.get(id, &block)
285
- repo.url = url if url
286
- repo
287
- end
288
-
289
- def plugin(*args, &block)
290
- build.plugins.get(*args, &block)
291
- end
292
-
293
- def dependency_management(&block)
294
- @dependency_management ||= DependencyManagement.new
295
- if block
296
- block.call(@dependency_management)
297
- end
298
- @dependency_management
299
- end
300
- end
301
-
302
- class Developer < Tag
303
- tags :id, :name, :email
304
-
305
- def initialize(*args)
306
- case args.size
307
- when 1
308
- @email = args[0].sub(/.*</, '').sub(/>.*/, '')
309
- @name = args[0].sub(/\s*<.*/, '')
310
- when 2
311
- @name = args[0]
312
- @email = args[1]
313
- when 3
314
- @id = args[0]
315
- @name = args[1]
316
- @email = args[2]
317
- end
318
- @email = @email[0] if @email.is_a? Array # this produces a partial list
319
- @id = (@email || @name).sub(/@/, '_at_').gsub(/\./, '_dot_').gsub(/ /, '_') unless @id
320
- self
321
- end
322
- end
323
-
324
- class License < Tag
325
- tags :name, :url, :distribution
326
-
327
- def initialize(*args)
328
- case args.size
329
- when 1
330
- @url = args[0]
331
- @name = args[0].sub(/.*\//, '').sub(/\.\w+/, '')
332
- when 2
333
- @url = args[0]
334
- @name = args[1]
335
- when 3
336
- @url = args[0]
337
- @name = args[1]
338
- @distribution = args[2]
339
- end
340
- @url = "./#{url}" unless @url =~ /^\.\// || @url =~ /^https?:\/\//
341
- @distribution = "repo" unless @distribution
342
- self
343
- end
344
- end
345
-
346
- class SourceControl < Tag
347
-
348
- tags :connection, :developer_connection, :url
349
-
350
- def _name
351
- 'scm'
352
- end
353
- end
354
-
355
- class Project < Coordinate
356
- prepend_tags :model_version, :parent
357
-
358
- tags :name, :packaging, :description, :url, :developers, :licenses, :repositories, :plugin_repositories, :scm
359
-
360
- include Dependencies
361
-
362
- tags :dependency_management, :properties, :build, :profiles
363
-
364
- def initialize(*args, &block)
365
- super(*args)
366
- model_version "4.0.0"
367
- if block
368
- block.call(self)
369
- end
370
- self
371
- end
372
-
373
- def _name
374
- 'project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"'
375
- end
376
-
377
- def dump_pom( file = nil )
378
- @dump_pom = file if file
379
- @dump_pom
380
- end
381
-
382
- def version(val = nil)
383
- self.version = val if val
384
- @version ||= (@parent.nil? ? '0.0.0' : @parent.version)
385
- end
386
-
387
- def name(val = nil)
388
- self.name = val if val
389
- @name
390
- end
391
-
392
- def name=(val)
393
- @name = "<![CDATA[#{val}]]>"
394
- end
395
-
396
- def description(val = nil)
397
- self.description = val if val
398
- @description
399
- end
400
-
401
- def description=(val)
402
- @description = "<![CDATA[#{val}]]>"
403
- end
404
-
405
- def parent(*args, &block)
406
- @parent ||= Parent.new(*args)
407
- block.call( @parent ) if block
408
- @parent
409
- end
410
-
411
- def source_control(&block)
412
- @scm ||= SourceControl.new
413
- block.call( @scm ) if block
414
- @scm
415
- end
416
- alias :scm :source_control
417
-
418
- def execute_in_phase(phase, name = nil, &block)
419
- gem_plugin = plugin("gem")
420
- gem_plugin.in_phase(phase.to_s, name).execute_goal("execute_in_phase").with(:file => File.basename('Mavenfile'), :phase => phase)
421
- executions_in_phase[phase.to_s] = block
422
- gem_plugin
423
- end
424
-
425
- def executions_in_phase
426
- @executions_in_phase ||= {}
427
- end
428
-
429
- def plugin(*args, &block)
430
- build.plugins.get(*args, &block)
431
- end
432
-
433
- def plugin?(name)
434
- build.plugin?(name)
435
- end
436
-
437
- def profile(*args, &block)
438
- profiles.get(*args, &block)
439
- end
440
-
441
- def build
442
- @build ||= Build.new
443
- end
444
-
445
- def developers(&block)
446
- @developers ||= DeveloperHash.new
447
- if block
448
- block.call(@developers)
449
- end
450
- @developers
451
- end
452
-
453
- def licenses(&block)
454
- @licenses ||= LicenseHash.new
455
- if block
456
- block.call(@licenses)
457
- end
458
- @licenses
459
- end
460
-
461
- def repositories(&block)
462
- @repositories ||= ModelHash.new(Repository)
463
- if block
464
- block.call(@repositories)
465
- end
466
- @repositories
467
- end
468
-
469
- def repository(id, url = nil, &block)
470
- repo = repositories.get(id, &block)
471
- repo.url = url if url
472
- repo
473
- end
474
-
475
- def plugin_repositories(&block)
476
- @plugin_repositories ||= ModelHash.new(PluginRepository)
477
- if block
478
- block.call(@plugin_repositories)
479
- end
480
- @plugin_repositories
481
- end
482
-
483
- def plugin_repository(id, url = nil, &block)
484
- repo = plugin_repositories.get(id, &block)
485
- repo.url = url if url
486
- repo
487
- end
488
-
489
- def dependency_management(&block)
490
- @dependency_management ||= DependencyManagement.new
491
- if block
492
- block.call(@dependency_management)
493
- end
494
- @dependency_management
495
- end
496
-
497
- def properties
498
- @properties ||= Properties.new
499
- @properties.map
500
- end
501
-
502
- def properties=(props)
503
- if props.is_a? Hash
504
- @properties = Properties.new(props)
505
- else
506
- @properties = props
507
- end
508
- end
509
-
510
- def profile(id, &block)
511
- profiles.get(id, &block)
512
- end
513
-
514
- def profiles(&block)
515
- @profiles ||= ModelHash.new(Profile)
516
- if block
517
- block.call(@profiles)
518
- end
519
- @profiles
520
- end
521
- end
522
-
523
- class Configuration < HashTag
524
-
525
- def initialize(args = {})
526
- super("configuration", args)
527
- end
528
- end
529
-
530
- class Properties < HashTag
531
-
532
- def initialize(args = {})
533
- super("properties", args)
534
- end
535
-
536
- def map
537
- @props
538
- end
539
- end
540
-
541
- class OS < Tag
542
- tags :name, :family, :arch, :version
543
- end
544
-
545
- class Activation < Tag
546
- tags :activeByDefault, :property, :os
547
- def initialize
548
- super({})
549
- end
550
-
551
- def add_property(name, value)
552
- warn "deprecated, use 'property' instead"
553
- property(name, value)
554
- end
555
-
556
- def property(name, value)
557
- if name && value
558
- # TODO make more then one property
559
- raise "more then one property is not implemented: #{@property.name} => #{@property.value}" if @property
560
- @property ||= ListItems.new
561
- @property << Property.new(name, value)
562
- end
563
- self
564
- end
565
-
566
- def os(&block)
567
- @os ||= OS.new
568
- block.call(@os) if block
569
- @os
570
- end
571
-
572
- def by_default(value = true)
573
- @activeByDefault = value
574
- self
575
- end
576
- end
577
-
578
- class Property < Tag
579
- tags :name, :value
580
-
581
- def initialize(name, value)
582
- self.name name
583
- self.value value
584
- end
585
- end
586
-
587
- class Repository < Tag
588
- tags :id, :name, :url, :releases, :snapshots
589
- def initialize(id, &block)
590
- super({})
591
- self.id id
592
- if block
593
- block.call(self)
594
- end
595
- self
596
- end
597
-
598
- def releases(args = {})
599
- @releases ||= args
600
- end
601
-
602
- def snapshots(args = {})
603
- @snapshots ||= args
604
- end
605
-
606
- def to_xml(*args)
607
- super
608
- end
609
- end
610
-
611
- class PluginRepository < Repository
612
- tags :dummy
613
- def _name
614
- "pluginRepository"
615
- end
616
- end
617
- end
618
- end