lock_jar 0.14.5 → 0.14.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfc96065e3e9627fc0db3267dfc96c2749c13bab
4
- data.tar.gz: 405653c6f9961b07ce3009cf0c04cf9a0834da68
3
+ metadata.gz: bb1062ded1e751410d49d6b1b81666008048d662
4
+ data.tar.gz: 1b3ed787d557da58076dba1d60f5a4d0ecee3b64
5
5
  SHA512:
6
- metadata.gz: 0841da259510056f369cda445a9aea607f1a85b0ffb2ab84fb283eb5a308393589c4138a7e2eca6502905020e3210e61fd67c902ab46aed6fe68b93efc708e79
7
- data.tar.gz: 44c737e6d62349948a2ac1839d6199d66c1b0abaea839b5bf2df32a23e20ed266b0b8109272db0aa18313a799ed127759342ff64123cd31bdcb793ca6c9c1510
6
+ metadata.gz: 6041663c5fcdc7673e30286f3cdc624b25075592ff5c6befa30c998b5b6188dc442c14d3dd96ce5490a69c80a70d9fc229706b588d301d1533ba48d2f3ce8435
7
+ data.tar.gz: c247a4d5d5bac9fe488223c5b6943957f04f0186ea79d13f7f5291b235e47c315edc5b128a2ef6faf4bb8c549101518019e62ffa4c243a3c49024a0807d96a7e
data/.rubocop.yml CHANGED
@@ -26,3 +26,6 @@ Style/PredicateName:
26
26
 
27
27
  Style/Lambda:
28
28
  Enabled: false
29
+
30
+ Style/Alias:
31
+ Enabled: false
data/Gemfile CHANGED
@@ -12,5 +12,5 @@ group :development do
12
12
  gem 'guard-rspec', require: false
13
13
  gem 'pry'
14
14
  gem 'yard'
15
- gem 'rubocop'
15
+ gem 'rubocop', '~> 0.36.0'
16
16
  end
data/README.md CHANGED
@@ -51,7 +51,7 @@ methods:
51
51
  end
52
52
 
53
53
  group 'test' do
54
- jar 'junit:junit:jar:4.10', :group => 'test'
54
+ jar 'junit:junit:jar:4.12', :group => 'test'
55
55
  end
56
56
 
57
57
  ### Resolving dependencies
@@ -90,7 +90,7 @@ The _Jarfile.lock_ generated is a YAML file containing information on how to han
90
90
  - ch.qos.logback:logback-classic:jar:0.9.24
91
91
  - ch.qos.logback:logback-core:jar:0.9.24
92
92
  - com.metapossum:metapossum-scanner:jar:1.0
93
- - com.slackworks:modelcitizen:jar:0.2.2
93
+ - com.tobedevoured.modelcitizen:core:jar:0.8.1
94
94
  - commons-beanutils:commons-beanutils:jar:1.8.3
95
95
  - commons-io:commons-io:jar:1.4
96
96
  - commons-lang:commons-lang:jar:2.6
@@ -123,10 +123,10 @@ The _Jarfile.lock_ generated is a YAML file containing information on how to han
123
123
  transitive: {}
124
124
  test:
125
125
  dependencies:
126
- - junit:junit:jar:4.10
126
+ - junit:junit:jar:4.12
127
127
  - org.hamcrest:hamcrest-core:jar:1.1
128
128
  artifacts:
129
- - jar:junit:junit:jar:4.10:
129
+ - jar:junit:junit:jar:4.12:
130
130
  transitive:
131
131
  org.hamcrest:hamcrest-core:jar:1.1: {}
132
132
  ...
@@ -146,7 +146,7 @@ The _Jarfile.lock_ generated is a YAML file containing information on how to han
146
146
  * _[Hash]_ will set the options, e.g. `{ :local_repo => 'path' }`
147
147
  * **:local_repo** _[String]_ sets the local repo path. Defaults to `ENV['M2_REPO']` or `'~/.m2/repository'`
148
148
  * **:local_paths** _[Boolean]_ converts the notations to paths of jars in the local repo
149
- * **:resolve** _[Boolean]_ to true will make transitive dependences resolve before returning list of jars
149
+ * **:resolve** _[Boolean]_ to `true` will make transitive dependences resolve before returning list of jars. Setting to `false` will list dependencies, excluding transitive dependencies.
150
150
 
151
151
  **LockJar.load(*args)**: Loads all dependencies to the classpath for groups from the Jarfile.lock. Default group is _default_. Default lock file is _Jarfile.lock_.
152
152
  * _[String]_ will set the Jarfile.lock, e.g. `'Better.lock'`
@@ -301,7 +301,7 @@ Sample buildfile with LockJar
301
301
  lock_jar do
302
302
 
303
303
  group 'test' do
304
- jar 'junit:junit:jar:4.10'
304
+ jar 'junit:junit:jar:4.12'
305
305
  end
306
306
  end
307
307
 
@@ -329,13 +329,15 @@ Generated the following lock files using **lock_jar:lock**
329
329
  ## Bundler Integration
330
330
 
