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/registry.rb
CHANGED
@@ -1,93 +1,93 @@
|
|
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 'singleton'
|
17
|
-
|
18
|
-
#
|
19
|
-
# Registry of resources loaded by LockJar
|
20
|
-
#
|
21
|
-
# @author Michael Guymon
|
22
|
-
#
|
23
|
-
class LockJar::Registry
|
24
|
-
include Singleton
|
25
|
-
|
26
|
-
attr_accessor :loaded_gems
|
27
|
-
attr_accessor :loaded_jars
|
28
|
-
attr_accessor :loaded_lockfiles
|
29
|
-
|
30
|
-
def initialize
|
31
|
-
@loaded_gems = {}
|
32
|
-
@loaded_jars = []
|
33
|
-
@loaded_lockfiles = []
|
34
|
-
end
|
35
|
-
|
36
|
-
def lockfile_registered?( lockfile )
|
37
|
-
if lockfile
|
38
|
-
@loaded_lockfiles.include? File.expand_path( lockfile )
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def register_lockfile( lockfile )
|
43
|
-
if lockfile && !lockfile_registered?( lockfile )
|
44
|
-
@loaded_lockfiles << File.expand_path( lockfile )
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def register_jars( jars )
|
49
|
-
if jars
|
50
|
-
jars_to_load = jars - @loaded_jars
|
51
|
-
|
52
|
-
@loaded_jars += jars_to_load
|
53
|
-
|
54
|
-
jars_to_load
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def register_gem( spec )
|
59
|
-
@loaded_gems[spec.name] = spec
|
60
|
-
end
|
61
|
-
|
62
|
-
def gem_registered?( spec )
|
63
|
-
!@loaded_gems[spec.name].nil?
|
64
|
-
end
|
65
|
-
|
66
|
-
def load_gem( spec )
|
67
|
-
unless gem_registered?( spec )
|
68
|
-
register_gem(spec)
|
69
|
-
gem_dir = spec.gem_dir
|
70
|
-
|
71
|
-
lockfile = File.join( gem_dir, "Jarfile.lock" )
|
72
|
-
|
73
|
-
if File.exists?( lockfile )
|
74
|
-
puts "#{spec.name} has Jarfile.lock, loading jars"
|
75
|
-
LockJar.load( lockfile )
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def load_jars_for_gems
|
81
|
-
specs = Gem.loaded_specs
|
82
|
-
if specs
|
83
|
-
gems = specs.keys - @loaded_gems.keys
|
84
|
-
if gems.size > 0
|
85
|
-
gems.each do |key|
|
86
|
-
spec = specs[key]
|
87
|
-
load_gem( spec )
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
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 'singleton'
|
17
|
+
|
18
|
+
#
|
19
|
+
# Registry of resources loaded by LockJar
|
20
|
+
#
|
21
|
+
# @author Michael Guymon
|
22
|
+
#
|
23
|
+
class LockJar::Registry
|
24
|
+
include Singleton
|
25
|
+
|
26
|
+
attr_accessor :loaded_gems
|
27
|
+
attr_accessor :loaded_jars
|
28
|
+
attr_accessor :loaded_lockfiles
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
@loaded_gems = {}
|
32
|
+
@loaded_jars = []
|
33
|
+
@loaded_lockfiles = []
|
34
|
+
end
|
35
|
+
|
36
|
+
def lockfile_registered?( lockfile )
|
37
|
+
if lockfile
|
38
|
+
@loaded_lockfiles.include? File.expand_path( lockfile )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def register_lockfile( lockfile )
|
43
|
+
if lockfile && !lockfile_registered?( lockfile )
|
44
|
+
@loaded_lockfiles << File.expand_path( lockfile )
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def register_jars( jars )
|
49
|
+
if jars
|
50
|
+
jars_to_load = jars - @loaded_jars
|
51
|
+
|
52
|
+
@loaded_jars += jars_to_load
|
53
|
+
|
54
|
+
jars_to_load
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def register_gem( spec )
|
59
|
+
@loaded_gems[spec.name] = spec
|
60
|
+
end
|
61
|
+
|
62
|
+
def gem_registered?( spec )
|
63
|
+
!@loaded_gems[spec.name].nil?
|
64
|
+
end
|
65
|
+
|
66
|
+
def load_gem( spec )
|
67
|
+
unless gem_registered?( spec )
|
68
|
+
register_gem(spec)
|
69
|
+
gem_dir = spec.gem_dir
|
70
|
+
|
71
|
+
lockfile = File.join( gem_dir, "Jarfile.lock" )
|
72
|
+
|
73
|
+
if File.exists?( lockfile )
|
74
|
+
puts "#{spec.name} has Jarfile.lock, loading jars"
|
75
|
+
LockJar.load( lockfile )
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def load_jars_for_gems
|
81
|
+
specs = Gem.loaded_specs
|
82
|
+
if specs
|
83
|
+
gems = specs.keys - @loaded_gems.keys
|
84
|
+
if gems.size > 0
|
85
|
+
gems.each do |key|
|
86
|
+
spec = specs[key]
|
87
|
+
load_gem( spec )
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
93
|
end
|
data/lib/lock_jar/resolver.rb
CHANGED
@@ -1,96 +1,96 @@
|
|
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 'rubygems'
|
17
|
-
require 'naether'
|
18
|
-
require 'naether/bootstrap'
|
19
|
-
require 'fileutils'
|
20
|
-
|
21
|
-
module LockJar
|
22
|
-
class Resolver
|
23
|
-
|
24
|
-
attr_reader :opts
|
25
|
-
attr_reader :naether
|
26
|
-
|
27
|
-
def initialize( opts = {} )
|
28
|
-
|
29
|
-
@opts = opts
|
30
|
-
local_repo = opts[:local_repo] || Naether::Bootstrap.default_local_repo
|
31
|
-
|
32
|
-
# Bootstrap Naether
|
33
|
-
Naether::Bootstrap.bootstrap_local_repo( local_repo, opts )
|
34
|
-
|
35
|
-
# Bootstrapping naether will create an instance from downloaded jars.
|
36
|
-
# If jars exist locally already, create manually
|
37
|
-
@naether = Naether.create
|
38
|
-
@naether.local_repo_path = local_repo if local_repo
|
39
|
-
@naether.clear_remote_repositories if opts[:offline]
|
40
|
-
end
|
41
|
-
|
42
|
-
def remote_repositories
|
43
|
-
@naether.remote_repository_urls
|
44
|
-
end
|
45
|
-
|
46
|
-
def add_remote_repository( repo )
|
47
|
-
@naether.add_remote_repository( repo )
|
48
|
-
end
|
49
|
-
|
50
|
-
|
51
|
-
def resolve( dependencies, download_artifacts = true )
|
52
|
-
@naether.dependencies = dependencies
|
53
|
-
@naether.resolve_dependencies( download_artifacts )
|
54
|
-
@naether.dependencies_notation
|
55
|
-
end
|
56
|
-
|
57
|
-
def dependencies_graph
|
58
|
-
@naether.dependencies_graph
|
59
|
-
end
|
60
|
-
|
61
|
-
def download( dependencies )
|
62
|
-
@naether.download_artifacts( dependencies )
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_local_paths( notations )
|
66
|
-
paths = []
|
67
|
-
notations.each do |notation|
|
68
|
-
if File.exists?(notation)
|
69
|
-
paths << notation
|
70
|
-
else
|
71
|
-
paths = paths + @naether.to_local_paths( [notation] )
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
paths
|
76
|
-
end
|
77
|
-
|
78
|
-
def load_to_classpath( artifacts )
|
79
|
-
paths = []
|
80
|
-
notations = []
|
81
|
-
|
82
|
-
artifacts.each do |art|
|
83
|
-
if File.exists?(art)
|
84
|
-
paths << art
|
85
|
-
else
|
86
|
-
notations << art
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
paths += @naether.to_local_paths( notations )
|
91
|
-
Naether::Java.load_paths( paths )
|
92
|
-
|
93
|
-
paths
|
94
|
-
end
|
95
|
-
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 'rubygems'
|
17
|
+
require 'naether'
|
18
|
+
require 'naether/bootstrap'
|
19
|
+
require 'fileutils'
|
20
|
+
|
21
|
+
module LockJar
|
22
|
+
class Resolver
|
23
|
+
|
24
|
+
attr_reader :opts
|
25
|
+
attr_reader :naether
|
26
|
+
|
27
|
+
def initialize( opts = {} )
|
28
|
+
|
29
|
+
@opts = opts
|
30
|
+
local_repo = opts[:local_repo] || Naether::Bootstrap.default_local_repo
|
31
|
+
|
32
|
+
# Bootstrap Naether
|
33
|
+
Naether::Bootstrap.bootstrap_local_repo( local_repo, opts )
|
34
|
+
|
35
|
+
# Bootstrapping naether will create an instance from downloaded jars.
|
36
|
+
# If jars exist locally already, create manually
|
37
|
+
@naether = Naether.create
|
38
|
+
@naether.local_repo_path = local_repo if local_repo
|
39
|
+
@naether.clear_remote_repositories if opts[:offline]
|
40
|
+
end
|
41
|
+
|
42
|
+
def remote_repositories
|
43
|
+
@naether.remote_repository_urls
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_remote_repository( repo )
|
47
|
+
@naether.add_remote_repository( repo )
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def resolve( dependencies, download_artifacts = true )
|
52
|
+
@naether.dependencies = dependencies
|
53
|
+
@naether.resolve_dependencies( download_artifacts )
|
54
|
+
@naether.dependencies_notation
|
55
|
+
end
|
56
|
+
|
57
|
+
def dependencies_graph
|
58
|
+
@naether.dependencies_graph
|
59
|
+
end
|
60
|
+
|
61
|
+
def download( dependencies )
|
62
|
+
@naether.download_artifacts( dependencies )
|
63
|
+
end
|
64
|
+
|
65
|
+
def to_local_paths( notations )
|
66
|
+
paths = []
|
67
|
+
notations.each do |notation|
|
68
|
+
if File.exists?(notation)
|
69
|
+
paths << notation
|
70
|
+
else
|
71
|
+
paths = paths + @naether.to_local_paths( [notation] )
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
paths
|
76
|
+
end
|
77
|
+
|
78
|
+
def load_to_classpath( artifacts )
|
79
|
+
paths = []
|
80
|
+
notations = []
|
81
|
+
|
82
|
+
artifacts.each do |art|
|
83
|
+
if File.exists?(art)
|
84
|
+
paths << art
|
85
|
+
else
|
86
|
+
notations << art
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
paths += @naether.to_local_paths( notations )
|
91
|
+
Naether::Java.load_paths( paths )
|
92
|
+
|
93
|
+
paths
|
94
|
+
end
|
95
|
+
end
|
96
96
|
end
|