Skip to content

Commit

Permalink
Add support for Java 23
Browse files Browse the repository at this point in the history
Closes gh-1585
  • Loading branch information
mhalbritter committed Sep 19, 2024
1 parent d199bc6 commit e1eeda3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import io.spring.initializr.generator.project.MutableProjectDescription;
import io.spring.initializr.generator.project.ProjectDescriptionCustomizer;
import io.spring.initializr.generator.version.Version;
import io.spring.initializr.generator.version.VersionParser;
import io.spring.initializr.generator.version.VersionRange;

/**
* Validate that the requested java version is compatible with the chosen Spring Boot
Expand All @@ -37,8 +35,6 @@
*/
public class JavaVersionProjectDescriptionCustomizer implements ProjectDescriptionCustomizer {

private static final VersionRange SPRING_BOOT_3_2_4_OR_LATER = VersionParser.DEFAULT.parseRange("3.2.4");

private static final List<String> UNSUPPORTED_VERSIONS = Arrays.asList("1.6", "1.7", "1.8");

@Override
Expand All @@ -56,13 +52,9 @@ public void customize(MutableProjectDescription description) {
if (javaGeneration < 17) {
updateTo(description, "17");
}
if (javaGeneration == 22) {
// Java 21 support as of Spring Boot 3.2.4
if (!SPRING_BOOT_3_2_4_OR_LATER.match(platformVersion)) {
updateTo(description, "21");
}
if (javaGeneration >= 22) {
if (isKotlin(description)) {
// Kotlin 1.9.x doesn't support Java 22
// Kotlin 1.9.x doesn't support Java > 21
updateTo(description, "21");
}
}
Expand All @@ -80,7 +72,7 @@ private void updateTo(MutableProjectDescription description, String jvmVersion)
private Integer determineJavaGeneration(String javaVersion) {
try {
int generation = Integer.parseInt(javaVersion);
return ((generation > 9 && generation <= 22) ? generation : null);
return ((generation > 9 && generation <= 23) ? generation : null);
}
catch (NumberFormatException ex) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion start-site/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,7 @@ initializr:
id: war
default: false
javaVersions:
- id: 22
- id: 23
default: false
- id: 21
default: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ void gradleGroovyBuildWithSupportedOptionsDoesNotDowngradeJavaVersion(String lan
}

@Test
void java22IsNotSupportedWithBoot323() {
assertThat(mavenPom(javaProject("22", "3.2.3"))).hasProperty("java.version", "21");
void java22IsNotSupportedWithKotlin() {
assertThat(mavenPom(kotlinProject("22", "3.2.9"))).hasProperty("java.version", "21");
}

@Test
void java22IsNotSupportedWithKotlin() {
assertThat(mavenPom(kotlinProject("22", "3.2.5"))).hasProperty("java.version", "21");
void java23IsNotSupportedWithKotlin() {
assertThat(mavenPom(kotlinProject("23", "3.2.9"))).hasProperty("java.version", "21");
}

static Stream<Arguments> supportedMavenParameters() {
Expand All @@ -81,17 +81,16 @@ static Stream<Arguments> supportedGradleGroovyParameters() {
}

private static Stream<Arguments> supportedJavaParameters() {
return Stream.of(java("17", "3.2.0"), java("21", "3.2.0"), java("22", "3.2.4"), java("17", "3.3.0"),
java("21", "3.3.0"), java("22", "3.3.0"));
return Stream.of(java("17", "3.2.0"), java("21", "3.2.0"), java("23", "3.2.9"), java("17", "3.3.0"),
java("21", "3.3.0"), java("23", "3.3.0"));
}

private static Stream<Arguments> supportedKotlinParameters() {
return Stream.of(kotlin("21", "3.2.0"), kotlin("21", "3.3.0"));
}

private static Stream<Arguments> supportedGroovyParameters() {
return Stream.of(groovy("21", "3.2.0"), groovy("22", "3.2.4"), groovy("21", "3.3.0-M2"),
groovy("22", "3.3.0-M3"));
return Stream.of(groovy("21", "3.2.0"), groovy("23", "3.2.9"), groovy("21", "3.3.0-M2"), groovy("23", "3.3.0"));
}

private static Arguments java(String javaVersion, String springBootVersion) {
Expand Down

0 comments on commit e1eeda3

Please sign in to comment.