lock_jar 0.10.0 → 0.10.2

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +59 -59
  3. data/.travis.yml +8 -8
  4. data/CHANGELOG.md +30 -21
  5. data/Gemfile +13 -13
  6. data/Guardfile +9 -9
  7. data/README.md +375 -375
  8. data/Rakefile +24 -24
  9. data/bundler/Gemfile +21 -21
  10. data/bundler/LICENSE.txt +22 -22
  11. data/bundler/README.md +29 -29
  12. data/bundler/Rakefile +2 -2
  13. data/bundler/lib/lock_jar_bundler/bundler.rb +35 -35
  14. data/bundler/lib/lock_jar_bundler/piggy_back.rb +97 -97
  15. data/bundler/lib/lock_jar_bundler/version.rb +5 -5
  16. data/bundler/lib/lock_jar_bundler.rb +4 -4
  17. data/bundler/lock_jar_bundler.gemspec +24 -24
  18. data/bundler/spec/Jarfile +2 -2
  19. data/bundler/spec/dummy_gem/dummy_gem.gemspec +19 -19
  20. data/bundler/spec/lock_jar_bundler_spec.rb +48 -48
  21. data/bundler/spec/spec_helper.rb +88 -88
  22. data/lib/lock_jar/buildr.rb +144 -144
  23. data/lib/lock_jar/bundler.rb +154 -154
  24. data/lib/lock_jar/cli.rb +64 -64
  25. data/lib/lock_jar/domain/artifact.rb +123 -123
  26. data/lib/lock_jar/domain/dsl.rb +187 -187
  27. data/lib/lock_jar/domain/dsl_helper.rb +83 -83
  28. data/lib/lock_jar/domain/gem_dsl.rb +44 -44
  29. data/lib/lock_jar/domain/jarfile_dsl.rb +46 -46
  30. data/lib/lock_jar/domain/lockfile.rb +113 -113
  31. data/lib/lock_jar/maven.rb +111 -111
  32. data/lib/lock_jar/registry.rb +92 -92
  33. data/lib/lock_jar/resolver.rb +95 -95
  34. data/lib/lock_jar/runtime.rb +359 -355
  35. data/lib/lock_jar/version.rb +3 -3
  36. data/lib/lock_jar.rb +172 -177
  37. data/lock_jar.gemspec +27 -27
  38. data/spec/fixtures/Jarfile +13 -13
  39. data/spec/fixtures/Jarfile2 +1 -0
  40. data/spec/lock_jar/class_loader_spec.rb +57 -57
  41. data/spec/lock_jar/cli_spec.rb +100 -100
  42. data/spec/lock_jar/domain/dsl_helper_spec.rb +52 -52
  43. data/spec/lock_jar/domain/dsl_spec.rb +57 -57
  44. data/spec/lock_jar/maven_spec.rb +23 -23
  45. data/spec/lock_jar/resolver_spec.rb +26 -26
  46. data/spec/lock_jar/runtime_spec.rb +26 -26
  47. data/spec/lock_jar_spec.rb +372 -295
  48. data/spec/pom.xml +34 -34
  49. data/spec/spec_helper.rb +38 -38
  50. data/spec/support/helper.rb +44 -44
  51. metadata +3 -1
@@ -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
@@ -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