lock_jar 0.15.11-java
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.
- checksums.yaml +7 -0
- data/.codeclimate.yml +16 -0
- data/.gitignore +59 -0
- data/.rubocop.yml +31 -0
- data/.travis.yml +21 -0
- data/CHANGELOG.md +80 -0
- data/Gemfile +13 -0
- data/Guardfile +8 -0
- data/LICENSE +176 -0
- data/README.md +392 -0
- data/Rakefile +28 -0
- data/bin/lockjar +6 -0
- data/lib/lock_jar/buildr.rb +151 -0
- data/lib/lock_jar/bundler.rb +68 -0
- data/lib/lock_jar/class_loader.rb +67 -0
- data/lib/lock_jar/cli.rb +92 -0
- data/lib/lock_jar/config.rb +41 -0
- data/lib/lock_jar/domain/artifact.rb +114 -0
- data/lib/lock_jar/domain/dsl.rb +165 -0
- data/lib/lock_jar/domain/dsl_merger.rb +76 -0
- data/lib/lock_jar/domain/gem_dsl.rb +43 -0
- data/lib/lock_jar/domain/jarfile_dsl.rb +35 -0
- data/lib/lock_jar/domain/lockfile.rb +113 -0
- data/lib/lock_jar/logging.rb +14 -0
- data/lib/lock_jar/maven.rb +112 -0
- data/lib/lock_jar/registry.rb +85 -0
- data/lib/lock_jar/resolver.rb +100 -0
- data/lib/lock_jar/runtime/install.rb +28 -0
- data/lib/lock_jar/runtime/list.rb +77 -0
- data/lib/lock_jar/runtime/load.rb +53 -0
- data/lib/lock_jar/runtime/lock.rb +152 -0
- data/lib/lock_jar/runtime.rb +106 -0
- data/lib/lock_jar/version.rb +5 -0
- data/lib/lock_jar.rb +203 -0
- data/lock_jar.gemspec +36 -0
- data/spec/fixtures/Jarfile +14 -0
- data/spec/fixtures/Jarfile2 +1 -0
- data/spec/fixtures/jarfile_gem/Gemfile +4 -0
- data/spec/fixtures/jarfile_gem/Jarfile +1 -0
- data/spec/fixtures/jarfile_gem/jarfile_gem.gemspec +23 -0
- data/spec/fixtures/jarfile_gem/lib/jarfile_gem/version.rb +3 -0
- data/spec/fixtures/jarfile_gem/lib/jarfile_gem.rb +5 -0
- data/spec/fixtures/lock_jar_config.yml +4 -0
- data/spec/fixtures/naether-0.13.0.jar +0 -0
- data/spec/lock_jar/bundler_spec.rb +34 -0
- data/spec/lock_jar/class_loader_spec.rb +55 -0
- data/spec/lock_jar/cli_spec.rb +93 -0
- data/spec/lock_jar/config_spec.rb +51 -0
- data/spec/lock_jar/domain/dsl_merger_spec.rb +51 -0
- data/spec/lock_jar/domain/dsl_spec.rb +55 -0
- data/spec/lock_jar/domain/gem_dsl_spec.rb +18 -0
- data/spec/lock_jar/maven_spec.rb +21 -0
- data/spec/lock_jar/resolver_spec.rb +69 -0
- data/spec/lock_jar/runtime_spec.rb +30 -0
- data/spec/lock_jar_spec.rb +472 -0
- data/spec/pom.xml +28 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/support/Jarfile +1 -0
- data/spec/support/helper.rb +52 -0
- data/spec/support/shared_examples/lockfile.rb +45 -0
- metadata +203 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'lockjar' do
|
4
|
+
include Spec::Helpers
|
5
|
+
|
6
|
+
before do
|
7
|
+
install_jarfile <<-J
|
8
|
+
jar 'com.google.guava:guava:14.0.1'
|
9
|
+
J
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
remove_file('Jarfile')
|
14
|
+
remove_file('Jarfile.lock')
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'version' do
|
18
|
+
it 'should return correct version' do
|
19
|
+
lockjar 'version'
|
20
|
+
expect(@out).to eq(LockJar::VERSION)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'lock' do
|
25
|
+
it 'should create lock file with default path' do
|
26
|
+
lockjar 'lock'
|
27
|
+
expect(@out).to match(/^Locking Jarfile to Jarfile.lock.*/)
|
28
|
+
expect(File).to exist('Jarfile.lock')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should create lock file with specific path' do
|
32
|
+
jarfile_path = File.join('spec', 'support', 'Jarfile')
|
33
|
+
jarfile_lock_path = File.join('spec', 'support', 'Jarfile.lock')
|
34
|
+
remove_file(jarfile_lock_path)
|
35
|
+
|
36
|
+
lockjar "lock -j #{jarfile_path} -l #{jarfile_lock_path}"
|
37
|
+
expect(@out).to eq("Locking #{jarfile_path} to #{jarfile_lock_path}")
|
38
|
+
expect(File).to exist(jarfile_lock_path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'list' do
|
43
|
+
it 'should list with default path' do
|
44
|
+
lockjar 'lock'
|
45
|
+
|
46
|
+
expect_output = %(
|
47
|
+
Listing Jars from Jarfile.lock for ["default"]
|
48
|
+
["com.google.guava:guava:jar:14.0.1"]
|
49
|
+
).strip
|
50
|
+
|
51
|
+
lockjar 'list'
|
52
|
+
expect(@out).to eq(expect_output)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should list with specific path' do
|
56
|
+
jarfile_path = File.join('spec', 'support', 'Jarfile')
|
57
|
+
jarfile_lock_path = File.join('spec', 'support', 'Jarfile.lock')
|
58
|
+
remove_file(jarfile_lock_path)
|
59
|
+
lockjar "lock -j #{jarfile_path} -l #{jarfile_lock_path}"
|
60
|
+
|
61
|
+
expect_expr = Regexp.new(<<-'EOM'.strip)
|
62
|
+
Listing Jars from .*Jarfile.lock for \["default"\]
|
63
|
+
\["com.google.guava:guava:jar:14.0.1"\]
|
64
|
+
EOM
|
65
|
+
|
66
|
+
lockjar "list -l #{jarfile_lock_path}"
|
67
|
+
expect(@out).to match(expect_expr)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'install' do
|
72
|
+
it 'should install jar archives with default path' do
|
73
|
+
lockjar 'lock'
|
74
|
+
|
75
|
+
lockjar 'install'
|
76
|
+
expect(@out).to eq(%(Installing Jars from Jarfile.lock for ["default"]))
|
77
|
+
LockJar.load
|
78
|
+
expect(Java::ComGoogleCommonCollect::Multimap).to be_kind_of(Module) if is_jruby?
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should install jar archives with specific path' do
|
82
|
+
jarfile_path = File.join('spec', 'support', 'Jarfile')
|
83
|
+
jarfile_lock_path = File.join('spec', 'support', 'Jarfile.lock')
|
84
|
+
remove_file(jarfile_lock_path)
|
85
|
+
lockjar "lock -j #{jarfile_path} -l #{jarfile_lock_path}"
|
86
|
+
|
87
|
+
lockjar "install -l #{jarfile_lock_path}"
|
88
|
+
expect(@out).to eq(%(Installing Jars from #{jarfile_lock_path} for ["default"]))
|
89
|
+
LockJar.load(jarfile_lock_path)
|
90
|
+
expect(Java::ComGoogleCommonCollect::Multimap).to be_kind_of(Module) if is_jruby?
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LockJar::Config do
|
4
|
+
describe '.load_config_file' do
|
5
|
+
let(:test_config_file) { File.join('spec', 'fixtures', 'lock_jar_config.yml') }
|
6
|
+
let(:temp_config_file) { File.join(TEMP_DIR, described_class::DEFAULT_FILENAME) }
|
7
|
+
let(:config) { described_class.load_config_file }
|
8
|
+
let(:expected_repo_config) do
|
9
|
+
{
|
10
|
+
'https://some.fancy.doman/maven' => {
|
11
|
+
'username' => 'user1',
|
12
|
+
'password' => 'the_pass'
|
13
|
+
}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
FileUtils.cp(test_config_file, temp_config_file)
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'using current dir config' do
|
22
|
+
before do
|
23
|
+
allow(Dir).to receive(:pwd).and_return(TEMP_DIR)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should have a repository config' do
|
27
|
+
expect(config.repositories).to eq(expected_repo_config)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'using home dir config' do
|
32
|
+
before do
|
33
|
+
allow(Dir).to receive(:home).and_return(TEMP_DIR)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should have a repository config' do
|
37
|
+
expect(config.repositories).to eq(expected_repo_config)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'using ENV path to config' do
|
42
|
+
before do
|
43
|
+
ENV[described_class::CONFIG_ENV] = temp_config_file
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should have a repository config' do
|
47
|
+
expect(config.repositories).to eq(expected_repo_config)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'lock_jar/domain/dsl_merger'
|
4
|
+
|
5
|
+
describe LockJar::Domain::DslMerger do
|
6
|
+
it 'should merge dsl' do
|
7
|
+
block1 = LockJar::Domain::Dsl.create do
|
8
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
9
|
+
|
10
|
+
jar 'org.apache.mina:mina-core:2.0.4'
|
11
|
+
pom 'spec/pom.xml'
|
12
|
+
|
13
|
+
group 'runtime' do
|
14
|
+
jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
|
15
|
+
end
|
16
|
+
|
17
|
+
group 'test' do
|
18
|
+
jar 'org.testng:testng:jar:6.9.10'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
block2 = LockJar::Domain::Dsl.create do
|
23
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
24
|
+
repository 'http://new-repo'
|
25
|
+
|
26
|
+
jar 'org.apache.mina:mina-core:2.0.4'
|
27
|
+
jar 'compile-jar'
|
28
|
+
|
29
|
+
group 'runtime' do
|
30
|
+
jar 'runtime-jar'
|
31
|
+
pom 'runtime-pom.xml'
|
32
|
+
end
|
33
|
+
|
34
|
+
group 'test' do
|
35
|
+
jar 'test-jar'
|
36
|
+
pom 'test-pom.xml'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
dsl = LockJar::Domain::DslMerger.new(block1, block2).merge
|
41
|
+
|
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
|
+
)
|
49
|
+
dsl.remote_repositories.should eql(['http://repository.jboss.org/nexus/content/groups/public-jboss', 'http://new-repo'])
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lock_jar/domain/artifact'
|
3
|
+
|
4
|
+
describe LockJar::Domain::Dsl do
|
5
|
+
describe '.create' do
|
6
|
+
it 'should load a Jarfile' do
|
7
|
+
jarfile = LockJar::Domain::Dsl.create('spec/fixtures/Jarfile')
|
8
|
+
|
9
|
+
jarfile.local_repository.should eql '~/.m2/repository'
|
10
|
+
expect(jarfile.artifacts['default'][0]).to eq LockJar::Domain::Jar.new('org.apache.mina:mina-core:2.0.4')
|
11
|
+
expect(jarfile.artifacts['default'][1]).to eq LockJar::Domain::Local.new('spec/fixtures/naether-0.13.0.jar')
|
12
|
+
jarfile.artifacts['default'][2].path.should eql 'spec/pom.xml'
|
13
|
+
jarfile.artifacts['default'][3].should be_nil
|
14
|
+
|
15
|
+
expect(jarfile.artifacts['development'][0]).to eq LockJar::Domain::Jar.new('com.typesafe:config:jar:0.5.0')
|
16
|
+
jarfile.artifacts['development'][1].should be_nil
|
17
|
+
|
18
|
+
expect(jarfile.artifacts['test'][0]).to eq LockJar::Domain::Jar.new('org.testng:testng:jar:6.9.10')
|
19
|
+
jarfile.artifacts['test'][1].should be_nil
|
20
|
+
|
21
|
+
jarfile.remote_repositories.should eql(['http://mirrors.ibiblio.org/pub/mirrors/maven2'])
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should load a block' do
|
25
|
+
block = LockJar::Domain::Dsl.create do
|
26
|
+
local_repo '~/.m2'
|
27
|
+
repository 'http://repository.jboss.org/nexus/content/groups/public-jboss'
|
28
|
+
|
29
|
+
jar 'org.apache.mina:mina-core:2.0.4'
|
30
|
+
local 'spec/fixtures/naether-0.13.0.jar'
|
31
|
+
pom 'spec/pom.xml'
|
32
|
+
|
33
|
+
group 'pirate' do
|
34
|
+
jar 'org.apache.tomcat:servlet-api:jar:6.0.35'
|
35
|
+
end
|
36
|
+
|
37
|
+
group 'test' do
|
38
|
+
jar 'org.testng:testng:jar:6.9.10'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
block.local_repository.should eql '~/.m2'
|
43
|
+
expect(block.artifacts).to eq(
|
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
|
+
'pirate' => [LockJar::Domain::Jar.new('org.apache.tomcat:servlet-api:jar:6.0.35')],
|
46
|
+
'test' => [LockJar::Domain::Jar.new('org.testng:testng:jar:6.9.10')]
|
47
|
+
)
|
48
|
+
block.remote_repositories.should eql(['http://repository.jboss.org/nexus/content/groups/public-jboss'])
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should raise an error without arguments' do
|
52
|
+
lambda { LockJar::Domain::Dsl.create }.should raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lock_jar/domain/gem_dsl'
|
3
|
+
|
4
|
+
describe LockJar::Domain::GemDsl do
|
5
|
+
describe '.create' do
|
6
|
+
let(:spec) do
|
7
|
+
double(:spec, gem_dir: 'spec/fixtures', name: 'test')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should create from a block' do
|
11
|
+
jarfile = LockJar::Domain::GemDsl.create(spec, File.join(spec.gem_dir, 'Jarfile')) do
|
12
|
+
pom 'pom.xml'
|
13
|
+
end
|
14
|
+
|
15
|
+
expect(jarfile.gem_dir).to eql 'spec/fixtures'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lock_jar'
|
3
|
+
require 'lock_jar/maven'
|
4
|
+
require 'naether'
|
5
|
+
|
6
|
+
describe LockJar::Maven do
|
7
|
+
before do
|
8
|
+
# Bootstrap Naether
|
9
|
+
Naether::Bootstrap.bootstrap_local_repo
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should get pom version' do
|
13
|
+
LockJar::Maven.pom_version('spec/pom.xml').should eql('3')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should install artifact' do
|
17
|
+
LockJar::Maven.install('maven_spec:install:7', 'spec/pom.xml', nil, local_repo: "#{TEMP_DIR}/test-repo")
|
18
|
+
|
19
|
+
File.exist?("#{TEMP_DIR}/test-repo/maven_spec/install/7/install-7.pom").should be_truthy
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lock_jar/resolver'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'naether'
|
5
|
+
|
6
|
+
describe LockJar::Resolver do
|
7
|
+
subject { described_class.new(config, local_repo: "#{TEMP_DIR}/test-repo") }
|
8
|
+
|
9
|
+
before do
|
10
|
+
FileUtils.mkdir_p("#{TEMP_DIR}/test-repo")
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:config) do
|
14
|
+
LockJar::Config.new(
|
15
|
+
'repositories' => {
|
16
|
+
'https://test/repo' => {
|
17
|
+
'username' => 'user1',
|
18
|
+
'password' => 'pass1'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should bootstrap naether' do
|
25
|
+
subject
|
26
|
+
|
27
|
+
deps = Naether::Bootstrap.check_local_repo_for_deps("#{TEMP_DIR}/test-repo")
|
28
|
+
deps[:missing].should eql([])
|
29
|
+
deps[:exists].each do |dep|
|
30
|
+
expect(dep.values[0]).to match(/#{TEMP_DIR}#{File::SEPARATOR}test-repo#{File::SEPARATOR}.+/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#to_local_paths' do
|
35
|
+
it 'should return local paths for notations' do
|
36
|
+
expect(subject.to_local_paths(['org.testng:testng:jar:6.9.10'])).to(
|
37
|
+
eql([File.expand_path("#{TEMP_DIR}/test-repo/org/testng/testng/6.9.10/testng-6.9.10.jar")])
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#add_remote_repository' do
|
43
|
+
let(:remote_repos) do
|
44
|
+
subject.naether.remote_repositories.map do |repo|
|
45
|
+
{
|
46
|
+
url: repo.url
|
47
|
+
}.tap do |hash|
|
48
|
+
if repo.authentication
|
49
|
+
hash[:username] = repo.authentication.username
|
50
|
+
hash[:password] = repo.authentication.password
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
let(:expected_remote_repos) do
|
57
|
+
[
|
58
|
+
{ url: 'https://repo1.maven.org/maven2/' },
|
59
|
+
{ url: 'https://test/repo', username: 'user1', password: 'pass1' }
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should use repo config for auth' do
|
64
|
+
subject.add_remote_repository('https://test/repo')
|
65
|
+
|
66
|
+
expect(remote_repos).to eq(expected_remote_repos)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lock_jar/runtime'
|
3
|
+
|
4
|
+
describe LockJar::Runtime do
|
5
|
+
describe '#load' do
|
6
|
+
it 'should set local repo' do
|
7
|
+
LockJar::Runtime.instance.load(nil, [], resolve: true, local_repo: TEST_REPO) do
|
8
|
+
jar 'org.testng:testng:jar:6.9.10'
|
9
|
+
end
|
10
|
+
|
11
|
+
LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql TEST_REPO
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should use the local repo from the dsl' do
|
15
|
+
LockJar::Runtime.instance.load(nil) do
|
16
|
+
local_repo DSL_CONFIG
|
17
|
+
end
|
18
|
+
|
19
|
+
LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql DSL_CONFIG
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should use the local repo from param' do
|
23
|
+
LockJar::Runtime.instance.load(nil, [], local_repo: PARAM_CONFIG) do
|
24
|
+
local_repo 'dsl_config'
|
25
|
+
end
|
26
|
+
|
27
|
+
LockJar::Runtime.instance.current_resolver.naether.local_repo_path.should eql PARAM_CONFIG
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|