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.
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,47 +1,47 @@
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
-
19
- module LockJar
20
- module Domain
21
- class JarfileDsl < Dsl
22
-
23
- attr_accessor :file_path, :bundler_enabled
24
-
25
- class << self
26
- alias :overriden_create :create
27
- def create(jarfile)
28
- builder = new
29
- builder.file_path = jarfile
30
-
31
- evaluate(builder, jarfile)
32
- end
33
- end
34
-
35
- def bundler(*groups)
36
- if groups.nil?
37
- groups = [:default]
38
- else
39
- groups = groups.map(&:to_sym)
40
- end
41
-
42
- @bundler_enabled = groups
43
- end
44
-
45
- end
46
- 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
+
19
+ module LockJar
20
+ module Domain
21
+ class JarfileDsl < Dsl
22
+
23
+ attr_accessor :file_path, :bundler_enabled
24
+
25
+ class << self
26
+ alias :overriden_create :create
27
+ def create(jarfile)
28
+ builder = new
29
+ builder.file_path = jarfile
30
+
31
+ evaluate(builder, jarfile)
32
+ end
33
+ end
34
+
35
+ def bundler(*groups)
36
+ if groups.nil?
37
+ groups = [:default]
38
+ else
39
+ groups = groups.map(&:to_sym)
40
+ end
41
+
42
+ @bundler_enabled = groups
43
+ end
44
+
45
+ end
46
+ end
47
47
  end
@@ -1,114 +1,114 @@
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 "yaml"
17
- require 'lock_jar/version'
18
-
19
- module LockJar
20
- module Domain
21
- class Lockfile
22
-
23
- attr_accessor :local_repository, :maps, :excludes, :remote_repositories,
24
- :version, :groups, :gems, :merged
25
- attr_reader :force_utf8
26
-
27
-
28
- def self.read( path )
29
- lockfile = Lockfile.new
30
-
31
- lock_data = YAML.load_file( path )
32
-
33
- lockfile.version = lock_data['version'] || LockJar::VERSION
34
- lockfile.merged = lock_data['merged']
35
- lockfile.local_repository = lock_data['local_repository']
36
- lockfile.merged = lock_data['merged'] || []
37
- lockfile.maps = lock_data['maps'] || []
38
- lockfile.excludes = lock_data['excludes'] || []
39
- lockfile.groups = lock_data['groups'] || lock_data['scopes'] || {}
40
- lockfile.remote_repositories = lock_data['remote_repositories'] || lock_data['repositories'] || []
41
- lockfile.gems = lock_data['gems'] || []
42
- lockfile
43
- end
44
-
45
- def initialize
46
- @force_utf8 ||= RUBY_VERSION =~ /^1.9/
47
- @groups = { 'default' => {} }
48
- @maps = []
49
- @excludes = []
50
- @remote_repositories = []
51
- @gems = []
52
- @merged = []
53
-
54
- @version = LockJar::VERSION # default version
55
- end
56
-
57
- def to_hash
58
- lock_data = { 'version' => @version }
59
-
60
- unless local_repository.nil?
61
- lock_data['local_repository'] = local_repository
62
-
63
- if @force_utf8
64
- lock_data['local_repository'] = lock_data['local_repository'].force_encoding("UTF-8")
65
- end
66
- end
67
-
68
- unless merged.empty?
69
- lock_data['merged'] = merged
70
- end
71
-
72
- if maps.size > 0
73
- lock_data['maps'] = maps
74
- end
75
-
76
- if excludes.size > 0
77
- lock_data['excludes'] = excludes
78
-
79
- if @force_utf8
80
- lock_data['excludes'].map! { |exclude| exclude.force_encoding("UTF-8") }
81
- end
82
- end
83
-
84
- unless gems.empty?
85
- lock_data['gems'] = gems
86
- end
87
-
88
- lock_data['groups'] = groups
89
-
90
- #if @force_utf8
91
- # lock_data['groups'].each do |group, group_notations|
92
- # group_notations.map! { |notation| notation.force_encoding("UTF-8") }
93
- # end
94
- #end
95
-
96
- if remote_repositories.size > 0
97
- lock_data['remote_repositories'] = remote_repositories
98
- end
99
-
100
- lock_data
101
- end
102
-
103
- def to_yaml
104
- to_hash.to_yaml
105
- end
106
-
107
- def write( path )
108
- File.open( path, "w") do |f|
109
- f.write( to_yaml )
110
- end
111
- end
112
- end
113
- 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 "yaml"
17
+ require 'lock_jar/version'
18
+
19
+ module LockJar
20
+ module Domain
21
+ class Lockfile
22
+
23
+ attr_accessor :local_repository, :maps, :excludes, :remote_repositories,
24
+ :version, :groups, :gems, :merged
25
+ attr_reader :force_utf8
26
+
27
+
28
+ def self.read( path )
29
+ lockfile = Lockfile.new
30
+
31
+ lock_data = YAML.load_file( path )
32
+
33
+ lockfile.version = lock_data['version'] || LockJar::VERSION
34
+ lockfile.merged = lock_data['merged']
35
+ lockfile.local_repository = lock_data['local_repository']
36
+ lockfile.merged = lock_data['merged'] || []
37
+ lockfile.maps = lock_data['maps'] || []
38
+ lockfile.excludes = lock_data['excludes'] || []
39
+ lockfile.groups = lock_data['groups'] || lock_data['scopes'] || {}
40
+ lockfile.remote_repositories = lock_data['remote_repositories'] || lock_data['repositories'] || []
41
+ lockfile.gems = lock_data['gems'] || []
42
+ lockfile
43
+ end
44
+
45
+ def initialize
46
+ @force_utf8 ||= RUBY_VERSION =~ /^1.9/
47
+ @groups = { 'default' => {} }
48
+ @maps = []
49
+ @excludes = []
50
+ @remote_repositories = []
51
+ @gems = []
52
+ @merged = []
53
+
54
+ @version = LockJar::VERSION # default version
55
+ end
56
+
57
+ def to_hash
58
+ lock_data = { 'version' => @version }
59
+
60
+ unless local_repository.nil?
61
+ lock_data['local_repository'] = local_repository
62
+
63
+ if @force_utf8
64
+ lock_data['local_repository'] = lock_data['local_repository'].force_encoding("UTF-8")
65
+ end
66
+ end
67
+
68
+ unless merged.empty?
69
+ lock_data['merged'] = merged
70
+ end
71
+
72
+ if maps.size > 0
73
+ lock_data['maps'] = maps
74
+ end
75
+
76
+ if excludes.size > 0
77
+ lock_data['excludes'] = excludes
78
+
79
+ if @force_utf8
80
+ lock_data['excludes'].map! { |exclude| exclude.force_encoding("UTF-8") }
81
+ end
82
+ end
83
+
84
+ unless gems.empty?
85
+ lock_data['gems'] = gems
86
+ end
87
+
88
+ lock_data['groups'] = groups
89
+
90
+ #if @force_utf8
91
+ # lock_data['groups'].each do |group, group_notations|
92
+ # group_notations.map! { |notation| notation.force_encoding("UTF-8") }
93
+ # end
94
+ #end
95
+
96
+ if remote_repositories.size > 0
97
+ lock_data['remote_repositories'] = remote_repositories
98
+ end
99
+
100
+ lock_data
101
+ end
102
+
103
+ def to_yaml
104
+ to_hash.to_yaml
105
+ end
106
+
107
+ def write( path )
108
+ File.open( path, "w") do |f|
109
+ f.write( to_yaml )
110
+ end
111
+ end
112
+ end
113
+ end
114
114
  end
