lock_jar 0.10.0 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +59 -59
- data/.travis.yml +8 -8
- data/CHANGELOG.md +30 -21
- data/Gemfile +13 -13
- data/Guardfile +9 -9
- data/README.md +375 -375
- data/Rakefile +24 -24
- data/bundler/Gemfile +21 -21
- data/bundler/LICENSE.txt +22 -22
- data/bundler/README.md +29 -29
- data/bundler/Rakefile +2 -2
- data/bundler/lib/lock_jar_bundler/bundler.rb +35 -35
- data/bundler/lib/lock_jar_bundler/piggy_back.rb +97 -97
- data/bundler/lib/lock_jar_bundler/version.rb +5 -5
- data/bundler/lib/lock_jar_bundler.rb +4 -4
- data/bundler/lock_jar_bundler.gemspec +24 -24
- data/bundler/spec/Jarfile +2 -2
- data/bundler/spec/dummy_gem/dummy_gem.gemspec +19 -19
- data/bundler/spec/lock_jar_bundler_spec.rb +48 -48
- data/bundler/spec/spec_helper.rb +88 -88
- data/lib/lock_jar/buildr.rb +144 -144
- data/lib/lock_jar/bundler.rb +154 -154
- data/lib/lock_jar/cli.rb +64 -64
- data/lib/lock_jar/domain/artifact.rb +123 -123
- data/lib/lock_jar/domain/dsl.rb +187 -187
- data/lib/lock_jar/domain/dsl_helper.rb +83 -83
- data/lib/lock_jar/domain/gem_dsl.rb +44 -44
- data/lib/lock_jar/domain/jarfile_dsl.rb +46 -46
- data/lib/lock_jar/domain/lockfile.rb +113 -113
- data/lib/lock_jar/maven.rb +111 -111
- data/lib/lock_jar/registry.rb +92 -92
- data/lib/lock_jar/resolver.rb +95 -95
- data/lib/lock_jar/runtime.rb +359 -355
- data/lib/lock_jar/version.rb +3 -3
- data/lib/lock_jar.rb +172 -177
- data/lock_jar.gemspec +27 -27
- data/spec/fixtures/Jarfile +13 -13
- data/spec/fixtures/Jarfile2 +1 -0
- data/spec/lock_jar/class_loader_spec.rb +57 -57
- data/spec/lock_jar/cli_spec.rb +100 -100
- data/spec/lock_jar/domain/dsl_helper_spec.rb +52 -52
- data/spec/lock_jar/domain/dsl_spec.rb +57 -57
- data/spec/lock_jar/maven_spec.rb +23 -23
- data/spec/lock_jar/resolver_spec.rb +26 -26
- data/spec/lock_jar/runtime_spec.rb +26 -26
- data/spec/lock_jar_spec.rb +372 -295
- data/spec/pom.xml +34 -34
- data/spec/spec_helper.rb +38 -38
- data/spec/support/helper.rb +44 -44
- metadata +3 -1
data/lib/lock_jar/bundler.rb
CHANGED
@@ -1,155 +1,155 @@
|
|
1
|
-
require 'lock_jar'
|
2
|
-
require 'lock_jar/registry'
|
3
|
-
require 'lock_jar/domain/lockfile'
|
4
|
-
require 'lock_jar/domain/dsl'
|
5
|
-
require 'lock_jar/domain/gem_dsl'
|
6
|
-
require 'lock_jar/domain/jarfile_dsl'
|
7
|
-
require 'lock_jar/domain/dsl_helper'
|
8
|
-
|
9
|
-
module LockJar
|
10
|
-
|
11
|
-
class Bundler
|
12
|
-
|
13
|
-
class << self
|
14
|
-
|
15
|
-
attr_accessor :skip_lock
|
16
|
-
|
17
|
-
def load(*groups)
|
18
|
-
if groups && !groups.empty? && File.exists?( 'Jarfile.lock')
|
19
|
-
|
20
|
-
lockfile = LockJar::Domain::Lockfile.read( 'Jarfile.lock' )
|
21
|
-
|
22
|
-
# expand merged paths to include gem base path
|
23
|
-
unless lockfile.merged.empty?
|
24
|
-
lockfile.merged = LockJar::Bundler.expand_gem_paths( lockfile.merged )
|
25
|
-
end
|
26
|
-
|
27
|
-
LockJar.load( lockfile, groups )
|
28
|
-
|
29
|
-
if ENV["DEBUG"]
|
30
|
-
puts "[LockJar] Loaded Jars for #{groups.inspect}: #{LockJar::Registry.instance.loaded_jars.inspect}"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def expand_gem_paths(merged)
|
36
|
-
|
37
|
-
merged_gem_paths = []
|
38
|
-
Gem.path.each do |gem_root|
|
39
|
-
merged.each do |merge|
|
40
|
-
# merged gems follow the notation: gem:gemname:path
|
41
|
-
if merge.start_with? 'gem:'
|
42
|
-
gem_path = merge.gsub(/^gem:.+:/, '')
|
43
|
-
gem_path = File.join( gem_root, gem_path )
|
44
|
-
if File.exists? gem_path
|
45
|
-
merged_gem_paths << gem_path
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
merged_gem_paths
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
module Bundler
|
59
|
-
class << self
|
60
|
-
alias :_lockjar_extended_require :require
|
61
|
-
def require(*groups)
|
62
|
-
LockJar::Bundler.load(*groups)
|
63
|
-
|
64
|
-
LockJar::Bundler.skip_lock = true
|
65
|
-
|
66
|
-
_lockjar_extended_require
|
67
|
-
end
|
68
|
-
|
69
|
-
alias :_lockjar_extended_setup :setup
|
70
|
-
def setup(*groups)
|
71
|
-
LockJar::Bundler.load(*groups)
|
72
|
-
|
73
|
-
LockJar::Bundler.skip_lock = true
|
74
|
-
|
75
|
-
_lockjar_extended_setup
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
class Runtime
|
80
|
-
|
81
|
-
alias :_lockjar_extended_require :require
|
82
|
-
def require(*groups)
|
83
|
-
LockJar::Bundler.load(*groups)
|
84
|
-
|
85
|
-
LockJar::Bundler.skip_lock = true
|
86
|
-
|
87
|
-
_lockjar_extended_require
|
88
|
-
end
|
89
|
-
|
90
|
-
alias :_lockjar_extended_setup :setup
|
91
|
-
def setup(*groups)
|
92
|
-
LockJar::Bundler.load(*groups)
|
93
|
-
|
94
|
-
LockJar::Bundler.skip_lock = true
|
95
|
-
|
96
|
-
_lockjar_extended_setup
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class Definition
|
101
|
-
alias :_lockjar_extended_to_lock :to_lock
|
102
|
-
def to_lock
|
103
|
-
to_lock = _lockjar_extended_to_lock
|
104
|
-
|
105
|
-
if LockJar::Bundler.skip_lock != true
|
106
|
-
definition = Bundler.definition
|
107
|
-
#if !definition.send( :nothing_changed? )
|
108
|
-
gems_with_jars = []
|
109
|
-
|
110
|
-
# load local Jarfile
|
111
|
-
if File.exists?( 'Jarfile' )
|
112
|
-
dsl = LockJar::Domain::JarfileDsl.create( File.expand_path( 'Jarfile' ) )
|
113
|
-
gems_with_jars << 'jarfile:Jarfile'
|
114
|
-
# Create new Dsl
|
115
|
-
else
|
116
|
-
dsl = LockJar::Domain::Dsl.new
|
117
|
-
end
|
118
|
-
|
119
|
-
definition.groups.each do |group|
|
120
|
-
if ENV["DEBUG"]
|
121
|
-
puts "[LockJar] Group #{group}:"
|
122
|
-
end
|
123
|
-
|
124
|
-
definition.specs_for( [group] ).each do |spec|
|
125
|
-
gem_dir = spec.gem_dir
|
126
|
-
|
127
|
-
jarfile = File.join( gem_dir, "Jarfile" )
|
128
|
-
|
129
|
-
if File.exists?( jarfile )
|
130
|
-
gems_with_jars << "gem:#{spec.name}"
|
131
|
-
|
132
|
-
if ENV["DEBUG"]
|
133
|
-
puts "[LockJar] #{spec.name} has Jarfile"
|
134
|
-
end
|
135
|
-
|
136
|
-
spec_dsl = LockJar::Domain::GemDsl.create( spec, "Jarfile" )
|
137
|
-
|
138
|
-
dsl = LockJar::Domain::DslHelper.merge( dsl, spec_dsl, group.to_s )
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
|
144
|
-
puts "[LockJar] Locking Jars for: #{gems_with_jars.inspect}"
|
145
|
-
LockJar.lock( dsl )
|
146
|
-
#elsif ENV["DEBUG"]
|
147
|
-
# puts "[LockJar] Locking skiped, Gemfile has not changed"
|
148
|
-
#end
|
149
|
-
end
|
150
|
-
|
151
|
-
to_lock
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
1
|
+
require 'lock_jar'
|
2
|
+
require 'lock_jar/registry'
|
3
|
+
require 'lock_jar/domain/lockfile'
|
4
|
+
require 'lock_jar/domain/dsl'
|
5
|
+
require 'lock_jar/domain/gem_dsl'
|
6
|
+
require 'lock_jar/domain/jarfile_dsl'
|
7
|
+
require 'lock_jar/domain/dsl_helper'
|
8
|
+
|
9
|
+
module LockJar
|
10
|
+
|
11
|
+
class Bundler
|
12
|
+
|
13
|
+
class << self
|
14
|
+
|
15
|
+
attr_accessor :skip_lock
|
16
|
+
|
17
|
+
def load(*groups)
|
18
|
+
if groups && !groups.empty? && File.exists?( 'Jarfile.lock')
|
19
|
+
|
20
|
+
lockfile = LockJar::Domain::Lockfile.read( 'Jarfile.lock' )
|
21
|
+
|
22
|
+
# expand merged paths to include gem base path
|
23
|
+
unless lockfile.merged.empty?
|
24
|
+
lockfile.merged = LockJar::Bundler.expand_gem_paths( lockfile.merged )
|
25
|
+
end
|
26
|
+
|
27
|
+
LockJar.load( lockfile, groups )
|
28
|
+
|
29
|
+
if ENV["DEBUG"]
|
30
|
+
puts "[LockJar] Loaded Jars for #{groups.inspect}: #{LockJar::Registry.instance.loaded_jars.inspect}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def expand_gem_paths(merged)
|
36
|
+
|
37
|
+
merged_gem_paths = []
|
38
|
+
Gem.path.each do |gem_root|
|
39
|
+
merged.each do |merge|
|
40
|
+
# merged gems follow the notation: gem:gemname:path
|
41
|
+
if merge.start_with? 'gem:'
|
42
|
+
gem_path = merge.gsub(/^gem:.+:/, '')
|
43
|
+
gem_path = File.join( gem_root, gem_path )
|
44
|
+
if File.exists? gem_path
|
45
|
+
merged_gem_paths << gem_path
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
merged_gem_paths
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
module Bundler
|
59
|
+
class << self
|
60
|
+
alias :_lockjar_extended_require :require
|
61
|
+
def require(*groups)
|
62
|
+
LockJar::Bundler.load(*groups)
|
63
|
+
|
64
|
+
LockJar::Bundler.skip_lock = true
|
65
|
+
|
66
|
+
_lockjar_extended_require
|
67
|
+
end
|
68
|
+
|
69
|
+
alias :_lockjar_extended_setup :setup
|
70
|
+
def setup(*groups)
|
71
|
+
LockJar::Bundler.load(*groups)
|
72
|
+
|
73
|
+
LockJar::Bundler.skip_lock = true
|
74
|
+
|
75
|
+
_lockjar_extended_setup
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Runtime
|
80
|
+
|
81
|
+
alias :_lockjar_extended_require :require
|
82
|
+
def require(*groups)
|
83
|
+
LockJar::Bundler.load(*groups)
|
84
|
+
|
85
|
+
LockJar::Bundler.skip_lock = true
|
86
|
+
|
87
|
+
_lockjar_extended_require
|
88
|
+
end
|
89
|
+
|
90
|
+
alias :_lockjar_extended_setup :setup
|
91
|
+
def setup(*groups)
|
92
|
+
LockJar::Bundler.load(*groups)
|
93
|
+
|
94
|
+
LockJar::Bundler.skip_lock = true
|
95
|
+
|
96
|
+
_lockjar_extended_setup
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class Definition
|
101
|
+
alias :_lockjar_extended_to_lock :to_lock
|
102
|
+
def to_lock
|
103
|
+
to_lock = _lockjar_extended_to_lock
|
104
|
+
|
105
|
+
if LockJar::Bundler.skip_lock != true
|
106
|
+
definition = Bundler.definition
|
107
|
+
#if !definition.send( :nothing_changed? )
|
108
|
+
gems_with_jars = []
|
109
|
+
|
110
|
+
# load local Jarfile
|
111
|
+
if File.exists?( 'Jarfile' )
|
112
|
+
dsl = LockJar::Domain::JarfileDsl.create( File.expand_path( 'Jarfile' ) )
|
113
|
+
gems_with_jars << 'jarfile:Jarfile'
|
114
|
+
# Create new Dsl
|
115
|
+
else
|
116
|
+
dsl = LockJar::Domain::Dsl.new
|
117
|
+
end
|
118
|
+
|
119
|
+
definition.groups.each do |group|
|
120
|
+
if ENV["DEBUG"]
|
121
|
+
puts "[LockJar] Group #{group}:"
|
122
|
+
end
|
123
|
+
|
124
|
+
definition.specs_for( [group] ).each do |spec|
|
125
|
+
gem_dir = spec.gem_dir
|
126
|
+
|
127
|
+
jarfile = File.join( gem_dir, "Jarfile" )
|
128
|
+
|
129
|
+
if File.exists?( jarfile )
|
130
|
+
gems_with_jars << "gem:#{spec.name}"
|
131
|
+
|
132
|
+
if ENV["DEBUG"]
|
133
|
+
puts "[LockJar] #{spec.name} has Jarfile"
|
134
|
+
end
|
135
|
+
|
136
|
+
spec_dsl = LockJar::Domain::GemDsl.create( spec, "Jarfile" )
|
137
|
+
|
138
|
+
dsl = LockJar::Domain::DslHelper.merge( dsl, spec_dsl, group.to_s )
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
puts "[LockJar] Locking Jars for: #{gems_with_jars.inspect}"
|
145
|
+
LockJar.lock( dsl )
|
146
|
+
#elsif ENV["DEBUG"]
|
147
|
+
# puts "[LockJar] Locking skiped, Gemfile has not changed"
|
148
|
+
#end
|
149
|
+
end
|
150
|
+
|
151
|
+
to_lock
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
155
|
end
|
data/lib/lock_jar/cli.rb
CHANGED
@@ -1,64 +1,64 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'thor'
|
3
|
-
require 'lock_jar'
|
4
|
-
|
5
|
-
module LockJar
|
6
|
-
|
7
|
-
class CLI < Thor
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
def generate_lockfile_option
|
11
|
-
method_option :lockfile,
|
12
|
-
:aliases => "-l",
|
13
|
-
:default => 'Jarfile.lock',
|
14
|
-
:desc => "Path to Jarfile.lock"
|
15
|
-
end
|
16
|
-
|
17
|
-
def generate_scopes_option
|
18
|
-
method_option :scopes,
|
19
|
-
:aliases => "-s",
|
20
|
-
:default => ['default'],
|
21
|
-
:desc => "Scopes to install from Jarfile.lock",
|
22
|
-
:type => :array
|
23
|
-
end
|
24
|
-
|
25
|
-
def generate_jarfile_option
|
26
|
-
method_option :jarfile,
|
27
|
-
:aliases => "-j",
|
28
|
-
:default => 'Jarfile',
|
29
|
-
:desc => "Path to Jarfile"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
extend(ClassMethods)
|
33
|
-
|
34
|
-
desc "version", "LockJar version"
|
35
|
-
def version
|
36
|
-
puts LockJar::VERSION
|
37
|
-
end
|
38
|
-
|
39
|
-
desc "install", "Install Jars from a Jarfile.lock"
|
40
|
-
generate_lockfile_option
|
41
|
-
generate_scopes_option
|
42
|
-
def install
|
43
|
-
puts "Installing Jars from #{options[:lockfile]} for #{options[:scopes].inspect}"
|
44
|
-
LockJar.install( options[:lockfile], options[:scopes] )
|
45
|
-
end
|
46
|
-
|
47
|
-
desc "list", "List Jars from a Jarfile.lock"
|
48
|
-
generate_lockfile_option
|
49
|
-
generate_scopes_option
|
50
|
-
def list
|
51
|
-
puts "Listing Jars from #{options[:lockfile]} for #{options[:scopes].inspect}"
|
52
|
-
puts LockJar.list( options[:lockfile], options[:scopes] ).inspect
|
53
|
-
end
|
54
|
-
|
55
|
-
desc 'lock', 'Lock Jars in a Jarfile.lock'
|
56
|
-
generate_jarfile_option
|
57
|
-
generate_lockfile_option
|
58
|
-
def lock
|
59
|
-
puts "Locking #{options[:jarfile]} to #{options[:lockfile]}"
|
60
|
-
LockJar.lock( options[:jarfile], { :lockfile => options[:lockfile] } )
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'thor'
|
3
|
+
require 'lock_jar'
|
4
|
+
|
5
|
+
module LockJar
|
6
|
+
|
7
|
+
class CLI < Thor
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def generate_lockfile_option
|
11
|
+
method_option :lockfile,
|
12
|
+
:aliases => "-l",
|
13
|
+
:default => 'Jarfile.lock',
|
14
|
+
:desc => "Path to Jarfile.lock"
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_scopes_option
|
18
|
+
method_option :scopes,
|
19
|
+
:aliases => "-s",
|
20
|
+
:default => ['default'],
|
21
|
+
:desc => "Scopes to install from Jarfile.lock",
|
22
|
+
:type => :array
|
23
|
+
end
|
24
|
+
|
25
|
+
def generate_jarfile_option
|
26
|
+
method_option :jarfile,
|
27
|
+
:aliases => "-j",
|
28
|
+
:default => 'Jarfile',
|
29
|
+
:desc => "Path to Jarfile"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
extend(ClassMethods)
|
33
|
+
|
34
|
+
desc "version", "LockJar version"
|
35
|
+
def version
|
36
|
+
puts LockJar::VERSION
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "install", "Install Jars from a Jarfile.lock"
|
40
|
+
generate_lockfile_option
|
41
|
+
generate_scopes_option
|
42
|
+
def install
|
43
|
+
puts "Installing Jars from #{options[:lockfile]} for #{options[:scopes].inspect}"
|
44
|
+
LockJar.install( options[:lockfile], options[:scopes] )
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "list", "List Jars from a Jarfile.lock"
|
48
|
+
generate_lockfile_option
|
49
|
+
generate_scopes_option
|
50
|
+
def list
|
51
|
+
puts "Listing Jars from #{options[:lockfile]} for #{options[:scopes].inspect}"
|
52
|
+
puts LockJar.list( options[:lockfile], options[:scopes] ).inspect
|
53
|
+
end
|
54
|
+
|
55
|
+
desc 'lock', 'Lock Jars in a Jarfile.lock'
|
56
|
+
generate_jarfile_option
|
57
|
+
generate_lockfile_option
|
58
|
+
def lock
|
59
|
+
puts "Locking #{options[:jarfile]} to #{options[:lockfile]}"
|
60
|
+
LockJar.lock( options[:jarfile], { :lockfile => options[:lockfile] } )
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -1,124 +1,124 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
require 'set'
|
17
|
-
require 'lock_jar/maven'
|
18
|
-
require 'naether/notation'
|
19
|
-
|
20
|
-
module LockJar
|
21
|
-
module Domain
|
22
|
-
|
23
|
-
|
24
|
-
class Artifact
|
25
|
-
include Comparable
|
26
|
-
attr_reader :type
|
27
|
-
|
28
|
-
def <=>(another_artifact)
|
29
|
-
if another_artifact.is_a? Artifact
|
30
|
-
to_urn <=> another_artifact.to_urn
|
31
|
-
else
|
32
|
-
to_urn <=> another_artifact.to_s
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def resolvable?
|
37
|
-
true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
class Jar < Artifact
|
42
|
-
attr_reader :notation
|
43
|
-
|
44
|
-
def initialize( notation )
|
45
|
-
@type = 'jar'
|
46
|
-
@notation = Naether::Notation.new( notation ).to_notation
|
47
|
-
end
|
48
|
-
|
49
|
-
def to_urn
|
50
|
-
"jar:#{notation}"
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_dep
|
54
|
-
notation
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
class Local < Artifact
|
59
|
-
attr_reader :path
|
60
|
-
def initialize( path )
|
61
|
-
@type = 'local'
|
62
|
-
@path = path
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_urn
|
66
|
-
"local:#{path}"
|
67
|
-
end
|
68
|
-
|
69
|
-
def to_dep
|
70
|
-
path
|
71
|
-
end
|
72
|
-
|
73
|
-
def resolvable?
|
74
|
-
false
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
class Pom < Artifact
|
79
|
-
attr_reader :path, :scopes
|
80
|
-
|
81
|
-
def initialize( _path, _scopes = ['compile','runtime'] )
|
82
|
-
@type = 'pom'
|
83
|
-
@path = _path
|
84
|
-
@scopes = _scopes
|
85
|
-
end
|
86
|
-
|
87
|
-
def to_urn
|
88
|
-
"pom:#{path}"
|
89
|
-
end
|
90
|
-
|
91
|
-
def to_dep
|
92
|
-
{ path => scopes }
|
93
|
-
end
|
94
|
-
|
95
|
-
def notations
|
96
|
-
LockJar::Maven.dependencies( path, scopes )
|
97
|
-
end
|
98
|
-
|
99
|
-
def ==(another_artifact)
|
100
|
-
self.<=>(another_artifact) == 0
|
101
|
-
end
|
102
|
-
|
103
|
-
def <=>(another_artifact)
|
104
|
-
if another_artifact.is_a? Pom
|
105
|
-
if to_urn == another_artifact.to_urn
|
106
|
-
return 0 if Set.new(scopes) == Set.new(another_artifact.scopes)
|
107
|
-
|
108
|
-
# XXX: this is not a reliable way to compare.
|
109
|
-
if scopes.size > another_artifact.scopes.size
|
110
|
-
return 1
|
111
|
-
else
|
112
|
-
return -1
|
113
|
-
end
|
114
|
-
else
|
115
|
-
to_urn <=> another_artifact.to_urn
|
116
|
-
end
|
117
|
-
else
|
118
|
-
super
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
end
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require 'set'
|
17
|
+
require 'lock_jar/maven'
|
18
|
+
require 'naether/notation'
|
19
|
+
|
20
|
+
module LockJar
|
21
|
+
module Domain
|
22
|
+
|
23
|
+
|
24
|
+
class Artifact
|
25
|
+
include Comparable
|
26
|
+
attr_reader :type
|
27
|
+
|
28
|
+
def <=>(another_artifact)
|
29
|
+
if another_artifact.is_a? Artifact
|
30
|
+
to_urn <=> another_artifact.to_urn
|
31
|
+
else
|
32
|
+
to_urn <=> another_artifact.to_s
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def resolvable?
|
37
|
+
true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Jar < Artifact
|
42
|
+
attr_reader :notation
|
43
|
+
|
44
|
+
def initialize( notation )
|
45
|
+
@type = 'jar'
|
46
|
+
@notation = Naether::Notation.new( notation ).to_notation
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_urn
|
50
|
+
"jar:#{notation}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_dep
|
54
|
+
notation
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Local < Artifact
|
59
|
+
attr_reader :path
|
60
|
+
def initialize( path )
|
61
|
+
@type = 'local'
|
62
|
+
@path = path
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_urn
|
66
|
+
"local:#{path}"
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_dep
|
70
|
+
path
|
71
|
+
end
|
72
|
+
|
73
|
+
def resolvable?
|
74
|
+
false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class Pom < Artifact
|
79
|
+
attr_reader :path, :scopes
|
80
|
+
|
81
|
+
def initialize( _path, _scopes = ['compile','runtime'] )
|
82
|
+
@type = 'pom'
|
83
|
+
@path = _path
|
84
|
+
@scopes = _scopes
|
85
|
+
end
|
86
|
+
|
87
|
+
def to_urn
|
88
|
+
"pom:#{path}"
|
89
|
+
end
|
90
|
+
|
91
|
+
def to_dep
|
92
|
+
{ path => scopes }
|
93
|
+
end
|
94
|
+
|
95
|
+
def notations
|
96
|
+
LockJar::Maven.dependencies( path, scopes )
|
97
|
+
end
|
98
|
+
|
99
|
+
def ==(another_artifact)
|
100
|
+
self.<=>(another_artifact) == 0
|
101
|
+
end
|
102
|
+
|
103
|
+
def <=>(another_artifact)
|
104
|
+
if another_artifact.is_a? Pom
|
105
|
+
if to_urn == another_artifact.to_urn
|
106
|
+
return 0 if Set.new(scopes) == Set.new(another_artifact.scopes)
|
107
|
+
|
108
|
+
# XXX: this is not a reliable way to compare.
|
109
|
+
if scopes.size > another_artifact.scopes.size
|
110
|
+
return 1
|
111
|
+
else
|
112
|
+
return -1
|
113
|
+
end
|
114
|
+
else
|
115
|
+
to_urn <=> another_artifact.to_urn
|
116
|
+
end
|
117
|
+
else
|
118
|
+
super
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
124
|
end
|