1616
1717package org .springframework .graphql .build .conventions ;
1818
19- import java .util .ArrayList ;
20- import java .util .List ;
21-
2219import org .gradle .api .Project ;
23- import org .jetbrains .kotlin .gradle .dsl .KotlinJvmOptions ;
20+ import org .jetbrains .kotlin .gradle .dsl .JvmTarget ;
21+ import org .jetbrains .kotlin .gradle .dsl .KotlinVersion ;
2422import org .jetbrains .kotlin .gradle .tasks .KotlinCompile ;
2523
2624/**
@@ -35,15 +33,19 @@ public void apply(Project project) {
3533 }
3634
3735 private void configure (KotlinCompile compile ) {
38- KotlinJvmOptions kotlinOptions = compile .getKotlinOptions ();
39- kotlinOptions .setApiVersion ("1.7" );
40- kotlinOptions .setLanguageVersion ("1.7" );
41- kotlinOptions .setJvmTarget ("17" );
42- kotlinOptions .setJavaParameters (true );
43- kotlinOptions .setAllWarningsAsErrors (true );
44- List <String > freeCompilerArgs = new ArrayList <>(compile .getKotlinOptions ().getFreeCompilerArgs ());
45- freeCompilerArgs .addAll (List .of ("-Xsuppress-version-warnings" , "-Xjsr305=strict" , "-opt-in=kotlin.RequiresOptIn" ));
46- compile .getKotlinOptions ().setFreeCompilerArgs (freeCompilerArgs );
36+ compile .compilerOptions (options -> {
37+ options .getApiVersion ().set (KotlinVersion .KOTLIN_2_1 );
38+ options .getLanguageVersion ().set (KotlinVersion .KOTLIN_2_1 );
39+ options .getJvmTarget ().set (JvmTarget .JVM_17 );
40+ options .getJavaParameters ().set (true );
41+ options .getAllWarningsAsErrors ().set (true );
42+ options .getFreeCompilerArgs ().addAll (
43+ "-Xsuppress-version-warnings" ,
44+ "-Xjsr305=strict" , // For dependencies using JSR 305
45+ "-opt-in=kotlin.RequiresOptIn" ,
46+ "-Xjdk-release=17" // Needed due to https://youtrack.jetbrains.com/issue/KT-49746
47+ );
48+ });
4749 }
4850
4951}
0 commit comments