@@ -1,112 +1,112 @@
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 'naether/maven'
17
-
18
- module LockJar
19
-
20
- # Helper for providing Maven specific operations
21
- #
22
- # @author Michael Guymon
23
- #
24
- class Maven
25
-
26
- class << self
27
-
28
- #
29
- # Get the version of a POM
30
- #
31
- # @param [String] pom_path path to the pom
32
- #
33
- # @return [String] version of POM
34
- #
35
- def pom_version( pom_path )
36
- maven = Naether::Maven.create_from_pom( pom_path )
37
- maven.version()
38
- end
39
-
40
- #
41
- # Get dependencies of a Pom
42
- #
43
- # @param [String] pom_path path to the pom
44
- # @param [Array] scopes
45
- #
46
- # @return [String] version of POM
47
- #
48
- def dependencies( pom_path, scopes = ['compile', 'runtime'] )
49
- maven = Naether::Maven.create_from_pom( pom_path )
50
- maven.dependencies(scopes)
51
- end
52
-
53
- #
54
- # Write a POM from list of notations
55
- #
56
- # @param [String] pom notation
57
- # @param [String] file_path path of new pom
58
- # @param [Hash] opts
59
- # @option opts [Boolean] :include_resolved to add dependencies of resolve dependencies from Jarfile.lock. Default is true.
60
- # @option opts [Array] :dependencies Array of of mixed dependencies:
61
- # * [String] Artifact notation, such as groupId:artifactId:version, e.g. 'junit:junit:4.7'
62
- # * [Hash] of a single artifaction notation => scope - { 'junit:junit:4.7' => 'test' }
63
- #
64
- def write_pom( notation, file_path, opts = {} )
65
- opts = {:include_resolved => true}.merge( opts )
66
-
67
- maven = Naether::Maven.create_from_notataion( notation )
68
-
69
- if opts[:include_resolved]
70
- # Passes in nil to the resolver to get the cache
71
- maven.load_naether( Runtime.instance.resolver.naether )
72
- end
73
-
74
- if opts[:dependencies]
75
- opts[:dependencies].each do |dep|
76
- if dep.is_a? Array
77
- maven.add_dependency(dep[0], dep[1])
78
- else
79
- maven.add_dependency(dep)
80
- end
81
- end
82
- end
83
- maven.write_pom( file_path )
84
- end
85
-
86
- #
87
- # Deploy an artifact to a Maven repository
88
- #
89
- # @param [String] notation of artifact
90
- # @param [String] file_path path to the Jar
91
- # @param [String] url Maven repository deploying to
92
- # @param [Hash] deploy_opts options for deploying
93
- # @param [Hash] lockjar_opts options for initializing LockJar
94
- #
95
- def deploy_artifact( notation, file_path, url, deploy_opts = {}, lockjar_opts = {} )
96
- Runtime.instance.resolver(lockjar_opts).naether.deploy_artifact( notation, file_path, url, deploy_opts )
97
- end
98
-
99
- #
100
- # Install an artifact to a local repository
101
- #
102
- # @param [String] notation of artifact
103
- # @param [String] pom_path path to the pom
104
- # @param [String] jar_path path to the jar
105
- # @param [Hash] opts options
106
- #
107
- def install( notation, pom_path, jar_path, opts = {} )
108
- Runtime.instance.resolver(opts).naether.install( notation, pom_path, jar_path )
109
- end
110
- end
111
- 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 'naether/maven'
17
+
18
+ module LockJar
19
+
20
+ # Helper for providing Maven specific operations
21
+ #
22
+ # @author Michael Guymon
23
+ #
24
+ class Maven
25
+
26
+ class << self
27
+
28
+ #
29
+ # Get the version of a POM
30
+ #
31
+ # @param [String] pom_path path to the pom
32
+ #
33
+ # @return [String] version of POM
34
+ #
35
+ def pom_version( pom_path )
36
+ maven = Naether::Maven.create_from_pom( pom_path )
37
+ maven.version()
38
+ end
39
+
40
+ #
41
+ # Get dependencies of a Pom
42
+ #
43
+ # @param [String] pom_path path to the pom
44
+ # @param [Array] scopes
45
+ #
46
+ # @return [String] version of POM
47
+ #
48
+ def dependencies( pom_path, scopes = ['compile', 'runtime'] )
49
+ maven = Naether::Maven.create_from_pom( pom_path )
50
+ maven.dependencies(scopes)
51
+ end
52
+
53
+ #
54
+ # Write a POM from list of notations
55
+ #
56
+ # @param [String] pom notation
57
+ # @param [String] file_path path of new pom
58
+ # @param [Hash] opts
59
+ # @option opts [Boolean] :include_resolved to add dependencies of resolve dependencies from Jarfile.lock. Default is true.
60
+ # @option opts [Array] :dependencies Array of of mixed dependencies:
61
+ # * [String] Artifact notation, such as groupId:artifactId:version, e.g. 'junit:junit:4.7'
62
+ # * [Hash] of a single artifaction notation => scope - { 'junit:junit:4.7' => 'test' }
63
+ #
64
+ def write_pom( notation, file_path, opts = {} )
65
+ opts = {:include_resolved => true}.merge( opts )
66
+
67
+ maven = Naether::Maven.create_from_notataion( notation )
68
+
69
+ if opts[:include_resolved]
70
+ # Passes in nil to the resolver to get the cache
71
+ maven.load_naether( Runtime.instance.resolver.naether )
72
+ end
73
+
74
+ if opts[:dependencies]
75
+ opts[:dependencies].each do |dep|
76
+ if dep.is_a? Array
77
+ maven.add_dependency(dep[0], dep[1])
78
+ else
79
+ maven.add_dependency(dep)
80
+ end
81
+ end
82
+ end
83
+ maven.write_pom( file_path )
84
+ end
85
+
86
+ #
87
+ # Deploy an artifact to a Maven repository
88
+ #
89
+ # @param [String] notation of artifact
90
+ # @param [String] file_path path to the Jar
91
+ # @param [String] url Maven repository deploying to
92
+ # @param [Hash] deploy_opts options for deploying
93
+ # @param [Hash] lockjar_opts options for initializing LockJar
94
+ #
95
+ def deploy_artifact( notation, file_path, url, deploy_opts = {}, lockjar_opts = {} )
96
+ Runtime.instance.resolver(lockjar_opts).naether.deploy_artifact( notation, file_path, url, deploy_opts )
97
+ end
98
+
99
+ #
100
+ # Install an artifact to a local repository
101
+ #
102
+ # @param [String] notation of artifact
103
+ # @param [String] pom_path path to the pom
104
+ # @param [String] jar_path path to the jar
105
+ # @param [Hash] opts options
106
+ #
107
+ def install( notation, pom_path, jar_path, opts = {} )
108
+ Runtime.instance.resolver(opts).naether.install( notation, pom_path, jar_path )
109
+ end
110
+ end
111
+ end
112
112
  end