331
331
  [LockJar patches Bundler](https://github.com/mguymon/lock_jar/blob/master/lib/lock_jar/bundler.rb)
332
- to allow creation of a _Jarfile.lock_ when Bundler calls `install` and `update`. The dependencies from the _Jarfile.lock_ are automatically loaded when
333
- Bundler calls `setup` and `require`. To enable this support, add this require to your _Gemfile_
332
+ to allow creation of a _Jarfile.lock_ when Bundler calls `install` and `update`. To enable this support, add this exit callback your _Gemfile_
334
333
 
335
- require 'lock_jar/bundler'
334
+ @@check ||= at_exit do
335
+ require 'lock_jar/bundler'
336
+ LockJar::Bundler.lock!(::Bundler)
337
+ end
336
338
 
337
339
  You can optionally create a _Jarfile_ that will automatically be included when you `bundle install` or `bundle update`. Otherwise
338
- Gems with a Jarfile will be merge to generate a _Jarfile.lock_. The Jarfile.lock will be loaded when Bundler calls `setup` or `require`.
340
+ Gems with a Jarfile will be merge to generate a _Jarfile.lock_.
339
341
 
340
342
  ### Bundler to LockJar groups
341
343
 
data/lib/lock_jar.rb CHANGED
@@ -168,37 +168,35 @@ module LockJar
168
168
  args = args.reject { |arg| arg.is_a? String }
169
169
  lock(combined, *args, &blk)
170
170
  end
171
- end
172
-
173
- private
174
171
 
175
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
176
- def self.extract_args(type, args, &blk)
177
- lockfile_or_path = nil
178
- opts = {}
179
- groups = ['default']
180
- args.each do |arg|
181
- case arg
182
- when Hash
183
- opts.merge!(arg)
184
- when String
185
- lockfile_or_path = arg
186
- when LockJar::Domain::Lockfile
187
- lockfile_or_path = arg if type == :lockfile
188
- when LockJar::Domain::Dsl
189
- lockfile_or_path = arg if type == :jarfile
190
- when Array
191
- groups = arg
172
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
173
+ def extract_args(type, args, &blk)
174
+ lockfile_or_path = nil
175
+ opts = {}
176
+ groups = ['default']
177
+ args.each do |arg|
178
+ case arg
179
+ when Hash
180
+ opts.merge!(arg)
181
+ when String
182
+ lockfile_or_path = arg
183
+ when LockJar::Domain::Lockfile
184
+ lockfile_or_path = arg if type == :lockfile
185
+ when LockJar::Domain::Dsl
186
+ lockfile_or_path = arg if type == :jarfile
187
+ when Array
188
+ groups = arg
189
+ end
192
190
  end
193
- end
194
- if blk.nil? && lockfile_or_path.nil?
195
- if type == :lockfile
196
- lockfile_or_path = opts.fetch(:lockfile, 'Jarfile.lock')
197
- elsif type == :jarfile
198
- lockfile_or_path = 'Jarfile'
191
+ if blk.nil? && lockfile_or_path.nil?
192
+ if type == :lockfile
193
+ lockfile_or_path = opts.fetch(:lockfile, 'Jarfile.lock')
194
+ elsif type == :jarfile
195
+ lockfile_or_path = 'Jarfile'
196
+ end
199
197
  end
198
+ [lockfile_or_path, groups, opts]
200
199
  end
201
- [lockfile_or_path, groups, opts]
200
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
202
201
  end
203
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
204
202
  end
@@ -22,7 +22,7 @@ module Buildr
22
22
 
23
23
  class << self
24
24
  def project_to_lockfile(project)
25
- "#{project.name.gsub(/:/, '-')}.lock"
25
+ "#{project.name.tr(':', '-')}.lock"
26
26
  end
27
27
  end
28
28
 
@@ -23,13 +23,13 @@ module LockJar
23
23
  jarfile = File.expand_path(jarfile_opt || 'Jarfile')
24
24
 
25
25
  # load local Jarfile
26
- if File.exist?(jarfile)
27
- dsl = LockJar::Domain::JarfileDsl.create(jarfile)
26
+ dsl = if File.exist?(jarfile)
27
+ LockJar::Domain::JarfileDsl.create(jarfile)
28
28
 
29
- # Create new Dsl
30
- else
31
- dsl = LockJar::Domain::Dsl.new
32
- end
29
+ # Create new Dsl
30
+ else
31
+ LockJar::Domain::Dsl.new
32
+ end
33
33
 
34
34
  gems_with_jars = []
35
35
  ::Bundler.definition.groups.each do |group|
@@ -25,11 +25,9 @@ module LockJar
25
25
  attr_reader :type
26
26
 
27
27
  def <=>(other)
28
- if other.is_a? Artifact
29
- to_urn <=> other.to_urn
30
- else
31
- to_urn <=> other.to_s
32
- end
28
+ return to_urn <=> other.to_urn if other.is_a? Artifact
29
+
30
+ to_urn <=> other.to_s
33
31
  end
34
32
 
35
33
  def resolvable?
@@ -104,11 +102,9 @@ module LockJar
104
102
 
105
103
  def <=>(other)
106
104
  if other.is_a? Pom
107
- if to_urn == other.to_urn
108
- return Set.new(scopes) <=> Set.new(other.scopes)
109
- else
110
- to_urn <=> other.to_urn
111
- end
105
+ return Set.new(scopes) <=> Set.new(other.scopes) if to_urn == other.to_urn
106
+
107
+ to_urn <=> other.to_urn
112
108
  else
113
109
  super
114
110
  end
@@ -21,7 +21,7 @@ module LockJar
21
21
  module Domain
22
22
  #
23
23
  class Dsl
24
- DEFAULT_GROUP = ['default']
24
+ DEFAULT_GROUP = ['default'].freeze
25
25
 
26
26
  attr_accessor :artifacts, :remote_repositories, :local_repository, :groups,
27
27
  :maps, :excludes, :merged, :clear_repositories
@@ -76,7 +76,7 @@ module LockJar
76
76
 
77
77
  groups.each do |group|
78
78
  next unless lockfile.groups[group.to_s]
79
- dependencies += lockfile.groups[group.to_s]['dependencies']
79
+ dependencies += yield lockfile.groups[group.to_s]
80
80
 
81
81
  if with_locals
82
82
  locals = lockfile.groups[group.to_s]['locals']
@@ -10,13 +10,8 @@ module LockJar
10
10
  with_locals = { with_locals: true }.merge(opts).delete(:with_locals)
11
11
 
12
12
  if lockfile_or_path
13
- if lockfile_or_path.is_a? LockJar::Domain::Lockfile
14
- lockfile = lockfile_or_path
15
- elsif lockfile_or_path
16
- lockfile = LockJar::Domain::Lockfile.read(lockfile_or_path)
17
- end
18
-
19
- dependencies = lockfile_dependencies(lockfile, groups, with_locals)
13
+ lockfile = build_lockfile(lockfile_or_path)
14
+ dependencies = dependencies_from_lockfile(lockfile, groups, with_locals, opts)
20
15
  maps = lockfile.maps
21
16
  end
22
17
 
@@ -41,15 +36,42 @@ module LockJar
41
36
 
42
37
  dependencies = resolver(opts).resolve(dependencies) if opts[:resolve]
43
38
 
44
- if opts[:local_paths]
45
- opts.delete(:local_paths) # remove list opts so resolver is not reset
46
- resolver(opts).to_local_paths(dependencies)
39
+ # local_paths and !resolve are mutualally exclusive
40
+ if opts[:local_paths] && opts[:resolve] != false
41
+ # remove local_paths opt so resolver is not reset
42
+ resolver(opts.reject { |k| k == :local_paths }).to_local_paths(dependencies)
47
43
 
48
44
  else
49
45
  dependencies
50
46
  end
51
47
  end
52
48
  # rubocop:enable Metrics/PerceivedComplexity, MethodLength
49
+
50
+ def build_lockfile(lockfile_or_path)
51
+ if lockfile_or_path.is_a? LockJar::Domain::Lockfile
52
+ lockfile_or_path
53
+ elsif lockfile_or_path
54
+ LockJar::Domain::Lockfile.read(lockfile_or_path)
55
+ end
56
+ end
57
+
58
+ def dependencies_from_lockfile(lockfile, groups, with_locals, opts)
59
+ # Only list root dependencies
60
+ if opts[:resolve] == false
61
+ lockfile_dependencies(lockfile, groups, with_locals) do |group|
62
+ group['artifacts'].flat_map(&:keys).map do |notation|
63
+ # remove the prefix from artifacts, such as jar: or pom:
64
+ notation.gsub(/^.+?:/, '')
65
+ end
66
+ end
67
+
68
+ # List all dependencies
69
+ else
70
+ lockfile_dependencies(lockfile, groups, with_locals) do |group|
71
+ group['dependencies']
72
+ end
73
+ end
74
+ end
53
75
  end
54
76
  end
55
77
  end
@@ -17,12 +17,11 @@ module LockJar
17
17
  if lockfile_or_path.is_a? LockJar::Domain::Lockfile
18
18
  lockfile = lockfile_or_path
19
19
 
20
- # check if lockfile path is already loaded
21
- elsif LockJar::Registry.instance.lockfile_registered?(lockfile_or_path)
22
- return
23
-
24
- # convert lockfile path to a Lockfile instance
25
20
  else
21
+ # check if lockfile path is already loaded
22
+ return if LockJar::Registry.instance.lockfile_registered?(lockfile_or_path)
23
+
24
+ # convert lockfile path to a Lockfile instance
26
25
  lockfile = LockJar::Domain::Lockfile.read(lockfile_or_path)
27
26
  end
28
27
 
@@ -38,11 +38,11 @@ module LockJar
38
38
 
39
39
  def create_dsl!(jarfile_or_dsl, &blk)
40
40
  if jarfile_or_dsl
41
- if jarfile_or_dsl.is_a? LockJar::Domain::Dsl
42
- @jarfile = jarfile_or_dsl
43
- else
44
- @jarfile = LockJar::Domain::JarfileDsl.create(jarfile_or_dsl)
45
- end
41
+ @jarfile = if jarfile_or_dsl.is_a? LockJar::Domain::Dsl
42
+ jarfile_or_dsl
43
+ else
44
+ LockJar::Domain::JarfileDsl.create(jarfile_or_dsl)
45
+ end
46
46
  end
47
47
 
48
48
  return @jarfile if blk.nil?
@@ -132,7 +132,7 @@ module LockJar
132
132
  # iterate each dependency in Pom to map transitive dependencies
133
133
  transitive = {}
134
134
  artifact.notations.each do |notation|
135
- transitive.merge!(notation => resolver(opts).dependencies_graph[notation])
135
+ transitive[notation] = resolver(opts).dependencies_graph[notation]
136
136
  end
137
137
  artifact_data['transitive'] = transitive
138
138
 
@@ -1,4 +1,4 @@
1
1
  # the version
2
2
  module LockJar
3
- VERSION = '0.14.5'
3
+ VERSION = '0.14.6'.freeze
4
4
  end
@@ -4,11 +4,11 @@ repository 'http://mirrors.ibiblio.org/pub/mirrors/maven2'
4
4
  jar "org.apache.mina:mina-core:2.0.4"
5
5
  local "spec/fixtures/naether-0.13.0.jar"
6
6
  pom 'spec/pom.xml'
7
-
7
+
8
8
  group 'development' do
9
9
  jar 'com.typesafe:config:jar:0.5.0'
10
10
  end
11
11
 
12
12
  group 'test' do
13
- jar 'junit:junit:jar:4.10'
14
- end
13
+ jar 'org.testng:testng:jar:6.9.10'
14
+ end
@@ -15,7 +15,7 @@ describe LockJar::Domain::DslMerger do
15
15
  end
16
16
 
17
17
  group 'test' do
18
- jar 'junit:junit:jar:4.10'
18
+ jar 'org.testng:testng:jar:6.9.10'
19
19
  end
20
20
  end
21
21
 
@@ -39,11 +39,13 @@ describe LockJar::Domain::DslMerger do
39
39
 
40
40
  dsl = LockJar::Domain::DslMerger.new(block1, block2).merge
41
41
 
42
- expect(dsl.artifacts['default']).to eq([
43
- LockJar::Domain::Jar.new('org.apache.mina:mina-core:2.0.4'),
44
- LockJar::Domain::Pom.new('spec/pom.xml', %w(runtime compile)),
45
- LockJar::Domain::Jar.new('compile-jar')
46
- ])
42
+ expect(dsl.artifacts['default']).to eq(
43
+ [
44
+ LockJar::Domain::Jar.new('org.apache.mina:mina-core:2.0.4'),
45
+ LockJar::Domain::Pom.new('spec/pom.xml', %w(runtime compile)),
46
+ LockJar::Domain::Jar.new('compile-jar')
47
+ ]
48
+ )
47
49
  dsl.remote_repositories.should eql(['http://repository.jboss.org/nexus/content/groups/public-jboss', 'http://new-repo'])
48
50
  end
49
51
  end
@@ -15,7 +15,7 @@ describe LockJar::Domain::Dsl do
15
15
  expect(jarfile.artifacts['development'][0]).to eq LockJar::Domain::Jar.new('com.typesafe:config:jar:0.5.0')
16
16
  jarfile.artifacts['development'][1].should be_nil
17
17
 
18
- expect(jarfile.artifacts['test'][0]).to eq LockJar::Domain::Jar.new('junit:junit:jar:4.10')
18
+ expect(jarfile.artifacts['test'][0]).to eq LockJar::Domain::Jar.new('org.testng:testng:jar:6.9.10')
19
19
  jarfile.artifacts['test'][1].should be_nil
20
20
 
21
21
  jarfile.remote_repositories.should eql(['http://mirrors.ibiblio.org/pub/mirrors/maven2'])
@@ -35,7 +35,7 @@ describe LockJar::Domain::Dsl do
35
35
  end
36
36
 
37
37
  group 'test' do
38
- jar 'junit:junit:jar:4.10'
38
+ jar 'org.testng:testng:jar:6.9.10'
39
39
  end
40
40
  end
41
41
 
@@ -43,7 +43,7 @@ describe LockJar::Domain::Dsl do
43
43
  expect(block.artifacts).to eq(
44
44
  'default' => [LockJar::Domain::Jar.new('org.apache.mina:mina-core:2.0.4'), LockJar::Domain::Local.new('spec/fixtures/naether-0.13.0.jar'), LockJar::Domain::Pom.new('spec/pom.xml')],
45
45
  'pirate' => [LockJar::Domain::Jar.new('org.apache.tomcat:servlet-api:jar:6.0.35')],
46
- 'test' => [LockJar::Domain::Jar.new('junit:junit:jar:4.10')]
46
+ 'test' => [LockJar::Domain::Jar.new('org.testng:testng:jar:6.9.10')]
47
47
  )
48
48
  block.remote_repositories.should eql(['http://repository.jboss.org/nexus/content/groups/public-jboss'])
49
49
  end
@@ -18,8 +18,8 @@ describe LockJar::Resolver do
18
18
  end
19
19
 
20
20
  it 'should return local paths for notations' do
21
- expect(@resolver.to_local_paths(['junit:junit:jar:4.10'])).to(
22
- eql([File.expand_path("#{TEMP_DIR}/test-repo/junit/junit/4.10/junit-4.10.jar")])
21
+ expect(@resolver.to_local_paths(['org.testng:testng:jar:6.9.10'])).to(
22
+ eql([File.expand_path("#{TEMP_DIR}/test-repo/org/testng/testng/6.9.10/testng-6.9.10.jar")])
23
23
  )
24
24
  end
25
25
  end
@@ -5,7 +5,7 @@ describe LockJar::Runtime do
5
5
  describe '#load' do
6
6
  it 'should set local repo' do
7
7
  LockJar::Runtime.instance.load(nil, [], resolve: true, local_repo: TEST_REPO) do
8
- jar 'junit:junit:4.10'
8
+ jar 'org.testng:testng:jar:6.9.10'
9
9
  end
10
10
 
11
11
  LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql TEST_REPO
@@ -6,6 +6,8 @@ require 'naether'
6
6
  describe LockJar do
7
7
  include Spec::Helpers
8
8
 
9
+ let(:local_repo) { "#{TEMP_DIR}/test-repo" }
10
+
9
11
  before do
10
12
  LockJar::Runtime.instance.reset!
11
13
 
@@ -19,14 +21,26 @@ describe LockJar do
19
21
  describe '#lock' do
20
22
  context 'creates a lockfile' do
21
23
  let(:lockfile) do
22
- LockJar.lock(lockjar_source, local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/Jarfile.lock")
24
+ LockJar.lock(lockjar_source, local_repo: local_repo, lockfile: "#{TEMP_DIR}/Jarfile.lock")
23
25
  expect(File).to exist("#{TEMP_DIR}/Jarfile.lock")
24
26
  LockJar.read("#{TEMP_DIR}/Jarfile.lock")
25
27
  end
28
+ let(:test_dependencies) { %w(com.beust:jcommander:jar:1.48 org.beanshell:bsh:jar:2.0b4 org.testng:testng:jar:6.9.10) }
29
+ let(:test_artifacts) do
30
+ [
31
+ {
32
+ 'jar:org.testng:testng:jar:6.9.10' => {
33
+ 'transitive' => {
34
+ 'com.beust:jcommander:jar:1.48' => {},
35
+ 'org.beanshell:bsh:jar:2.0b4' => {}
36
+ }
37
+ }
38
+ }
39
+ ]
40
+ end
26
41
 
27
42
  context 'from Jarfile' do
28
43
  let(:lockjar_source) { 'spec/fixtures/Jarfile' }
29
-
30
44
  let(:expected_version) { LockJar::VERSION }
31
45
  let(:expected_local_repository) { '~/.m2/repository' }
32
46
  let(:expected_excludes) { %w(commons-logging logkit) }
@@ -38,7 +52,7 @@ describe LockJar do
38
52
  'dependencies' => %w(
39
53
  ch.qos.logback:logback-classic:jar:0.9.24
40
54
  ch.qos.logback:logback-core:jar:0.9.24 com.metapossum:metapossum-scanner:jar:1.0
41
- com.slackworks:modelcitizen:jar:0.2.2
55
+ com.tobedevoured.modelcitizen:core:jar:0.8.1
42
56
  commons-beanutils:commons-beanutils:jar:1.8.3 commons-io:commons-io:jar:1.4
43
57
  commons-lang:commons-lang:jar:2.6 commons-logging:commons-logging:jar:1.1.1
44
58
  org.apache.mina:mina-core:jar:2.0.4
@@ -54,7 +68,7 @@ describe LockJar do
54
68
  'pom:spec/pom.xml' => {
55
69
  'scopes' => %w(runtime compile),
56
70
  'transitive' => {
57
- 'com.slackworks:modelcitizen:jar:0.2.2' => {
71
+ 'com.tobedevoured.modelcitizen:core:jar:0.8.1' => {
58
72
  'com.metapossum:metapossum-scanner:jar:1.0' => {
59
73
  'commons-io:commons-io:jar:1.4' => {}
60
74
  },
@@ -78,14 +92,8 @@ describe LockJar do
78
92
  ]
79
93
  },
80
94
  'test' => {
81
- 'dependencies' => %w(junit:junit:jar:4.10 org.hamcrest:hamcrest-core:jar:1.1),
82
- 'artifacts' => [
83
- {
84
- 'jar:junit:junit:jar:4.10' => {
85
- 'transitive' => { 'org.hamcrest:hamcrest-core:jar:1.1' => {} }
86
- }
87
- }
88
- ]
95
+ 'dependencies' => test_dependencies,
96
+ 'artifacts' => test_artifacts
89
97
  }
90
98
  }
91
99
  end
@@ -97,23 +105,18 @@ describe LockJar do
97
105
  LockJar::Domain::Dsl.create do
98
106
  without_default_maven_repo
99
107
  remote_repo 'https://repository.jboss.org/nexus/content/groups/public'
100
- jar 'junit:junit:4.10'
108
+ jar 'org.jboss.logging:jboss-logging:3.1.0.GA'
101
109
  end
102
110
  end
103
111
 
104
112
  let(:expected_version) { LockJar::VERSION }
105
- let(:expected_maps) { { 'junit:junit:4.10' => [TEMP_DIR] } }
106
113
  let(:expected_remote_repositories) { ['https://repository.jboss.org/nexus/content/groups/public'] }
107
114
  let(:expected_groups) do
108
115
  {
109
116
  'default' => {
110
- 'dependencies' => %w(junit:junit:jar:4.10 org.hamcrest:hamcrest-core:jar:1.1),
117
+ 'dependencies' => ['org.jboss.logging:jboss-logging:jar:3.1.0.GA'],
111
118
  'artifacts' => [
112
- {
113
- 'jar:junit:junit:jar:4.10' => {
114
- 'transitive' => { 'org.hamcrest:hamcrest-core:jar:1.1' => {} }
115
- }
116
- }
119
+ { 'jar:org.jboss.logging:jboss-logging:jar:3.1.0.GA' => { 'transitive' => {} } }
117
120
  ]
118
121
  }
119
122
  }
@@ -125,25 +128,19 @@ describe LockJar do
125
128
  describe '#map' do
126
129
  let(:lockjar_source) do
127
130
  LockJar::Domain::Dsl.create do
128
- map 'junit:junit:4.10', TEMP_DIR
129
- jar 'junit:junit:4.10'
131
+ map 'org.testng:testng:jar:6.9.10', 'path/to/jar'
132
+ jar 'org.testng:testng:jar:6.9.10'
130
133
  end
131
134
  end
132
135
 
133
136
  let(:expected_version) { LockJar::VERSION }
134
- let(:expected_maps) { { 'junit:junit:4.10' => [TEMP_DIR] } }
137
+ let(:expected_maps) { { 'org.testng:testng:jar:6.9.10' => ['path/to/jar'] } }
135
138
  let(:expected_remote_repositories) { ['http://repo1.maven.org/maven2/'] }
136
139
  let(:expected_groups) do
137
140
  {
138
141
  'default' => {
139
- 'dependencies' => %w(junit:junit:jar:4.10 org.hamcrest:hamcrest-core:jar:1.1),
140
- 'artifacts' => [
141
- {
142
- 'jar:junit:junit:jar:4.10' => {
143
- 'transitive' => { 'org.hamcrest:hamcrest-core:jar:1.1' => {} }
144
- }
145
- }
146
- ]
142
+ 'dependencies' => test_dependencies,
143
+ 'artifacts' => test_artifacts
147
144
  }
148
145
  }
149
146
  end
@@ -196,7 +193,7 @@ describe LockJar do
196
193
 
197
194
  context 'from a block' do
198
195
  let(:lockfile) do
199
- LockJar.lock(local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/NoRepoJarfile.lock") do
196
+ LockJar.lock(local_repo: local_repo, lockfile: "#{TEMP_DIR}/NoRepoJarfile.lock") do
200
197
  jar 'org.eclipse.jetty:jetty-servlet:8.1.3.v20120416'
201
198
  end
202
199
 
@@ -248,22 +245,19 @@ describe LockJar do
248
245
  end
249
246
 
250
247
  describe '#install' do
248
+ let(:repo_path) { "#{TEMP_DIR}/test-repo-install" }
249
+
251
250
  it 'should install jars' do
252
251
  LockJar.lock('spec/fixtures/Jarfile', download_artifacts: false, local_repo: "#{TEMP_DIR}/test-repo-install", lockfile: "#{TEMP_DIR}/Jarfile.lock")
253
252
 
254
253
  jars = LockJar.install("#{TEMP_DIR}/Jarfile.lock", ['default'], local_repo: "#{TEMP_DIR}/test-repo-install")
255
- jars.should eql([
256
- File.expand_path("#{TEMP_DIR}/test-repo-install/ch/qos/logback/logback-classic/0.9.24/logback-classic-0.9.24.jar"),
257
- File.expand_path("#{TEMP_DIR}/test-repo-install/ch/qos/logback/logback-core/0.9.24/logback-core-0.9.24.jar"),
258
- File.expand_path("#{TEMP_DIR}/test-repo-install/com/metapossum/metapossum-scanner/1.0/metapossum-scanner-1.0.jar"),
259
- File.expand_path("#{TEMP_DIR}/test-repo-install/com/slackworks/modelcitizen/0.2.2/modelcitizen-0.2.2.jar"),
260
- File.expand_path("#{TEMP_DIR}/test-repo-install/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"),
261
- File.expand_path("#{TEMP_DIR}/test-repo-install/commons-io/commons-io/1.4/commons-io-1.4.jar"),
262
- File.expand_path("#{TEMP_DIR}/test-repo-install/commons-lang/commons-lang/2.6/commons-lang-2.6.jar"),
263
- File.expand_path("#{TEMP_DIR}/test-repo-install/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"),
264
- File.expand_path("#{TEMP_DIR}/test-repo-install/org/apache/mina/mina-core/2.0.4/mina-core-2.0.4.jar"),
265
- File.expand_path("#{TEMP_DIR}/test-repo-install/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar")
266
- ])
254
+ expect(jars).to eql(
255
+ [
256
+ File.expand_path("#{repo_path}/com/google/guava/guava/14.0.1/guava-14.0.1.jar"),
257
+ File.expand_path("#{repo_path}/org/apache/mina/mina-core/2.0.4/mina-core-2.0.4.jar"),
258
+ File.expand_path("#{repo_path}/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar")
259
+ ]
260
+ )
267
261
  end
268
262
  end
269
263
 
@@ -343,42 +337,56 @@ describe LockJar do
343
337
  end
344
338
 
345
339
  describe '#list' do
346
- it 'should list jars' do
347
- LockJar.lock('spec/fixtures/Jarfile', local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/Jarfile.lock")
340
+ let(:lockfile) { "#{TEMP_DIR}/Jarfile.lock" }
341
+ let(:lock) do
342
+ LockJar.lock('spec/fixtures/Jarfile', local_repo: local_repo, lockfile: lockfile)
343
+ end
344
+ let(:jars) do
345
+ lock
346
+ LockJar.list(lockfile, ['default', 'development', 'bad scope'], local_repo: local_repo)
347
+ end
348
348
 
349
- jars = LockJar.list("#{TEMP_DIR}/Jarfile.lock", ['default', 'development', 'bad scope'], local_repo: "#{TEMP_DIR}/test-repo")
349
+ it 'should list jars' do
350
350
  jars.should eql(
351
351
  %w(
352
- ch.qos.logback:logback-classic:jar:0.9.24 ch.qos.logback:logback-core:jar:0.9.24
353
- com.metapossum:metapossum-scanner:jar:1.0 com.slackworks:modelcitizen:jar:0.2.2
354
- commons-beanutils:commons-beanutils:jar:1.8.3 commons-io:commons-io:jar:1.4
355
- commons-lang:commons-lang:jar:2.6 commons-logging:commons-logging:jar:1.1.1
356
- org.apache.mina:mina-core:jar:2.0.4
357
- org.slf4j:slf4j-api:jar:1.6.1 spec/fixtures/naether-0.13.0.jar com.typesafe:config:jar:0.5.0
352
+ com.google.guava:guava:jar:14.0.1 org.apache.mina:mina-core:jar:2.0.4
353
+ org.slf4j:slf4j-api:jar:1.6.1 spec/fixtures/naether-0.13.0.jar
354
+ com.typesafe:config:jar:0.5.0
358
355
  )
359
356
  )
360
357
  end
361
358
 
362
- it 'should replace dependencies with maps' do
363
- dsl = LockJar::Domain::Dsl.create do
364
- map 'junit:junit', TEMP_DIR
365
- jar 'junit:junit:4.10'
359
+ context 'with a dsl' do
360
+ let(:local_path) { "#{TEMP_DIR}/guava.jar" }
361
+ let(:lockfile) { "#{TEMP_DIR}/ListJarfile.lock" }
362
+ let(:dsl) do
363
+ LockJar::Domain::Dsl.create do
364
+ map 'com.google.guava:guava', "#{TEMP_DIR}/guava.jar"
365
+ jar 'com.google.guava:guava:14.0.1'
366
+ end
366
367
  end
368
+ let(:paths) { LockJar.list(lockfile, local_repo: local_repo) }
369
+
370
+ before { LockJar.lock(dsl, local_repo: local_repo, lockfile: lockfile) }
367
371
 
368
- LockJar.lock(dsl, local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/ListJarfile.lock")
369
- paths = LockJar.list("#{TEMP_DIR}/ListJarfile.lock", local_repo: "#{TEMP_DIR}/test-repo")
370
- paths.should eql([TEMP_DIR, 'org.hamcrest:hamcrest-core:jar:1.1'])
372
+ it 'should replace dependencies with maps' do
373
+ paths.should eql([local_path])
374
+ end
371
375
  end
372
376
 
373
- it 'should replace dependencies with maps and get local paths' do
374
- dsl = LockJar::Domain::Dsl.create do
375
- map 'junit:junit', TEMP_DIR
376
- jar 'junit:junit:4.10'
377
+ context 'with resolve: false' do
378
+ let(:jars) do
379
+ lock
380
+ LockJar.list(lockfile, local_repo: local_repo, resolve: false)
377
381
  end
378
382
 
379
- LockJar.lock(dsl, local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/ListJarfile.lock")
380
- paths = LockJar.list("#{TEMP_DIR}/ListJarfile.lock", local_repo: "#{TEMP_DIR}/test-repo")
381
- paths.should eql([TEMP_DIR, 'org.hamcrest:hamcrest-core:jar:1.1'])
383
+ it 'should only list root dependencies' do
384
+ jars.should eql(
385
+ %w(
386
+ org.apache.mina:mina-core:jar:2.0.4 spec/pom.xml spec/fixtures/naether-0.13.0.jar
387
+ )
388
+ )
389
+ end
382
390
  end
383
391
  end
384
392
 
@@ -399,42 +407,24 @@ describe LockJar do
399
407
  end
400
408
  end
401
409
 
402
- let(:expected_jars) do
403
- [
404
- 'spec/fixtures/naether-0.13.0.jar',
405
- File.expand_path("#{TEMP_DIR}/test-repo/ch/qos/logback/logback-classic/0.9.24/logback-classic-0.9.24.jar"),
406
- File.expand_path("#{TEMP_DIR}/test-repo/ch/qos/logback/logback-core/0.9.24/logback-core-0.9.24.jar"),
407
- File.expand_path("#{TEMP_DIR}/test-repo/com/metapossum/metapossum-scanner/1.0/metapossum-scanner-1.0.jar"),
408
- File.expand_path("#{TEMP_DIR}/test-repo/com/slackworks/modelcitizen/0.2.2/modelcitizen-0.2.2.jar"),
409
- File.expand_path("#{TEMP_DIR}/test-repo/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar"),
410
- File.expand_path("#{TEMP_DIR}/test-repo/commons-io/commons-io/1.4/commons-io-1.4.jar"),
411
- File.expand_path("#{TEMP_DIR}/test-repo/commons-lang/commons-lang/2.6/commons-lang-2.6.jar"),
412
- File.expand_path("#{TEMP_DIR}/test-repo/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"),
413
- File.expand_path("#{TEMP_DIR}/test-repo/org/apache/mina/mina-core/2.0.4/mina-core-2.0.4.jar"),
414
- File.expand_path("#{TEMP_DIR}/test-repo/org/slf4j/slf4j-api/1.6.1/slf4j-api-1.6.1.jar")
415
- ]
416
- end
410
+ let(:repo_path) { "#{TEMP_DIR}/test-repo" }
417
411
 
418
412
  it 'by Jarfile.lock' do
419
413
  expect_java_class_not_loaded('org.apache.mina.core.IoUtil')
420
414
 
421
- LockJar.lock('spec/fixtures/Jarfile', local_repo: "#{TEMP_DIR}/test-repo", lockfile: "#{TEMP_DIR}/Jarfile.lock")
422
- jars = LockJar.load("#{TEMP_DIR}/Jarfile.lock", ['default'], local_repo: "#{TEMP_DIR}/test-repo")
423
- LockJar::Registry.instance.lockfile_registered?("#{TEMP_DIR}/Jarfile.lock").should be_false
424
-
425
- expect(jars).to eql(expected_jars)
415
+ LockJar.lock('spec/fixtures/Jarfile', local_repo: local_repo, lockfile: "#{TEMP_DIR}/Jarfile.lock")
416
+ LockJar.load("#{TEMP_DIR}/Jarfile.lock", ['default'], local_repo: local_repo)
417
+ expect(LockJar::Registry.instance.lockfile_registered?("#{TEMP_DIR}/Jarfile.lock")).to_not be
426
418
  expect_java_class_loaded('org.apache.mina.core.IoUtil')
427
419
  end
428
420
 
429
421
  it 'by block with resolve option' do
430
422
  expect_java_class_not_loaded('org.modeshape.common.math.Duration')
431
423
 
432
- jars = LockJar.load(local_repo: TEST_REPO, resolve: true) do
424
+ LockJar.load(local_repo: TEST_REPO, resolve: true) do
433
425
  jar 'org.modeshape:modeshape-common:3.4.0.Final'
434
426
  end
435
427
 
436
- jars.should eql([File.expand_path(TEST_REPO + '/org/modeshape/modeshape-common/3.4.0.Final/modeshape-common-3.4.0.Final.jar')])
437
-
438
428
  expect_java_class_loaded('org.modeshape.common.math.Duration')
439
429
  end
440
430
 
data/spec/pom.xml CHANGED
@@ -14,9 +14,9 @@ ttp://maven.apache.org/maven-v4_0_0.xsd ">
14
14
  </repositories>
15
15
  <dependencies>
16
16
  <dependency>
17
- <groupId>com.slackworks</groupId>
18
- <artifactId>modelcitizen</artifactId>
19
- <version>0.2.2</version>
17
+ <groupId>com.google.guava</groupId>
18
+ <artifactId>guava</artifactId>
19
+ <version>14.0.1</version>
20
20
  </dependency>
21
21
  <dependency>
22
22
  <groupId>org.jboss.unit</groupId>
@@ -24,11 +24,5 @@ ttp://maven.apache.org/maven-v4_0_0.xsd ">
24
24
  <version>1.2.4</version>
25
25
  <scope>test</scope>
26
26
  </dependency>
27
- <dependency>
28
- <groupId>junit</groupId>
29
- <artifactId>junit</artifactId>
30
- <version>4.8.2</version>
31
- <scope>test</scope>
32
- </dependency>
33
27
  </dependencies>
34
28
  </project>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lock_jar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.5
4
+ version: 0.14.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Guymon