maven-tools 0.29.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/MIT-LICENSE +20 -0
- data/README.md +1 -0
- data/lib/maven-tools.rb +1 -0
- data/lib/maven-tools.rb~ +1 -0
- data/lib/maven/jarfile.rb~ +77 -0
- data/lib/maven/maven_util.rb~ +56 -0
- data/lib/maven/model/dependencies.rb +230 -0
- data/lib/maven/model/dependencies.rb~ +247 -0
- data/lib/maven/model/model.rb +540 -0
- data/lib/maven/model/model.rb~ +528 -0
- data/lib/maven/model/model_utils.rb~ +832 -0
- data/lib/maven/model/utils.rb +343 -0
- data/lib/maven/model/utils.rb~ +322 -0
- data/lib/maven/tools/coordinate.rb +84 -0
- data/lib/maven/tools/coordinate.rb~ +81 -0
- data/lib/maven/tools/execute_in_phase.rb +9 -0
- data/lib/maven/tools/gem_project.rb +503 -0
- data/lib/maven/tools/gem_project.rb~ +498 -0
- data/lib/maven/tools/gemfile_lock.rb +70 -0
- data/lib/maven/tools/gemfile_lock.rb~ +67 -0
- data/lib/maven/tools/jarfile.rb +95 -0
- data/lib/maven/tools/jarfile.rb~ +79 -0
- data/lib/maven/tools/pom_generator.rb +63 -0
- data/lib/maven/tools/rails_project.rb +183 -0
- data/lib/maven/tools/version.rb +5 -0
- data/lib/maven/tools/versions.rb +15 -0
- data/lib/maven/tools/versions.rb~ +13 -0
- data/lib/maven_tools.rb +1 -0
- data/lib/maven_tools.rb~ +1 -0
- data/spec/coordinate_spec.rb +47 -0
- data/spec/jarfile_spec.rb +124 -0
- metadata +118 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Kristian Meier
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# maven tools [](http://travis-ci.org/torquebox/maven-tools) #
|
data/lib/maven-tools.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'maven_tools'
|
data/lib/maven-tools.rb~
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'maven_tools/jarfile'
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'jbundler/maven_util'
|
2
|
+
module JBundler
|
3
|
+
|
4
|
+
class Mavenfile
|
5
|
+
include MavenUtil
|
6
|
+
|
7
|
+
def initialize(file = 'Mvnfile')
|
8
|
+
@file = file
|
9
|
+
@lockfile = file + ".lock"
|
10
|
+
end
|
11
|
+
|
12
|
+
def mtime
|
13
|
+
File.mtime(@file)
|
14
|
+
end
|
15
|
+
|
16
|
+
def exists?
|
17
|
+
File.exists?(@file)
|
18
|
+
end
|
19
|
+
|
20
|
+
def mtime_lock
|
21
|
+
File.mtime(@lockfile)
|
22
|
+
end
|
23
|
+
|
24
|
+
def exists_lock?
|
25
|
+
File.exists?(@lockfile)
|
26
|
+
end
|
27
|
+
|
28
|
+
def load_lockfile
|
29
|
+
_locked = []
|
30
|
+
if exists_lock?
|
31
|
+
File.read(@lockfile).each_line do |line|
|
32
|
+
line.strip!
|
33
|
+
if line.size > 0 && !(line =~ /^\s*#/)
|
34
|
+
_locked << line
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
_locked
|
39
|
+
end
|
40
|
+
|
41
|
+
def locked
|
42
|
+
@locked ||= load_lockfile
|
43
|
+
end
|
44
|
+
|
45
|
+
def locked?(coordinate)
|
46
|
+
coord = coordinate.sub(/^([^:]+:[^:]+):.+/) { $1 }
|
47
|
+
locked.detect { |l| l.sub(/^([^:]+:[^:]+):.+/) { $1 } == coord } != nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def populate_unlocked(aether)
|
51
|
+
File.read(@file).each_line do |line|
|
52
|
+
if coord = to_coordinate(line)
|
53
|
+
unless locked?(coord)
|
54
|
+
aether.add_artifact(coord)
|
55
|
+
end
|
56
|
+
elsif line =~ /^\s*(repository|source)\s/
|
57
|
+
name, url = line.sub(/.*(repository|source)\s+/, '').gsub(/['":]/,'').split(/,/)
|
58
|
+
url = name unless url
|
59
|
+
aether.add_repository(name, url)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def populate_locked(aether)
|
65
|
+
locked.each { |l| aether.add_artifact(l) }
|
66
|
+
end
|
67
|
+
|
68
|
+
def generate_lockfile(dependency_coordinates)
|
69
|
+
File.open(@lockfile, 'w') do |f|
|
70
|
+
dependency_coordinates.each do |d|
|
71
|
+
f.puts d.to_s
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module JBundler
|
2
|
+
module MavenUtil
|
3
|
+
|
4
|
+
def to_coordinate(line)
|
5
|
+
if line =~ /^\s*(jar|pom)\s/
|
6
|
+
|
7
|
+
group_id, artifact_id, version, second_version = line.sub(/\s*[a-z]+\s+/, '').sub(/#.*/,'').gsub(/\s+/,'').gsub(/['"],/, ':').gsub(/['"]/, '').split(/:/)
|
8
|
+
mversion = second_version ? to_version(version, second_version) : to_version(version)
|
9
|
+
extension = line.strip.sub(/\s+.*/, '')
|
10
|
+
"#{group_id}:#{artifact_id}:#{extension}:#{mversion}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_version(*args)
|
15
|
+
if args.size == 0 || (args.size == 1 && args[0].nil?)
|
16
|
+
"[0,)"
|
17
|
+
else
|
18
|
+
low, high = convert(args[0])
|
19
|
+
low, high = convert(args[1], low, high) if args[1] =~ /[=~><]/
|
20
|
+
if low == high
|
21
|
+
low
|
22
|
+
else
|
23
|
+
"#{low || '[0'},#{high || ')'}"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def convert(arg, low = nil, high = nil)
|
31
|
+
if arg =~ /~>/
|
32
|
+
val = arg.sub(/~>\s*/, '')
|
33
|
+
last = val.sub(/\.[^.]+$/, '.99999')
|
34
|
+
["[#{val}", "#{last}]"]
|
35
|
+
elsif arg =~ />=/
|
36
|
+
val = arg.sub(/>=\s*/, '')
|
37
|
+
["[#{val}", (nil || high)]
|
38
|
+
elsif arg =~ /<=/
|
39
|
+
val = arg.sub(/<=\s*/, '')
|
40
|
+
[(nil || low), "#{val}]"]
|
41
|
+
# treat '!' the same way as '>' since maven can not describe such range
|
42
|
+
elsif arg =~ /[!>]/
|
43
|
+
val = arg.sub(/[!>]\s*/, '')
|
44
|
+
["(#{val}", (nil || high)]
|
45
|
+
elsif arg =~ /</
|
46
|
+
val = arg.sub(/<\s*/, '')
|
47
|
+
[(nil || low), "#{val})"]
|
48
|
+
elsif arg =~ /\=/
|
49
|
+
val = arg.sub(/=\s*/, '')
|
50
|
+
["[" + val, val + '.0.0.0.0.1)']
|
51
|
+
else
|
52
|
+
[arg, arg]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
# TODO make nice require after ruby-maven uses the same ruby files
|
2
|
+
require File.join(File.dirname(__FILE__), 'utils.rb')
|
3
|
+
require File.join(File.dirname(File.dirname(__FILE__)), 'tools', 'coordinate.rb')
|
4
|
+
#require 'maven/tools/coordinate'
|
5
|
+
|
6
|
+
module Maven
|
7
|
+
module Model
|
8
|
+
|
9
|
+
class DependencyArray < Array
|
10
|
+
def <<(dep)
|
11
|
+
raise "not of type Dependency" unless dep.is_a?(Dependency)
|
12
|
+
d = detect { |item| item == dep }
|
13
|
+
if d
|
14
|
+
d.version = dep.version
|
15
|
+
self
|
16
|
+
else
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
alias :push :<<
|
21
|
+
end
|
22
|
+
|
23
|
+
class ExclusionArray < Array
|
24
|
+
def <<(*dep)
|
25
|
+
excl = dep[0].is_a?(Exclusion) ? dep[0]: Exclusion.new(*dep.flatten)
|
26
|
+
delete_if { |item| item == excl }
|
27
|
+
super excl
|
28
|
+
end
|
29
|
+
alias :push :<<
|
30
|
+
end
|
31
|
+
|
32
|
+
class Coordinate < Tag
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
include ::Maven::Tools::Coordinate
|
37
|
+
|
38
|
+
public
|
39
|
+
|
40
|
+
tags :group_id, :artifact_id, :version
|
41
|
+
def initialize(*args)
|
42
|
+
@group_id, @artifact_id, @version = gav(*args.flatten)
|
43
|
+
end
|
44
|
+
|
45
|
+
def version?
|
46
|
+
!(@version.nil? || @version == '[0,)')
|
47
|
+
end
|
48
|
+
|
49
|
+
def hash
|
50
|
+
"#{group_id}:#{artifact_id}".hash
|
51
|
+
end
|
52
|
+
|
53
|
+
def ==(other)
|
54
|
+
group_id == other.group_id && artifact_id == other.artifact_id
|
55
|
+
end
|
56
|
+
alias :eql? :==
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
class Parent < Coordinate
|
61
|
+
tags :relative_path
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
class Exclusion < Tag
|
66
|
+
tags :group_id, :artifact_id
|
67
|
+
def initialize(*args)
|
68
|
+
@group_id, @artifact_id = group_artifact(*args)
|
69
|
+
end
|
70
|
+
|
71
|
+
def hash
|
72
|
+
"#{group_id}:#{artifact_id}".hash
|
73
|
+
end
|
74
|
+
|
75
|
+
def ==(other)
|
76
|
+
group_id == other.group_id && artifact_id == other.artifact_id
|
77
|
+
end
|
78
|
+
alias :eql? :==
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
include ::Maven::Tools::Coordinate
|
83
|
+
end
|
84
|
+
|
85
|
+
class Dependency < Coordinate
|
86
|
+
tags :type, :scope, :classifier, :exclusions
|
87
|
+
def initialize(type, *args)
|
88
|
+
super(*args)
|
89
|
+
@type = type
|
90
|
+
args.flatten!
|
91
|
+
if args[0] =~ /:/ && args.size == 3
|
92
|
+
@classifier = args[2] unless args[2] =~ /[=~><]/
|
93
|
+
elsif args.size == 4
|
94
|
+
@classifier = args[3] unless args[3] =~ /[=~><]/
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def hash
|
99
|
+
"#{group_id}:#{artifact_id}:#{@type}:#{@classifier}".hash
|
100
|
+
end
|
101
|
+
|
102
|
+
def ==(other)
|
103
|
+
super && @type == other.instance_variable_get(:@type) && @classifier == other.instance_variable_get(:@classifier)
|
104
|
+
end
|
105
|
+
alias :eql? :==
|
106
|
+
|
107
|
+
def self.new_gem(gemname, *args)
|
108
|
+
new(:gem, "rubygems", gemname, *args)
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.new_pom(*args)
|
112
|
+
new(:pom, *args)
|
113
|
+
end
|
114
|
+
|
115
|
+
def self.new_jar(*args)
|
116
|
+
new(:jar, *args)
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.new_test_jar(*args)
|
120
|
+
result = new(:jar, *args)
|
121
|
+
result.scope :test
|
122
|
+
result
|
123
|
+
end
|
124
|
+
|
125
|
+
def exclusions(&block)
|
126
|
+
@exclusions ||= ExclusionArray.new
|
127
|
+
if block
|
128
|
+
block.call(@exclusions)
|
129
|
+
end
|
130
|
+
@exclusions
|
131
|
+
end
|
132
|
+
|
133
|
+
def exclude(*args)
|
134
|
+
exclusions << args
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
module Dependencies
|
139
|
+
|
140
|
+
def self.included(parent)
|
141
|
+
parent.tags :dependencies
|
142
|
+
end
|
143
|
+
|
144
|
+
def jar?(*args)
|
145
|
+
dependencies.member?(Dependency.new(:jar, *args))
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_jar?(*args)
|
149
|
+
dependencies.member?(Dependency.new_test_jar(*args))
|
150
|
+
end
|
151
|
+
|
152
|
+
def gem?(*args)
|
153
|
+
dependencies.member?(Dependency.new(:gem, ['rubygems', *args].flatten))
|
154
|
+
end
|
155
|
+
|
156
|
+
def detect_gem(name)
|
157
|
+
dependencies.detect { |d| d.type.to_sym == :gem && d.artifact_id == name }
|
158
|
+
end
|
159
|
+
|
160
|
+
def pom?(*args)
|
161
|
+
dependencies.member?(Dependency.new_pom(*args))
|
162
|
+
end
|
163
|
+
|
164
|
+
def dependencies(&block)
|
165
|
+
@dependencies ||= DependencyArray.new
|
166
|
+
if block
|
167
|
+
block.call(self)
|
168
|
+
end
|
169
|
+
@dependencies
|
170
|
+
end
|
171
|
+
|
172
|
+
def add_dependency(dep, has_version = true, &block)
|
173
|
+
d = dependencies.detect { |d| d == dep }
|
174
|
+
if d
|
175
|
+
if has_version
|
176
|
+
d.version = dep.version
|
177
|
+
end
|
178
|
+
dep = d
|
179
|
+
else
|
180
|
+
dependencies << dep
|
181
|
+
end
|
182
|
+
block.call(dep) if block
|
183
|
+
dep
|
184
|
+
end
|
185
|
+
private :add_dependency
|
186
|
+
|
187
|
+
def add_gem(*args, &block)
|
188
|
+
args = args.flatten
|
189
|
+
if args.size == 1
|
190
|
+
dep = Dependency.new_gem(*args)
|
191
|
+
dep = dependencies.detect { |d| d == dep }
|
192
|
+
if dep
|
193
|
+
return dep
|
194
|
+
end
|
195
|
+
args[1] = ">= 0"
|
196
|
+
end
|
197
|
+
add_dependency(Dependency.new_gem(*args), &block)
|
198
|
+
end
|
199
|
+
private :add_gem
|
200
|
+
|
201
|
+
def jar(*args, &block)
|
202
|
+
if args.last.is_a?(Hash)
|
203
|
+
raise "hash not allowed for jar"
|
204
|
+
end
|
205
|
+
add_dependency(Dependency.new_jar(args), args.size > 1, &block)
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_jar(*args, &block)
|
209
|
+
if args.last.is_a?(Hash)
|
210
|
+
raise "hash not allowed for test_jar"
|
211
|
+
end
|
212
|
+
add_dependency(Dependency.new_test_jar(args), args.size > 1, &block)
|
213
|
+
end
|
214
|
+
|
215
|
+
def gem(*args, &block)
|
216
|
+
if args.last.is_a?(Hash)
|
217
|
+
raise "hash not allowed in that context"
|
218
|
+
end
|
219
|
+
add_gem(args, &block)
|
220
|
+
end
|
221
|
+
|
222
|
+
def pom(*args, &block)
|
223
|
+
if args.last.is_a?(Hash)
|
224
|
+
raise "hash not allowed in that context"
|
225
|
+
end
|
226
|
+
add_dependency(Dependency.new_pom(args), args.size > 1, &block)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "tools", 'model.rb')
|
2
|
+
|
3
|
+
module Maven
|
4
|
+
module Model
|
5
|
+
|
6
|
+
class DependencyArray < Array
|
7
|
+
def <<(dep)
|
8
|
+
d = detect { |item| item == dep }
|
9
|
+
if d
|
10
|
+
d.version = arg.version
|
11
|
+
self
|
12
|
+
else
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
alias :push :<<
|
17
|
+
end
|
18
|
+
|
19
|
+
class ExclusionArray < Array
|
20
|
+
def <<(dep)
|
21
|
+
excl = dep.is_a?(Exclusion) ? dep: Exclusion.new(dep)
|
22
|
+
d = detect { |item| item == excl }
|
23
|
+
if d
|
24
|
+
delete d
|
25
|
+
end
|
26
|
+
super excl
|
27
|
+
end
|
28
|
+
alias :push :<<
|
29
|
+
end
|
30
|
+
|
31
|
+
class Coordinate < Maven::Tools::Tag
|
32
|
+
tags :group_id, :artifact_id, :version
|
33
|
+
def initialize(*args)
|
34
|
+
@group_id, @artifact_id, @version = *coordinate(*args.flatten)
|
35
|
+
end
|
36
|
+
|
37
|
+
def coordinate(*args)
|
38
|
+
if args[0] =~ /:/
|
39
|
+
[args[0].sub(/:[^:]+$/, ''), args[0].sub(/.*:/, ''), version(*args[1, 2])]
|
40
|
+
else
|
41
|
+
[args[0], args[1], version(*args[2,3])]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def version(*args)
|
46
|
+
if args.size == 0
|
47
|
+
nil
|
48
|
+
else
|
49
|
+
low, high = convert(args[0])
|
50
|
+
low, high = convert(args[1], low, high) if args[1]
|
51
|
+
if low == high
|
52
|
+
low
|
53
|
+
else
|
54
|
+
"#{low || '[0.0.0'},#{high || ')'}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def convert(arg, low = nil, high = nil)
|
60
|
+
if arg =~ /~>/
|
61
|
+
val = arg.sub(/~>\s*/, '')
|
62
|
+
last = val.sub(/\.[^.]+$/, '.99999')
|
63
|
+
["[#{val}", "#{last}]"]
|
64
|
+
elsif arg =~ />=/
|
65
|
+
val = arg.sub(/>=\s*/, '')
|
66
|
+
["[#{val}", (nil || high)]
|
67
|
+
elsif arg =~ /<=/
|
68
|
+
val = arg.sub(/<=\s*/, '')
|
69
|
+
[(nil || low), "#{val}]"]
|
70
|
+
elsif arg =~ />/
|
71
|
+
val = arg.sub(/>\s*/, '')
|
72
|
+
["(#{val}", (nil || high)]
|
73
|
+
elsif arg =~ /</
|
74
|
+
val = arg.sub(/<\s*/, '')
|
75
|
+
[(nil || low), "#{val})"]
|
76
|
+
else
|
77
|
+
[arg, arg]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def hash
|
82
|
+
"#{group_id}:#{artifact_id}".hash
|
83
|
+
end
|
84
|
+
|
85
|
+
def ==(other)
|
86
|
+
group_id == other.group_id && artifact_id == other.artifact_id
|
87
|
+
end
|
88
|
+
alias :eql? :==
|
89
|
+
end
|
90
|
+
|
91
|
+
class Exclusion < Maven::Tools::Tag
|
92
|
+
tags :group_id, :artifact_id
|
93
|
+
def initialize(*args)
|
94
|
+
@group_id, @artifact_id = *coordinate(*args)
|
95
|
+
end
|
96
|
+
|
97
|
+
def coordinate(*args)
|
98
|
+
case args.size
|
99
|
+
when 1
|
100
|
+
name = args[0].sub(/^mvn:/, '')
|
101
|
+
if name =~ /:/
|
102
|
+
[name.sub(/:[^:]+$/, ''), name.sub(/.*:/, '')]
|
103
|
+
else
|
104
|
+
["rubygems", name]
|
105
|
+
end
|
106
|
+
else
|
107
|
+
[args[0], args[1]]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def hash
|
112
|
+
"#{group_id}:#{artifact_id}".hash
|
113
|
+
end
|
114
|
+
|
115
|
+
def ==(other)
|
116
|
+
group_id == other.group_id && artifact_id == other.artifact_id
|
117
|
+
end
|
118
|
+
alias :eql? :==
|
119
|
+
end
|
120
|
+
|
121
|
+
class Dependency < Coordinate
|
122
|
+
tags :type, :scope, :classifier, :exclusions
|
123
|
+
def initialize(type, *args)
|
124
|
+
super(*args)
|
125
|
+
@type = type
|
126
|
+
end
|
127
|
+
|
128
|
+
def hash
|
129
|
+
"#{group_id}:#{artifact_id}:#{@type}".hash
|
130
|
+
end
|
131
|
+
|
132
|
+
def ==(other)
|
133
|
+
super && @type == other.instance_variable_get(:@type)
|
134
|
+
end
|
135
|
+
alias :eql? :==
|
136
|
+
|
137
|
+
def self.new_gem(gemname, *args)
|
138
|
+
if gemname =~ /^mvn:/
|
139
|
+
new(:maven_gem, gemname.sub(/^mvn:/, ''), *args)
|
140
|
+
else
|
141
|
+
new(:gem, "rubygems", gemname, *args)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def self.new_jar(*args)
|
146
|
+
new(:jar, *args)
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.new_test_jar(*args)
|
150
|
+
new(:test_jar, *args)
|
151
|
+
end
|
152
|
+
|
153
|
+
def exclusions(&block)
|
154
|
+
@exclusions ||= ExclusionArray.new
|
155
|
+
if block
|
156
|
+
block.call(@exclusions)
|
157
|
+
end
|
158
|
+
@exclusions
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
module Dependencies
|
164
|
+
|
165
|
+
def jar?(*args)
|
166
|
+
dependencies.member?(Dependency.new(:jar, *args))
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_jar?(*args)
|
170
|
+
dependencies.member?(Dependency.new(:test_jar, *args))
|
171
|
+
end
|
172
|
+
|
173
|
+
def gem?(*args)
|
174
|
+
dependencies.member?(Dependency.new(:gem, *args))
|
175
|
+
end
|
176
|
+
|
177
|
+
def maven_gem?(*args)
|
178
|
+
dependencies.member?(Dependency.new(:maven_gem, *args))
|
179
|
+
end
|
180
|
+
|
181
|
+
def dependencies(&block)
|
182
|
+
@dependencies ||= DependencyArray.new
|
183
|
+
if block
|
184
|
+
block.call(@dependencies)
|
185
|
+
end
|
186
|
+
@dependencies
|
187
|
+
end
|
188
|
+
|
189
|
+
def lock_file
|
190
|
+
nil
|
191
|
+
end
|
192
|
+
|
193
|
+
def add_dependency(dep, &block)
|
194
|
+
dependencies << dep
|
195
|
+
block.call(dep) if block
|
196
|
+
dep
|
197
|
+
end
|
198
|
+
private :add_dependency
|
199
|
+
|
200
|
+
def add_gem(*args, &block)
|
201
|
+
if lock_file.nil? #|| !lock_file.hull.member?(args[0])
|
202
|
+
args[1] = ">= 0.0.0" unless args[1]
|
203
|
+
add_dependency(:gem, args, block)
|
204
|
+
else
|
205
|
+
result = add_dependency(:gem, args[0], block)
|
206
|
+
|
207
|
+
# add its dependencies as well to have the version
|
208
|
+
# determine by the dependencyManagement
|
209
|
+
lock_file.dependency_hull(args[0]).map.each do |d|
|
210
|
+
add_dependency(:gem, d[0], block)
|
211
|
+
end
|
212
|
+
|
213
|
+
result
|
214
|
+
end
|
215
|
+
end
|
216
|
+
private :add_gem
|
217
|
+
|
218
|
+
def jar(*args, &block)
|
219
|
+
if args.last.is_a?(Hash)
|
220
|
+
raise "hash not allowed for jar"
|
221
|
+
end
|
222
|
+
add_dependency(:jar, args, block)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_jar(*args, &block)
|
226
|
+
if args.last.is_a?(Hash)
|
227
|
+
raise "hash not allowed for test_jar"
|
228
|
+
end
|
229
|
+
add_dependency(:test_jar, args, block)
|
230
|
+
end
|
231
|
+
|
232
|
+
def gem(*args, &block)
|
233
|
+
if args.last.is_a?(Hash)
|
234
|
+
raise "hash not allowed in that context"
|
235
|
+
end
|
236
|
+
add_gem(args, block)
|
237
|
+
end
|
238
|
+
|
239
|
+
def maven_gem(*args, &block)
|
240
|
+
if args.last.is_a?(Hash)
|
241
|
+
raise "hash not allowed in that context"
|
242
|
+
end
|
243
|
+
add_dependency(:maven_gem, args, block)
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|