Skip to content

Commit 26f35e7

Browse files
committed
Fix java version parsing (#521)
1 parent e8ea622 commit 26f35e7

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

spark-api/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ license {
1313
header = project.file('HEADER.txt')
1414
}
1515

16+
java {
17+
withSourcesJar()
18+
withJavadocJar()
19+
}
20+
1621
publishing {
1722
//repositories {
1823
// maven {
19-
// url = 'https://oss.sonatype.org/content/repositories/snapshots'
24+
// url = 'https://nexus.lucko.me/repository/maven-snapshots/'
2025
// credentials {
21-
// username = sonatypeUsername
22-
// password = sonatypePassword
26+
// username = luckoNexusUsername
27+
// password = luckoNexusPassword
2328
// }
2429
// }
2530
//}

spark-common/src/main/java/me/lucko/spark/common/util/JavaVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static int parseJavaVersion(String version) {
3737
return Integer.parseInt(version.substring(2, 3));
3838
} else {
3939
// Java 9 and above
40-
return Integer.parseInt(version.split("\\.")[0]);
40+
return Integer.parseInt(version.split("\\.|\\-")[0]);
4141
}
4242
}
4343

spark-common/src/test/java/me/lucko/spark/common/util/JavaVersionTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public void testJavaVersion() {
3636
assertEquals(9, JavaVersion.parseJavaVersion("9.0.1"));
3737
assertEquals(11, JavaVersion.parseJavaVersion("11.0.1"));
3838
assertEquals(17, JavaVersion.parseJavaVersion("17.0.1"));
39+
assertEquals(17, JavaVersion.parseJavaVersion("17-ea"));
40+
assertEquals(17, JavaVersion.parseJavaVersion("17.0.1-ea"));
3941
}
4042

4143
}

0 commit comments

Comments
 (0)