jbundler 0.0.1 → 0.2.0
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.
- data/Build.md +32 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +35 -0
- data/Gemfile.lock- +33 -0
- data/Readme.md +88 -0
- data/lib/jbundler.jar +0 -0
- data/lib/jbundler.rb +25 -20
- data/lib/jbundler.rb~ +2 -0
- data/lib/jbundler/aether.rb +44 -15
- data/lib/jbundler/aether.rb~ +68 -0
- data/lib/jbundler/classpath_file.rb +2 -4
- data/lib/jbundler/classpath_file.rb~ +207 -0
- data/lib/jbundler/gemfile_lock.rb +4 -4
- data/lib/jbundler/gemfile_lock.rb~ +17 -0
- data/lib/jbundler/maven.rb~ +252 -0
- data/lib/jbundler/maven_gemify3.rb~ +337 -0
- data/lib/jbundler/{maven_util.rb → maven_util.rb~} +4 -14
- data/lib/jbundler/maven_version.rb~ +4 -0
- data/lib/jbundler/mavenfile.rb~ +9 -0
- data/lib/jbundler/pom.rb +2 -2
- data/lib/jbundler/pom.rb~ +251 -0
- data/spec/aether_spec.rb +78 -0
- data/spec/{mavenfile_spec.rb → aether_spec.rb~} +12 -14
- data/spec/classpath_file_spec.rb +26 -24
- data/spec/classpath_file_spec.rb~ +81 -0
- data/spec/{maven_util_spec.rb → maven_util_spec.rb~} +1 -12
- data/spec/mavenfile_spec.rb~ +40 -0
- data/spec/pom_spec.rb +2 -0
- data/spec/pom_spec.rb~ +40 -0
- data/spec/setup.rb +3 -0
- data/spec/setup.rb~ +3 -0
- metadata +82 -54
- data/lib/jbundler/mavenfile.rb +0 -77
data/spec/aether_spec.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#TODO get 'spec' into $LOAD by minispec-maven-plugin
|
2
|
+
load File.expand_path(File.join('spec', 'setup.rb'))
|
3
|
+
require 'maven/tools/jarfile'
|
4
|
+
require 'jbundler/aether'
|
5
|
+
|
6
|
+
describe JBundler::AetherRuby do
|
7
|
+
|
8
|
+
let(:workdir) { 'target' }
|
9
|
+
let(:jfile) { File.join(workdir, 'tmp-jarfile') }
|
10
|
+
let(:jfile_lock) { jfile + ".lock"}
|
11
|
+
let(:jarfile) { Maven::Tools::Jarfile.new(jfile) }
|
12
|
+
subject { JBundler::AetherRuby.new }
|
13
|
+
|
14
|
+
before do
|
15
|
+
Dir[File.join(workdir, "tmp*")].each { |f| FileUtils.rm_f f }
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'repositories' do
|
19
|
+
File.open(jfile, 'w') do |f|
|
20
|
+
f.write <<-EOF
|
21
|
+
repository :first, "http://example.com/repo"
|
22
|
+
source 'second', "http://example.org/repo"
|
23
|
+
EOF
|
24
|
+
end
|
25
|
+
jarfile.populate_unlocked subject
|
26
|
+
subject.repositories.size.must_equal 3
|
27
|
+
subject.artifacts.size.must_equal 0
|
28
|
+
subject.repositories[0].id.must_equal "central"
|
29
|
+
subject.repositories[1].id.must_equal "first"
|
30
|
+
subject.repositories[2].id.must_equal "second"
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'artifacts without locked' do
|
34
|
+
File.open(jfile, 'w') do |f|
|
35
|
+
f.write <<-EOF
|
36
|
+
jar 'a:b', '123'
|
37
|
+
pom 'x:y', '987'
|
38
|
+
EOF
|
39
|
+
end
|
40
|
+
jarfile.populate_unlocked subject
|
41
|
+
subject.repositories.size.must_equal 1 # central
|
42
|
+
subject.artifacts.size.must_equal 2
|
43
|
+
subject.artifacts[0].to_s.must_equal "a:b:jar:123"
|
44
|
+
subject.artifacts[1].to_s.must_equal "x:y:pom:987"
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'artifacts with locked' do
|
48
|
+
File.open(jfile, 'w') do |f|
|
49
|
+
f.write <<-EOF
|
50
|
+
jar 'a:b', '123'
|
51
|
+
pom 'x:y', '987'
|
52
|
+
EOF
|
53
|
+
end
|
54
|
+
File.open(jfile_lock, 'w') do |f|
|
55
|
+
f.write <<-EOF
|
56
|
+
a:b:jar:432
|
57
|
+
EOF
|
58
|
+
end
|
59
|
+
|
60
|
+
jarfile.populate_unlocked subject
|
61
|
+
subject.repositories.size.must_equal 1 # central
|
62
|
+
subject.artifacts.size.must_equal 1
|
63
|
+
subject.artifacts[0].to_s.must_equal "x:y:pom:987"
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'locked artifacts' do
|
67
|
+
File.open(jfile_lock, 'w') do |f|
|
68
|
+
f.write <<-EOF
|
69
|
+
a:b:jar:432
|
70
|
+
EOF
|
71
|
+
end
|
72
|
+
|
73
|
+
jarfile.populate_locked subject
|
74
|
+
subject.repositories.size.must_equal 1 # central
|
75
|
+
subject.artifacts.size.must_equal 1
|
76
|
+
subject.artifacts[0].to_s.must_equal "a:b:jar:432"
|
77
|
+
end
|
78
|
+
end
|
@@ -1,15 +1,13 @@
|
|
1
|
-
require '
|
2
|
-
require 'jbundler/mavenfile'
|
3
|
-
require 'jbundler/gemfile_lock'
|
1
|
+
require 'maven/tools/jarfile'
|
4
2
|
require 'jbundler/aether'
|
5
3
|
|
6
|
-
describe
|
4
|
+
describe Maven::Tools::Jarfile do
|
7
5
|
|
8
6
|
let(:workdir) { 'target' }
|
9
|
-
let(:
|
10
|
-
let(:
|
7
|
+
let(:jfile) { File.join(workdir, 'tmp-jarfile') }
|
8
|
+
let(:jfile_lock) { jfile + ".lock"}
|
11
9
|
let(:aether) { JBundler::AetherRuby.new }
|
12
|
-
subject {
|
10
|
+
subject { Maven::Tools::Jarfile.new(jfile) }
|
13
11
|
|
14
12
|
before do
|
15
13
|
Dir[File.join(workdir, "tmp*")].each { |f| FileUtils.rm_f f }
|
@@ -17,7 +15,7 @@ describe JBundler::Mavenfile do
|
|
17
15
|
|
18
16
|
it 'generates lockfile' do
|
19
17
|
subject.generate_lockfile(%w( a b c d e f))
|
20
|
-
File.read(
|
18
|
+
File.read(jfile_lock).must_equal <<-EOF
|
21
19
|
a
|
22
20
|
b
|
23
21
|
c
|
@@ -28,7 +26,7 @@ EOF
|
|
28
26
|
end
|
29
27
|
|
30
28
|
it 'check locked coordinate' do
|
31
|
-
File.open(
|
29
|
+
File.open(jfile_lock, 'w') do |f|
|
32
30
|
f.write <<-EOF
|
33
31
|
a:b:pom:3
|
34
32
|
a:c:jar:1
|
@@ -41,7 +39,7 @@ EOF
|
|
41
39
|
end
|
42
40
|
|
43
41
|
it 'populate repositories' do
|
44
|
-
File.open(
|
42
|
+
File.open(jfile, 'w') do |f|
|
45
43
|
f.write <<-EOF
|
46
44
|
repository :first, "http://example.com/repo"
|
47
45
|
source 'second', "http://example.org/repo"
|
@@ -56,7 +54,7 @@ EOF
|
|
56
54
|
end
|
57
55
|
|
58
56
|
it 'populate artifacts without locked' do
|
59
|
-
File.open(
|
57
|
+
File.open(jfile, 'w') do |f|
|
60
58
|
f.write <<-EOF
|
61
59
|
jar 'a:b', '123'
|
62
60
|
pom 'x:y', '987'
|
@@ -70,13 +68,13 @@ EOF
|
|
70
68
|
end
|
71
69
|
|
72
70
|
it 'populate artifacts with locked' do
|
73
|
-
File.open(
|
71
|
+
File.open(jfile, 'w') do |f|
|
74
72
|
f.write <<-EOF
|
75
73
|
jar 'a:b', '123'
|
76
74
|
pom 'x:y', '987'
|
77
75
|
EOF
|
78
76
|
end
|
79
|
-
File.open(
|
77
|
+
File.open(jfile_lock, 'w') do |f|
|
80
78
|
f.write <<-EOF
|
81
79
|
a:b:jar:432
|
82
80
|
EOF
|
@@ -89,7 +87,7 @@ EOF
|
|
89
87
|
end
|
90
88
|
|
91
89
|
it 'populate locked artifacts' do
|
92
|
-
File.open(
|
90
|
+
File.open(jfile_lock, 'w') do |f|
|
93
91
|
f.write <<-EOF
|
94
92
|
a:b:jar:432
|
95
93
|
EOF
|
data/spec/classpath_file_spec.rb
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
+
#TODO get 'spec' into $LOAD by minispec-maven-plugin
|
2
|
+
load File.expand_path(File.join('spec', 'setup.rb'))
|
1
3
|
require 'jbundler/classpath_file'
|
2
|
-
require '
|
4
|
+
require 'maven/tools/jarfile'
|
3
5
|
require 'jbundler/gemfile_lock'
|
4
6
|
|
5
7
|
describe JBundler::ClasspathFile do
|
6
8
|
|
7
9
|
let(:workdir) { 'target' }
|
8
|
-
let(:
|
10
|
+
let(:jfile) { File.join(workdir, 'tmp-jarfile') }
|
9
11
|
let(:gfile_lock) { File.join(workdir, 'tmp-gemfile.lock') }
|
10
|
-
let(:
|
12
|
+
let(:jfile_lock) { jfile + ".lock"}
|
11
13
|
let(:cpfile) { File.join(workdir, 'tmp-cp.rb') }
|
12
|
-
let(:
|
13
|
-
let(:gemfile_lock) { JBundler::GemfileLock.new(
|
14
|
+
let(:jarfile) { Maven::Tools::Jarfile.new(jfile) }
|
15
|
+
let(:gemfile_lock) { JBundler::GemfileLock.new(jarfile, gfile_lock) }
|
14
16
|
subject { JBundler::ClasspathFile.new(cpfile) }
|
15
17
|
|
16
18
|
before do
|
@@ -19,50 +21,50 @@ describe JBundler::ClasspathFile do
|
|
19
21
|
end
|
20
22
|
|
21
23
|
it 'needs update when all files are missing' do
|
22
|
-
subject.needs_update?(
|
24
|
+
subject.needs_update?(jarfile, gemfile_lock).must_equal true
|
23
25
|
end
|
24
26
|
|
25
|
-
it 'needs update when only
|
26
|
-
FileUtils.touch
|
27
|
-
subject.needs_update?(
|
27
|
+
it 'needs update when only jarfile' do
|
28
|
+
FileUtils.touch jfile
|
29
|
+
subject.needs_update?(jarfile, gemfile_lock).must_equal true
|
28
30
|
end
|
29
31
|
|
30
|
-
it 'needs update when
|
31
|
-
FileUtils.touch
|
32
|
+
it 'needs update when jarfilelock is missing' do
|
33
|
+
FileUtils.touch jfile
|
32
34
|
FileUtils.touch cpfile
|
33
|
-
subject.needs_update?(
|
35
|
+
subject.needs_update?(jarfile, gemfile_lock).must_equal true
|
34
36
|
end
|
35
37
|
|
36
38
|
it 'needs no update when classpath file is the youngest' do
|
37
|
-
FileUtils.touch
|
38
|
-
FileUtils.touch
|
39
|
+
FileUtils.touch jfile
|
40
|
+
FileUtils.touch jfile_lock
|
39
41
|
FileUtils.touch cpfile
|
40
|
-
subject.needs_update?(
|
42
|
+
subject.needs_update?(jarfile, gemfile_lock).must_equal false
|
41
43
|
end
|
42
44
|
|
43
45
|
it 'needs update when maven file is the youngest' do
|
44
|
-
FileUtils.touch
|
46
|
+
FileUtils.touch jfile_lock
|
45
47
|
FileUtils.touch cpfile
|
46
48
|
sleep 1
|
47
|
-
FileUtils.touch
|
48
|
-
subject.needs_update?(
|
49
|
+
FileUtils.touch jfile
|
50
|
+
subject.needs_update?(jarfile, gemfile_lock).must_equal true
|
49
51
|
end
|
50
52
|
|
51
53
|
it 'needs update when maven lockfile is the youngest' do
|
52
|
-
FileUtils.touch
|
54
|
+
FileUtils.touch jfile
|
53
55
|
FileUtils.touch cpfile
|
54
56
|
sleep 1
|
55
|
-
FileUtils.touch
|
56
|
-
subject.needs_update?(
|
57
|
+
FileUtils.touch jfile_lock
|
58
|
+
subject.needs_update?(jarfile, gemfile_lock).must_equal true
|
57
59
|
end
|
58
60
|
|
59
61
|
it 'needs update when gem lockfile is the youngest' do
|
60
|
-
FileUtils.touch
|
62
|
+
FileUtils.touch jfile
|
61
63
|
FileUtils.touch cpfile
|
62
|
-
FileUtils.touch
|
64
|
+
FileUtils.touch jfile_lock
|
63
65
|
sleep 1
|
64
66
|
FileUtils.touch gfile_lock
|
65
|
-
subject.needs_update?(
|
67
|
+
subject.needs_update?(jarfile, gemfile_lock).must_equal true
|
66
68
|
end
|
67
69
|
|
68
70
|
it 'generates a classpath ruby file' do
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'jbundler/classpath_file'
|
2
|
+
require 'jbundler/mavenfile'
|
3
|
+
require 'jbundler/gemfile_lock'
|
4
|
+
|
5
|
+
describe JBundler::ClasspathFile do
|
6
|
+
|
7
|
+
let(:workdir) { 'target' }
|
8
|
+
let(:mfile) { File.join(workdir, 'tmp-mvnfile') }
|
9
|
+
let(:gfile_lock) { File.join(workdir, 'tmp-gemfile.lock') }
|
10
|
+
let(:mfile_lock) { mfile + ".lock"}
|
11
|
+
let(:cpfile) { File.join(workdir, 'tmp-cp.rb') }
|
12
|
+
let(:mavenfile) { JBundler::Mavenfile.new(mfile) }
|
13
|
+
let(:gemfile_lock) { JBundler::GemfileLock.new(gfile_lock) }
|
14
|
+
subject { JBundler::ClasspathFile.new(cpfile) }
|
15
|
+
|
16
|
+
before do
|
17
|
+
Dir[File.join(workdir, "tmp*")].each { |f| FileUtils.rm_f f }
|
18
|
+
FileUtils.touch gfile_lock #assume there is always a Gemfile.lock
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'needs update when all files are missing' do
|
22
|
+
subject.needs_update?(mavenfile,gemfile_lock).must_equal true
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'needs update when only mavenfile' do
|
26
|
+
FileUtils.touch mfile
|
27
|
+
subject.needs_update?(mavenfile,gemfile_lock).must_equal true
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'needs update when mavenfilelock is missing' do
|
31
|
+
FileUtils.touch mfile
|
32
|
+
FileUtils.touch cpfile
|
33
|
+
subject.needs_update?(mavenfile,gemfile_lock).must_equal true
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'needs no update when classpath file is the youngest' do
|
37
|
+
FileUtils.touch mfile
|
38
|
+
FileUtils.touch mfile_lock
|
39
|
+
FileUtils.touch cpfile
|
40
|
+
subject.needs_update?(mavenfile,gemfile_lock).must_equal false
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'needs update when maven file is the youngest' do
|
44
|
+
FileUtils.touch mfile_lock
|
45
|
+
FileUtils.touch cpfile
|
46
|
+
sleep 1
|
47
|
+
FileUtils.touch mfile
|
48
|
+
subject.needs_update?(mavenfile,gemfile_lock).must_equal true
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'needs update when maven lockfile is the youngest' do
|
52
|
+
FileUtils.touch mfile
|
53
|
+
FileUtils.touch cpfile
|
54
|
+
sleep 1
|
55
|
+
FileUtils.touch mfile_lock
|
56
|
+
subject.needs_update?(mavenfile,gemfile_lock).must_equal true
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'needs update when gem lockfile is the youngest' do
|
60
|
+
FileUtils.touch mfile
|
61
|
+
FileUtils.touch cpfile
|
62
|
+
FileUtils.touch mfile_lock
|
63
|
+
sleep 1
|
64
|
+
FileUtils.touch gfile_lock
|
65
|
+
subject.needs_update?(mavenfile,gemfile_lock).must_equal true
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'generates a classpath ruby file' do
|
69
|
+
subject.generate("a:b:c:d:f:".gsub(/:/, File::PATH_SEPARATOR))
|
70
|
+
File.read(cpfile).must_equal <<-EOF
|
71
|
+
JBUNDLER_CLASSPATH = []
|
72
|
+
JBUNDLER_CLASSPATH << 'a'
|
73
|
+
JBUNDLER_CLASSPATH << 'b'
|
74
|
+
JBUNDLER_CLASSPATH << 'c'
|
75
|
+
JBUNDLER_CLASSPATH << 'd'
|
76
|
+
JBUNDLER_CLASSPATH << 'f'
|
77
|
+
JBUNDLER_CLASSPATH.freeze
|
78
|
+
JBUNDLER_CLASSPATH.each { |c| require c }
|
79
|
+
EOF
|
80
|
+
end
|
81
|
+
end
|
@@ -23,22 +23,11 @@ describe JBundler::MavenUtil do
|
|
23
23
|
subject.to_version('>1.2', '<=2.0').must_equal "(1.2,2.0]"
|
24
24
|
end
|
25
25
|
|
26
|
-
it 'should
|
26
|
+
it 'should maven version and ranges as is' do
|
27
27
|
subject.to_version('1.2.3').must_equal "1.2.3"
|
28
28
|
subject.to_version('(1,2)').must_equal "(1,2)"
|
29
29
|
subject.to_version('[1,2)').must_equal "[1,2)"
|
30
30
|
subject.to_version('(1,2]').must_equal "(1,2]"
|
31
31
|
subject.to_version('[1,2]').must_equal "[1,2]"
|
32
32
|
end
|
33
|
-
|
34
|
-
it 'should convert pom of jar deps to maven coordinate' do
|
35
|
-
subject.to_coordinate('something "a:b"').must_be_nil
|
36
|
-
subject.to_coordinate('#jar "a:b"').must_be_nil
|
37
|
-
subject.to_coordinate('jar "a:b" # bla').must_equal "a:b:jar:[0,)"
|
38
|
-
subject.to_coordinate("pom 'b:c', '!2.3.4'").must_equal "b:c:pom:(2.3.4,)"
|
39
|
-
subject.to_coordinate('jar "c:d", "2.3.4"').must_equal "c:d:jar:2.3.4"
|
40
|
-
subject.to_coordinate("jar 'd:e', '~>1.8.2'").must_equal "d:e:jar:[1.8.2,1.8.99999]"
|
41
|
-
subject.to_coordinate('pom "e:f", "[1.8,1.9.9)"').must_equal "e:f:pom:[1.8,1.9.9)"
|
42
|
-
subject.to_coordinate('pom "f:g", ">1.2", "<=2.0"').must_equal "f:g:pom:(1.2,2.0]"
|
43
|
-
end
|
44
33
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'jbundler/classpath_file'
|
2
|
+
require 'jbundler/mavenfile'
|
3
|
+
require 'jbundler/gemfile_lock'
|
4
|
+
|
5
|
+
describe JBundler::Mavenfile do
|
6
|
+
|
7
|
+
let(:workdir) { 'target' }
|
8
|
+
let(:mfile) { File.join(workdir, 'tmp-mvnfile') }
|
9
|
+
let(:mfile_lock) { mfile + ".lock"}
|
10
|
+
subject { JBundler::Mavenfile.new(mfile) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
Dir[File.join(workdir, "tmp*")].each { |f| FileUtils.rm_f f }
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'generates lockfile' do
|
17
|
+
subject.generate_lockfile(%w( a b c d e f))
|
18
|
+
File.read(mfile_lock).must_equal <<-EOF
|
19
|
+
a
|
20
|
+
b
|
21
|
+
c
|
22
|
+
d
|
23
|
+
e
|
24
|
+
f
|
25
|
+
EOF
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'check locked coordinate' do
|
29
|
+
File.open(mfile_lock, 'w') do |f|
|
30
|
+
f.write <<-EOF
|
31
|
+
a:b:pom:3
|
32
|
+
a:c:jar:1
|
33
|
+
EOF
|
34
|
+
end
|
35
|
+
subject.locked.must_equal ["a:b:pom:3", "a:c:jar:1"]
|
36
|
+
subject.locked?("a:b:pom:321").must_equal true
|
37
|
+
subject.locked?("a:b:jar:321").must_equal true
|
38
|
+
subject.locked?("a:d:jar:432").must_equal false
|
39
|
+
end
|
40
|
+
end
|
data/spec/pom_spec.rb
CHANGED
data/spec/pom_spec.rb~
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'jbundler/classpath_file'
|
2
|
+
require 'jbundler/mavenfile'
|
3
|
+
require 'jbundler/gemfile_lock'
|
4
|
+
|
5
|
+
describe JBundler::Mavenfile do
|
6
|
+
|
7
|
+
let(:workdir) { 'target' }
|
8
|
+
let(:mfile) { File.join(workdir, 'tmp-mvnfile') }
|
9
|
+
let(:mfile_lock) { mfile + ".lock"}
|
10
|
+
subject { JBundler::Mavenfile.new(mfile) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
Dir[File.join(workdir, "tmp*")].each { |f| FileUtils.rm_f f }
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'generates lockfile' do
|
17
|
+
subject.generate_lockfile(%w( a b c d e f))
|
18
|
+
File.read(mfile_lock).must_equal <<-EOF
|
19
|
+
a
|
20
|
+
b
|
21
|
+
c
|
22
|
+
d
|
23
|
+
e
|
24
|
+
f
|
25
|
+
EOF
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'check locked coordinate' do
|
29
|
+
File.open(mfile_lock, 'w') do |f|
|
30
|
+
f.write <<-EOF
|
31
|
+
a:b:3
|
32
|
+
a:c:1
|
33
|
+
EOF
|
34
|
+
end
|
35
|
+
subject.load_lockfile.must_equal ["a:b:3", "a:c:1"]
|
36
|
+
subject.locked.must_equal ["a:b:3", "a:c:1"]
|
37
|
+
subject.locked?("a:b:321").must_equal true
|
38
|
+
subject.locked?("a:d:432").must_equal false
|
39
|
+
end
|
40
|
+
end
|