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,188 +1,188 @@
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 'lock_jar/maven'
17
- require 'lock_jar/domain/dsl_helper'
18
- require 'lock_jar/domain/artifact'
19
-
20
- module LockJar
21
- module Domain
22
- class Dsl
23
-
24
- DEFAULT_GROUP = ['default']
25
-
26
- attr_accessor :artifacts, :remote_repositories, :local_repository, :groups,
27
- :maps, :excludes, :merged
28
-
29
- attr_reader :file_path
30
-
31
- class << self
32
-
33
- def create(jarfile = nil, &blk)
34
- builder = new
35
- evaluate(builder, jarfile, &blk)
36
- end
37
-
38
- def evaluate(builder, jarfile = nil, &blk)
39
- if jarfile.nil? && blk.nil?
40
- raise "jarfile or block must be set"
41
- end
42
-
43
- if jarfile
44
- builder.instance_eval(DslHelper.read_file(jarfile.to_s), jarfile.to_s, 1)
45
- end
46
-
47
- if blk
48
- builder.instance_eval(&blk)
49
- end
50
-
51
- builder
52
- end
53
-
54
- end
55
-
56
- def initialize
57
-
58
- @remote_repositories = []
59
- @artifacts = { 'default' => [] }
60
-
61
- @group_changed = false
62
-
63
- @present_group = 'default'
64
-
65
- @local_repository = nil
66
- @maps = {}
67
-
68
- @excludes = []
69
-
70
- @merged = []
71
- end
72
-
73
- def exclude(*notations)
74
- @excludes += notations
75
- end
76
-
77
- def jar(notation, *args)
78
- opts = {}
79
- if args.last.is_a? Hash
80
- opts.merge!( args.last )
81
- end
82
-
83
- artifact = Jar.new( notation )
84
-
85
- assign_groups( artifact, opts[:group] )
86
- end
87
-
88
- def local( *args )
89
- unless args.empty?
90
- if File.directory?( File.expand_path( args.first ) )
91
- warn "[DEPRECATION] `local` to set local_repository is deprecated. Please use `local_repo` instead."
92
- local_repo(args.first)
93
- else
94
- path = args.shift
95
-
96
- opts = {}
97
- if args.last.is_a? Hash
98
- opts.merge!( args.last )
99
- end
100
-
101
- artifact = Local.new( path )
102
-
103
- assign_groups( artifact, opts[:group] )
104
- end
105
- end
106
- end
107
-
108
- def local_repo( path )
109
- @local_repository = path
110
- end
111
-
112
- alias_method :name, :local_repository
113
-
114
- # Map a dependency to another dependency or local directory.
115
- def map( notation, *args )
116
- @maps[notation] = args
117
- end
118
-
119
- #
120
- def pom(path, *args)
121
- unless path =~ /\.xml$/i
122
- raise "#{path} is an invalid pom path"
123
- end
124
-
125
- opts = { :scopes => ['runtime', 'compile'] }
126
-
127
- if args.last.is_a? Hash
128
- opts.merge! args.last
129
- end
130
-
131
- artifact = Pom.new( path, opts[:scopes] )
132
-
133
- assign_groups( artifact, opts[:groups] )
134
- end
135
-
136
- def remote_repo( url, opts = {} )
137
- @remote_repositories << url
138
- end
139
- alias_method :remote_repository, :remote_repo
140
- alias_method :repository, :remote_repo
141
-
142
- def group(*groups, &blk)
143
- @group_changed = true
144
- groups.each do |group|
145
- @present_group = group.to_s
146
- yield
147
- end
148
- @group_changed = false
149
- @present_group = 'default'
150
- end
151
-
152
- # @deprecated Please use {#group} instead
153
- def scope(*scopes, &blk)
154
- warn "[DEPRECATION] `scope` is deprecated. Please use `group` instead."
155
- group(*scopes,&blk)
156
- end
157
-
158
- private
159
- def assign_groups(artifact, groups=nil)
160
-
161
- if groups
162
-
163
- unless groups.is_a? Array
164
- groups = [groups]
165
- end
166
-
167
- # include present group if within a group block
168
- if @group_changed
169
- groups << @present_group
170
- end
171
-
172
- else
173
- groups = [@present_group]
174
- end
175
-
176
- if artifact
177
- groups.uniq.each do |group|
178
- group_key = group.to_s
179
- @artifacts[group_key] = [] unless @artifacts[group_key]
180
- @artifacts[group_key] << artifact
181
- end
182
- end
183
-
184
- end
185
-
186
- end
187
- 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 'lock_jar/maven'
17
+ require 'lock_jar/domain/dsl_helper'
18
+ require 'lock_jar/domain/artifact'
19
+
20
+ module LockJar
21
+ module Domain
22
+ class Dsl
23
+
24
+ DEFAULT_GROUP = ['default']
25
+
26
+ attr_accessor :artifacts, :remote_repositories, :local_repository, :groups,
27
+ :maps, :excludes, :merged
28
+
29
+ attr_reader :file_path
30
+
31
+ class << self
32
+
33
+ def create(jarfile = nil, &blk)
34
+ builder = new
35
+ evaluate(builder, jarfile, &blk)
36
+ end
37
+
38
+ def evaluate(builder, jarfile = nil, &blk)
39
+ if jarfile.nil? && blk.nil?
40
+ raise "jarfile or block must be set"
41
+ end
42
+
43
+ if jarfile
44
+ builder.instance_eval(DslHelper.read_file(jarfile.to_s), jarfile.to_s, 1)
45
+ end
46
+
47
+ if blk
48
+ builder.instance_eval(&blk)
49
+ end
50
+
51
+ builder
52
+ end
53
+
54
+ end
55
+
56
+ def initialize
57
+
58
+ @remote_repositories = []
59
+ @artifacts = { 'default' => [] }
60
+
61
+ @group_changed = false
62
+
63
+ @present_group = 'default'
64
+
65
+ @local_repository = nil
66
+ @maps = {}
67
+
68
+ @excludes = []
69
+
70
+ @merged = []
71
+ end
72
+
73
+ def exclude(*notations)
74
+ @excludes += notations
75
+ end
76
+
77
+ def jar(notation, *args)
78
+ opts = {}
79
+ if args.last.is_a? Hash
80
+ opts.merge!( args.last )
81
+ end
82
+
83
+ artifact = Jar.new( notation )
84
+
85
+ assign_groups( artifact, opts[:group] )
86
+ end
87
+
88
+ def local( *args )
89
+ unless args.empty?
90
+ if File.directory?( File.expand_path( args.first ) )
91
+ warn "[DEPRECATION] `local` to set local_repository is deprecated. Please use `local_repo` instead."
92
+ local_repo(args.first)
93
+ else
94
+ path = args.shift
95
+
96
+ opts = {}
97
+ if args.last.is_a? Hash
98
+ opts.merge!( args.last )
99
+ end
100
+
101
+ artifact = Local.new( path )
102
+
103
+ assign_groups( artifact, opts[:group] )
104
+ end
105
+ end
106
+ end
107
+
108
+ def local_repo( path )
109
+ @local_repository = path
110
+ end
111
+
112
+ alias_method :name, :local_repository
113
+
114
+ # Map a dependency to another dependency or local directory.
115
+ def map( notation, *args )
116
+ @maps[notation] = args
117
+ end
118
+
119
+ #
120
+ def pom(path, *args)
121
+ unless path =~ /\.xml$/i
122
+ raise "#{path} is an invalid pom path"
123
+ end
124
+
125
+ opts = { :scopes => ['runtime', 'compile'] }
126
+
127
+ if args.last.is_a? Hash
128
+ opts.merge! args.last
129
+ end
130
+
131
+ artifact = Pom.new( path, opts[:scopes] )
132
+
133
+ assign_groups( artifact, opts[:groups] )
134
+ end
135
+
136
+ def remote_repo( url, opts = {} )
137
+ @remote_repositories << url
138
+ end
139
+ alias_method :remote_repository, :remote_repo
140
+ alias_method :repository, :remote_repo
141
+
142
+ def group(*groups, &blk)
143
+ @group_changed = true
144
+ groups.each do |group|
145
+ @present_group = group.to_s
146
+ yield
147
+ end
148
+ @group_changed = false
149
+ @present_group = 'default'
150
+ end
151
+
152
+ # @deprecated Please use {#group} instead
153
+ def scope(*scopes, &blk)
154
+ warn "[DEPRECATION] `scope` is deprecated. Please use `group` instead."
155
+ group(*scopes,&blk)
156
+ end
157
+
158
+ private
159
+ def assign_groups(artifact, groups=nil)
160
+
161
+ if groups
162
+
163
+ unless groups.is_a? Array
164
+ groups = [groups]
165
+ end
166
+
167
+ # include present group if within a group block
168
+ if @group_changed
169
+ groups << @present_group
170
+ end
171
+
172
+ else
173
+ groups = [@present_group]
174
+ end
175
+
176
+ if artifact
177
+ groups.uniq.each do |group|
178
+ group_key = group.to_s
179
+ @artifacts[group_key] = [] unless @artifacts[group_key]
180
+ @artifacts[group_key] << artifact
181
+ end
182
+ end
183
+
184
+ end
185
+
186
+ end
187
+ end
188
188
  end
