Skip to content

Commit 903c1eb

Browse files
committed
Fix JDK version parsing for EA builds
1 parent 20f07dd commit 903c1eb

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

bloop-rifle/src/bloop/rifle/BloopVersion.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package bloop.rifle
22
case class BloopVersion(raw: String) {
33
def isOlderThan(other: BloopVersion) = {
4-
val bloopVRegex = "([0-9]+).([0-9]+)[.]([0-9]+)[-]?([0-9]+)?".r
4+
val bloopVRegex = "([0-9]+).([0-9]+)[.]([0-9]+)[-]?[a-z]*[-]?([0-9]+)?".r
5+
// https://regex101.com/r/YOZsOH/1
56
def unwrapVersionString(v: String) =
67
List(1, 2, 3, 4).map(bloopVRegex.findAllIn(v).group(_)).map(x =>
78
if (x != null) x.toInt else 0

bloop-rifle/src/bloop/rifle/VersionUtil.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ object VersionUtil {
3030
def parseBloopAbout(stdoutFromBloopAbout: String): Option[BloopRifle.BloopServerRuntimeInfo] = {
3131

3232
val bloopVersionRegex = "bloop v(.*)\\s".r
33-
val bloopJvmRegex = "Running on Java ... v([0-9._A-Za-z]+) [(](.*)[)]".r
33+
val bloopJvmRegex = "Running on Java ... v([0-9._A-Za-z\\-]+) [(](.*)[)]".r
34+
// https://regex101.com/r/lT624X/1
3435

3536
for {
3637
bloopVersion <- bloopVersionRegex.findFirstMatchIn(stdoutFromBloopAbout).map(_.group(1))

bloop-rifle/test/src/bloop/rifle/ParsingTests.scala

+21
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ParsingTests extends munit.FunSuite {
1919
expect(!("1.4.9".v isOlderThan "1.4.9".v))
2020
expect("1.4.10-2".v isOlderThan "1.4.10-4".v)
2121
expect("1.4.10-2-abc".v isOlderThan "1.4.10-4-def".v)
22+
expect("1.5.6-sc-2".v isOlderThan "1.5.6-sc-4".v)
2223
}
2324

2425
test("jvm release parsing test") {
@@ -29,13 +30,17 @@ class ParsingTests extends munit.FunSuite {
2930
expect("9".j == Some(9))
3031
expect("14".j == Some(14))
3132
expect("17".j == Some(17))
33+
expect("17.0.9-ea".j == Some(17))
34+
expect("21-ea".j == Some(21))
3235
}
3336

3437
test("parse jvm version") {
3538
expect("""openjdk version "1.8.0_292" """.jv == Some(8))
3639
expect("""openjdk version "9" """.jv == Some(9))
3740
expect("""openjdk version "11.0.11" 2021-04-20 """.jv == Some(11))
3841
expect("""openjdk version "16" 2021-03-16 """.jv == Some(16))
42+
expect("""openjdk version "17.0.9-ea" 2023-10-17 """.jv == Some(17))
43+
expect("""openjdk version "21-ea" 2023-09-19 """.jv == Some(21))
3944
}
4045

4146
val jreBloopOutput =
@@ -55,6 +60,14 @@ class ParsingTests extends munit.FunSuite {
5560
| -> Supports debugging user code, Java Debug Interface (JDI) is available.
5661
|Maintained by the Scala Center and the community.""".stripMargin
5762

63+
val jdkBloopOutputEA =
64+
"""|bloop v1.5.6-sc-4
65+
|
66+
|Using Scala v2.12.17 and Zinc v1.8.0
67+
|Running on Java JDK v17.0.9-ea (/usr/lib/jvm/java-17-openjdk-amd64)
68+
| -> Supports debugging user code, Java Debug Interface (JDI) is available.
69+
|Maintained by the Scala Center and the community.""".stripMargin
70+
5871
test("parse jre bloop about") {
5972
expect(jreBloopOutput.p == Some(BloopRifle.BloopServerRuntimeInfo(
6073
BloopVersion("1.4.11"),
@@ -71,4 +84,12 @@ class ParsingTests extends munit.FunSuite {
7184
)))
7285
}
7386

87+
test("parse jdk bloop about (EA JDK)") {
88+
expect(jdkBloopOutputEA.p == Some(BloopRifle.BloopServerRuntimeInfo(
89+
BloopVersion("1.5.6-sc-4"),
90+
17,
91+
"/usr/lib/jvm/java-17-openjdk-amd64"
92+
)))
93+
}
94+
7495
}

0 commit comments

Comments
 (0)