pompompom 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pompompom.rb +1 -1
- data/lib/pompompom/resolver.rb +27 -1
- data/pompompom.gemspec +4 -2
- data/spec/pompompom/resolver_spec.rb +3 -2
- data/spec/resources/repository/com/example/test-abc/1.0/test-abc-1.0.pom +1 -1
- data/spec/resources/repository/com/example/test/77.7/test-77.7.jar +0 -0
- data/spec/resources/repository/com/example/test/77.7/test-77.7.pom +11 -0
- data/spec/resources/repository/com/example/test/maven-metadata.xml +1 -0
- data/tasks/spec.rake +1 -0
- metadata +6 -4
data/lib/pompompom.rb
CHANGED
data/lib/pompompom/resolver.rb
CHANGED
@@ -27,7 +27,7 @@ module PomPomPom
|
|
27
27
|
def filter_newest(pom_groups)
|
28
28
|
pom_groups.map do |id, poms|
|
29
29
|
if poms.size > 1
|
30
|
-
newest = poms
|
30
|
+
newest = find_newest_version(poms)
|
31
31
|
@logger.warn(%(Warning: multiple versions of #{id} were required, using the newest required version (#{newest.version})))
|
32
32
|
newest
|
33
33
|
else
|
@@ -35,6 +35,32 @@ module PomPomPom
|
|
35
35
|
end
|
36
36
|
end.flatten
|
37
37
|
end
|
38
|
+
|
39
|
+
def find_newest_version(poms)
|
40
|
+
sorted = poms.sort do |a, b|
|
41
|
+
a_version = a.version.sub(/-\w+$/, '').split('.').map(&:to_i)
|
42
|
+
b_version = b.version.sub(/-\w+$/, '').split('.').map(&:to_i)
|
43
|
+
|
44
|
+
while a_version.size < b_version.size
|
45
|
+
a_version << 0
|
46
|
+
end
|
47
|
+
|
48
|
+
while a_version.size > b_version.size
|
49
|
+
b_version << 0
|
50
|
+
end
|
51
|
+
|
52
|
+
cmp = 0
|
53
|
+
|
54
|
+
a_version.zip(b_version).each do |(an, bn)|
|
55
|
+
cmp = an <=> bn
|
56
|
+
break unless cmp == 0
|
57
|
+
end
|
58
|
+
|
59
|
+
cmp
|
60
|
+
end
|
61
|
+
|
62
|
+
sorted.reverse.first
|
63
|
+
end
|
38
64
|
|
39
65
|
def group_by_artifact(poms)
|
40
66
|
poms.inject({}) do |acc, pom|
|
data/pompompom.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pompompom}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Theo Hultberg"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-26}
|
13
13
|
s.default_executable = %q{pompompom}
|
14
14
|
s.description = %q{Ruby dependency manager for Maven repository artifacts}
|
15
15
|
s.email = %q{theo@iconara.net}
|
@@ -63,6 +63,8 @@ Gem::Specification.new do |s|
|
|
63
63
|
"spec/resources/repository/com/example/test-optional/1.0/test-optional-1.0.jar",
|
64
64
|
"spec/resources/repository/com/example/test-optional/1.0/test-optional-1.0.pom",
|
65
65
|
"spec/resources/repository/com/example/test-parent/1.0/test-parent-1.0.pom",
|
66
|
+
"spec/resources/repository/com/example/test/77.7/test-77.7.jar",
|
67
|
+
"spec/resources/repository/com/example/test/77.7/test-77.7.pom",
|
66
68
|
"spec/resources/repository/com/example/test/8.8/test-8.8.jar",
|
67
69
|
"spec/resources/repository/com/example/test/8.8/test-8.8.pom",
|
68
70
|
"spec/resources/repository/com/example/test/9.9/test-9.9.jar",
|
@@ -145,7 +145,8 @@ module PomPomPom
|
|
145
145
|
|
146
146
|
it 'selects the newest dependency if more than one of the same are found' do
|
147
147
|
@all_dependencies = @resolver.find_transitive_dependencies(*@dependencies)
|
148
|
-
@all_dependencies.map(&:to_s).should include('com.example:test:
|
148
|
+
@all_dependencies.map(&:to_s).should include('com.example:test:77.7')
|
149
|
+
@all_dependencies.map(&:to_s).should_not include('com.example:test:9.9')
|
149
150
|
@all_dependencies.map(&:to_s).should_not include('com.example:test:8.8')
|
150
151
|
end
|
151
152
|
|
@@ -155,7 +156,7 @@ module PomPomPom
|
|
155
156
|
end
|
156
157
|
|
157
158
|
it 'warns if dependencies on multiple versions of an artifact are found' do
|
158
|
-
@logger.should_receive(:warn).with('Warning: multiple versions of com.example:test were required, using the newest required version (
|
159
|
+
@logger.should_receive(:warn).with('Warning: multiple versions of com.example:test were required, using the newest required version (77.7)')
|
159
160
|
@resolver.find_transitive_dependencies(*@dependencies)
|
160
161
|
end
|
161
162
|
end
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<project>
|
3
|
+
<modelVersion>4.0.0</modelVersion>
|
4
|
+
<groupId>com.example</groupId>
|
5
|
+
<artifactId>test</artifactId>
|
6
|
+
<version>77.7</version>
|
7
|
+
<packaging>jar</packaging>
|
8
|
+
<name>Test POM</name>
|
9
|
+
<description>Test POM</description>
|
10
|
+
<url>http://www.example.com</url>
|
11
|
+
</project>
|
data/tasks/spec.rake
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pompompom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 3
|
10
|
+
version: 1.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Theo Hultberg
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-26 00:00:00 +02:00
|
19
19
|
default_executable: pompompom
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -100,6 +100,8 @@ files:
|
|
100
100
|
- spec/resources/repository/com/example/test-optional/1.0/test-optional-1.0.jar
|
101
101
|
- spec/resources/repository/com/example/test-optional/1.0/test-optional-1.0.pom
|
102
102
|
- spec/resources/repository/com/example/test-parent/1.0/test-parent-1.0.pom
|
103
|
+
- spec/resources/repository/com/example/test/77.7/test-77.7.jar
|
104
|
+
- spec/resources/repository/com/example/test/77.7/test-77.7.pom
|
103
105
|
- spec/resources/repository/com/example/test/8.8/test-8.8.jar
|
104
106
|
- spec/resources/repository/com/example/test/8.8/test-8.8.pom
|
105
107
|
- spec/resources/repository/com/example/test/9.9/test-9.9.jar
|