@@ -1,84 +1,84 @@
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
- module LockJar
17
- module Domain
18
- class DslHelper
19
-
20
- class << self
21
-
22
- #
23
- # Merge LockJar::Domain::Dsl
24
- # @param [LockJar::Domain::Dsl] into_dsl dsl that is merged into
25
- # @param [LockJar::Domain::Dsl] from_dsl dsl that is merged from
26
- # @param [String] into_group force only runtime and default groups to be loaded into this group
27
- # @return [LockJar::Domain::Dsl]
28
- def merge( into_dsl, from_dsl, into_group = nil )
29
- into_dsl.remote_repositories = (into_dsl.remote_repositories + from_dsl.remote_repositories).uniq
30
-
31
- # merge default and runtime group into specific group
32
- if into_group
33
- group_artifacts = into_dsl.artifacts[into_group] || []
34
- defaults = from_dsl.artifacts['default'] || []
35
- runtime = from_dsl.artifacts['runtime'] || []
36
- ( defaults + runtime ).each do |art|
37
- unless group_artifacts.include? art
38
- group_artifacts << art
39
- end
40
- end
41
- into_dsl.artifacts[into_group] = group_artifacts
42
-
43
- # one to one merging of groups
44
- else
45
- from_dsl.artifacts.each do |group, artifacts|
46
- group_artifacts = into_dsl.artifacts[group] || []
47
- artifacts.each do |art|
48
- unless group_artifacts.include? art
49
- group_artifacts << art
50
- end
51
- end
52
- into_dsl.artifacts[group] = group_artifacts
53
- end
54
- end
55
-
56
- from_dsl.maps.each do |artifact,paths|
57
- existing_map = into_dsl.maps[artifact]
58
- if existing_map
59
- into_dsl.maps[artifact] = (existing_map + paths).uniq
60
- else
61
- into_dsl.maps[artifact] = paths
62
- end
63
- end
64
-
65
- from_dsl.excludes.each do |exclude|
66
- unless into_dsl.include? exclude
67
- into_dsl.excludes << exclude
68
- end
69
- end
70
-
71
- if from_dsl.file_path
72
- into_dsl.merged << from_dsl.file_path
73
- end
74
-
75
- into_dsl
76
- end
77
-
78
- def read_file(file)
79
- File.open(file, "rb") { |f| f.read }
80
- end
81
- end
82
- end
83
- 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
+ module LockJar
17
+ module Domain
18
+ class DslHelper
19
+
20
+ class << self
21
+
22
+ #
23
+ # Merge LockJar::Domain::Dsl
24
+ # @param [LockJar::Domain::Dsl] into_dsl dsl that is merged into
25
+ # @param [LockJar::Domain::Dsl] from_dsl dsl that is merged from
26
+ # @param [String] into_group force only runtime and default groups to be loaded into this group
27
+ # @return [LockJar::Domain::Dsl]
28
+ def merge( into_dsl, from_dsl, into_group = nil )
29
+ into_dsl.remote_repositories = (into_dsl.remote_repositories + from_dsl.remote_repositories).uniq
30
+
31
+ # merge default and runtime group into specific group
32
+ if into_group
33
+ group_artifacts = into_dsl.artifacts[into_group] || []
34
+ defaults = from_dsl.artifacts['default'] || []
35
+ runtime = from_dsl.artifacts['runtime'] || []
36
+ ( defaults + runtime ).each do |art|
37
+ unless group_artifacts.include? art
38
+ group_artifacts << art
39
+ end
40
+ end
41
+ into_dsl.artifacts[into_group] = group_artifacts
42
+
43
+ # one to one merging of groups
44
+ else
45
+ from_dsl.artifacts.each do |group, artifacts|
46
+ group_artifacts = into_dsl.artifacts[group] || []
47
+ artifacts.each do |art|
48
+ unless group_artifacts.include? art
49
+ group_artifacts << art
50
+ end
51
+ end
52
+ into_dsl.artifacts[group] = group_artifacts
53
+ end
54
+ end
55
+
56
+ from_dsl.maps.each do |artifact,paths|
57
+ existing_map = into_dsl.maps[artifact]
58
+ if existing_map
59
+ into_dsl.maps[artifact] = (existing_map + paths).uniq
60
+ else
61
+ into_dsl.maps[artifact] = paths
62
+ end
63
+ end
64
+
65
+ from_dsl.excludes.each do |exclude|
66
+ unless into_dsl.include? exclude
67
+ into_dsl.excludes << exclude
68
+ end
69
+ end
70
+
71
+ if from_dsl.file_path
72
+ into_dsl.merged << from_dsl.file_path
73
+ end
74
+
75
+ into_dsl
76
+ end
77
+
78
+ def read_file(file)
79
+ File.open(file, "rb") { |f| f.read }
80
+ end
81
+ end
82
+ end
83
+ end
84
84
  end
