maven-tools 0.29.1 → 0.29.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -84,7 +84,7 @@ module Maven
84
84
  else
85
85
  File.open(@lockfile, 'w') do |f|
86
86
  dependency_coordinates.each do |d|
87
- f.puts d.to_s
87
+ f.puts d.to_s unless d.to_s =~ /^ruby.bundler:/
88
88
  end
89
89
  end
90
90
  end
@@ -1,5 +1,5 @@
1
1
  module Maven
2
2
  module Tools
3
- VERSION = '0.29.1'.freeze
3
+ VERSION = '0.29.2'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,124 @@
1
+ require 'maven/tools/jarfile'
2
+
3
+ class Container
4
+
5
+ attr_reader :artifacts, :repositories
6
+
7
+ def initialize
8
+ @artifacts = []
9
+ @repositories = []
10
+ end
11
+
12
+ def add_artifact(a)
13
+ @artifacts << a
14
+ end
15
+
16
+ def add_repository(name, url)
17
+ @repositories << name
18
+ end
19
+ end
20
+
21
+ describe Maven::Tools::Jarfile do
22
+
23
+ let(:workdir) { 'target' }
24
+ let(:jfile) { File.join(workdir, 'tmp-jarfile') }
25
+ let(:jfile_lock) { jfile + ".lock"}
26
+ let(:container) { Container.new }
27
+ subject { Maven::Tools::Jarfile.new(jfile) }
28
+
29
+ before do
30
+ FileUtils.mkdir_p workdir
31
+ Dir[File.join(workdir, "tmp*")].each { |f| FileUtils.rm_f f }
32
+ end
33
+
34
+ after do
35
+ FileUtils.rm_rf(File.join(workdir, "tmp-*"))
36
+ end
37
+
38
+ it 'generates lockfile' do
39
+ subject.generate_lockfile(%w( a b c d e f ruby.bundler:bla))
40
+ File.read(jfile_lock).must_equal <<-EOF
41
+ a
42
+ b
43
+ c
44
+ d
45
+ e
46
+ f
47
+ EOF
48
+ end
49
+
50
+ it 'check locked coordinate' do
51
+ File.open(jfile_lock, 'w') do |f|
52
+ f.write <<-EOF
53
+ a:b:pom:3
54
+ a:c:jar:1
55
+ EOF
56
+ end
57
+ subject.locked.must_equal ["a:b:pom:3", "a:c:jar:1"]
58
+ subject.locked?("a:b:pom:321").must_equal true
59
+ subject.locked?("a:b:jar:321").must_equal true
60
+ subject.locked?("a:d:jar:432").must_equal false
61
+ end
62
+
63
+ it 'populate repositories' do
64
+ File.open(jfile, 'w') do |f|
65
+ f.write <<-EOF
66
+ repository :first, "http://example.com/repo"
67
+ source 'second', "http://example.org/repo"
68
+ source "http://example.org/repo/3"
69
+ EOF
70
+ end
71
+ subject.populate_unlocked container
72
+ container.repositories.size.must_equal 3
73
+ container.artifacts.size.must_equal 0
74
+ container.repositories[0].must_equal "first"
75
+ container.repositories[1].must_equal "second"
76
+ container.repositories[2].must_equal "http://example.org/repo/3"
77
+ end
78
+
79
+ it 'populate artifacts without locked' do
80
+ File.open(jfile, 'w') do |f|
81
+ f.write <<-EOF
82
+ jar 'a:b', '123'
83
+ pom 'x:y', '987'
84
+ EOF
85
+ end
86
+ subject.populate_unlocked container
87
+ container.repositories.size.must_equal 0
88
+ container.artifacts.size.must_equal 2
89
+ container.artifacts[0].to_s.must_equal "a:b:jar:123"
90
+ container.artifacts[1].to_s.must_equal "x:y:pom:987"
91
+ end
92
+
93
+ it 'populate artifacts with locked' do
94
+ File.open(jfile, 'w') do |f|
95
+ f.write <<-EOF
96
+ jar 'a:b', '123'
97
+ pom 'x:y', '987'
98
+ EOF
99
+ end
100
+ File.open(jfile_lock, 'w') do |f|
101
+ f.write <<-EOF
102
+ a:b:jar:432
103
+ EOF
104
+ end
105
+
106
+ subject.populate_unlocked container
107
+ container.repositories.size.must_equal 0
108
+ container.artifacts.size.must_equal 1
109
+ container.artifacts[0].to_s.must_equal "x:y:pom:987"
110
+ end
111
+
112
+ it 'populate locked artifacts' do
113
+ File.open(jfile_lock, 'w') do |f|
114
+ f.write <<-EOF
115
+ a:b:jar:432
116
+ EOF
117
+ end
118
+
119
+ subject.populate_locked container
120
+ container.repositories.size.must_equal 0
121
+ container.artifacts.size.must_equal 1
122
+ container.artifacts[0].to_s.must_equal "a:b:jar:432"
123
+ end
124
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: maven-tools
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.29.1
5
+ version: 0.29.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kristian Meier
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-06-13 00:00:00 Z
13
+ date: 2012-06-14 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -83,6 +83,7 @@ files:
83
83
  - lib/maven/model/utils.rb~
84
84
  - lib/maven/model/model.rb~
85
85
  - spec/coordinate_spec.rb
86
+ - spec/#jarfile_spec.rb#
86
87
  - spec/jarfile_spec.rb
87
88
  - MIT-LICENSE
88
89
  - README.md