1
1
/*
2
- * Copyright 2002-2022 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
17
17
package org .springframework .build ;
18
18
19
- import java .util .ArrayList ;
20
- import java .util .List ;
21
-
22
19
import 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 ;
24
22
import org .jetbrains .kotlin .gradle .tasks .KotlinCompile ;
25
23
26
24
/**
27
25
* @author Brian Clozel
26
+ * @author Sebastien Deleuze
28
27
*/
29
28
public class KotlinConventions {
30
29
@@ -34,15 +33,14 @@ void apply(Project project) {
34
33
}
35
34
36
35
private void configure (KotlinCompile compile ) {
37
- KotlinJvmOptions kotlinOptions = compile .getKotlinOptions ();
38
- kotlinOptions .setApiVersion ("1.7" );
39
- kotlinOptions .setLanguageVersion ("1.7" );
40
- kotlinOptions .setJvmTarget ("17" );
41
- kotlinOptions .setJavaParameters (true );
42
- kotlinOptions .setAllWarningsAsErrors (true );
43
- List <String > freeCompilerArgs = new ArrayList <>(compile .getKotlinOptions ().getFreeCompilerArgs ());
44
- freeCompilerArgs .addAll (List .of ("-Xsuppress-version-warnings" , "-Xjsr305=strict" , "-opt-in=kotlin.RequiresOptIn" ));
45
- 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 ("-Xsuppress-version-warnings" , "-Xjsr305=strict" , "-opt-in=kotlin.RequiresOptIn" );
43
+ });
46
44
}
47
45
48
46
}
0 commit comments