@@ -1,45 +1,45 @@
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 'lock_jar/maven'
17
- require 'lock_jar/domain/jarfile_dsl'
18
- require 'lock_jar/domain/dsl_helper'
19
-
20
- module LockJar
21
- module Domain
22
- class GemDsl < JarfileDsl
23
-
24
- attr_accessor :gem_dir
25
-
26
- class << self
27
- alias :overriden_create :create
28
- def create(spec, jarfile)
29
- builder = new
30
- builder.gem_dir = spec.gem_dir
31
-
32
- jarfile = File.join( spec.gem_dir, jarfile )
33
- builder.file_path = "gem:#{spec.name}:#{jarfile.gsub( "#{spec.base_dir}/", "" )}.lock"
34
-
35
- evaluate(builder, jarfile)
36
- end
37
- end
38
-
39
- alias :overriden_pom :pom
40
- def pom(path, *args)
41
- overriden_pom( File.join( gem_dir, path), *args)
42
- end
43
- end
44
- 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 'lock_jar/maven'
17
+ require 'lock_jar/domain/jarfile_dsl'
18
+ require 'lock_jar/domain/dsl_helper'
19
+
20
+ module LockJar
21
+ module Domain
22
+ class GemDsl < JarfileDsl
23
+
24
+ attr_accessor :gem_dir
25
+
26
+ class << self
27
+ alias :overriden_create :create
28
+ def create(spec, jarfile)
29
+ builder = new
30
+ builder.gem_dir = spec.gem_dir
31
+
32
+ jarfile = File.join( spec.gem_dir, jarfile )
33
+ builder.file_path = "gem:#{spec.name}:#{jarfile.gsub( "#{spec.base_dir}/", "" )}.lock"
34
+
35
+ evaluate(builder, jarfile)
36
+ end
37
+ end
38
+
39
+ alias :overriden_pom :pom
40
+ def pom(path, *args)
41
+ overriden_pom( File.join( gem_dir, path), *args)
42
+ end
43
+ end
44
+ end
45
45
  end