Skip to content

Commit d055897

Browse files
committed
Fix logic to select the latest JRuby version
* The maven 'latest' field is unusuable, the order is unpredictable and we need to skip old 9000.dev-SNAPSHOT snapshots. See jruby/jruby#6713
1 parent 476a09f commit d055897

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

find-jruby-head-url-nokogiri.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'open-uri'
2+
require 'rubygems'
23
require 'nokogiri'
34

45
base_url = 'https://oss.sonatype.org/content/repositories/snapshots/org/jruby/jruby-dist'
@@ -9,7 +10,9 @@
910
STDERR.puts xml
1011

1112
versions = Nokogiri::XML(xml).css('version').map(&:text)
12-
most_recent = (versions - %w[9000.dev-SNAPSHOT]).last
13+
14+
versions.delete('9000.dev-SNAPSHOT')
15+
most_recent = versions.max_by { |v| Gem::Version.new(v) }
1316

1417
builds_url = "#{base_url}/#{most_recent}/maven-metadata.xml"
1518
STDERR.puts builds_url

find-jruby-head-url.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'open-uri'
2+
require 'rubygems'
23

34
module MicroXMLParser
45
HEADER = %r{<\?xml\s.+\?>\n}
@@ -65,7 +66,9 @@ def self.rec(xml)
6566

6667
parsed = MicroXMLParser.parse(xml)
6768
versions = parsed.dig(:metadata, :versioning, :versions).map { |e| e[:version] }
68-
most_recent = (versions - %w[9000.dev-SNAPSHOT]).last
69+
70+
versions.delete('9000.dev-SNAPSHOT')
71+
most_recent = versions.max_by { |v| Gem::Version.new(v) }
6972

7073
builds_url = "#{base_url}/#{most_recent}/maven-metadata.xml"
7174
STDERR.puts builds_url

0 commit comments

Comments
 (0)