File tree Expand file tree Collapse file tree 8 files changed +31
-11
lines changed
src/main/kotlin/com/google/devtools/ksp/processing
src/main/kotlin/com/google/devtools/ksp/gradle
integration-tests/src/test/kotlin/com/google/devtools/ksp/test Expand file tree Collapse file tree 8 files changed +31
-11
lines changed Original file line number Diff line number Diff line change 11import com.google.devtools.ksp.configureMetalava
2+ import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
23import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34
45description = " Kotlin Symbol Processing API"
@@ -7,7 +8,9 @@ val signingKey: String? by project
78val signingPassword: String? by project
89
910tasks.withType<KotlinCompile > {
10- compilerOptions.freeCompilerArgs.add(" -Xjvm-default=all-compatibility" )
11+ compilerOptions {
12+ jvmDefault.set(JvmDefaultMode .ENABLE )
13+ }
1114}
1215
1316plugins {
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ interface JvmPlatformInfo : PlatformInfo {
3434 val jvmTarget: String
3535
3636 /* *
37- * JVM default mode. Correspond to `-Xjvm -default' to Kotlin compiler
37+ * JVM default mode. Correspond to `-jvm -default' to Kotlin compiler
3838 */
3939 val jvmDefaultMode: String
4040}
Original file line number Diff line number Diff line change 1+ import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
2+
13description = " Kotlin Symbol Processor"
24
35val junitVersion: String by project
@@ -30,7 +32,7 @@ val dokkaJavadocJar = tasks.register<Jar>("dokkaJavadocJar") {
3032
3133kotlin {
3234 compilerOptions {
33- freeCompilerArgs.add( " -Xjvm-default=all-compatibility " )
35+ jvmDefault.set( JvmDefaultMode . ENABLE )
3436 }
3537}
3638
Original file line number Diff line number Diff line change 1+ import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
2+
13description = " Kotlin Symbol Processing Util"
24
35val junitVersion: String by project
@@ -16,7 +18,7 @@ dependencies {
1618
1719kotlin {
1820 compilerOptions {
19- freeCompilerArgs.add( " -Xjvm-default=all-compatibility " )
21+ jvmDefault.set( JvmDefaultMode . ENABLE )
2022 }
2123}
2224
Original file line number Diff line number Diff line change 1+ import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
12import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23
34description = " Kotlin Symbol Processor"
@@ -42,7 +43,7 @@ dependencies {
4243
4344kotlin {
4445 compilerOptions {
45- freeCompilerArgs.add( " -Xjvm-default=all-compatibility " )
46+ jvmDefault.set( JvmDefaultMode . ENABLE )
4647 }
4748}
4849
Original file line number Diff line number Diff line change @@ -354,7 +354,12 @@ abstract class KspAATask @Inject constructor(
354354
355355 val oldJvmDefaultMode = compileTask.flatMap { task ->
356356 task.compilerOptions.freeCompilerArgs
357- .map { args -> args.filter { it.startsWith(" -Xjvm-default=" ) } }
357+ .map { args ->
358+ args.filter {
359+ // Support both new and deprecated arguments (-Xjvm-* is deprecated)
360+ it.startsWith(" -jvm-default=" ) || it.startsWith(" -Xjvm-default=" )
361+ }
362+ }
358363 .map { it.lastOrNull()?.substringAfter(" =" ) ? : " undefined" }
359364 }
360365
Original file line number Diff line number Diff line change @@ -309,11 +309,16 @@ class PlaygroundIT() {
309309
310310 @Test
311311 fun testJvmPlatformInfo () {
312- val kotlinCompile = " org.jetbrains.kotlin.gradle.tasks.KotlinCompile"
313312 val buildFile = File (project.root, " workload/build.gradle.kts" )
314- buildFile.appendText(" \n tasks.withType<$kotlinCompile > {" )
315- buildFile.appendText(" \n compilerOptions.freeCompilerArgs.add(\" -Xjvm-default=all\" )" )
316- buildFile.appendText(" \n }" )
313+ buildFile.appendText(
314+ """
315+ |tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
316+ | compilerOptions {
317+ | jvmDefault.set(org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode.NO_COMPATIBILITY)
318+ | }
319+ |}
320+ |""" .trimMargin()
321+ )
317322
318323 val gradleRunner = GradleRunner .create().withProjectDir(project.root)
319324 gradleRunner.buildAndCheck(" clean" , " build" ) { result ->
Original file line number Diff line number Diff line change 1+ import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
2+
13plugins {
24 kotlin(" jvm" )
35}
@@ -16,6 +18,6 @@ dependencies {
1618
1719kotlin {
1820 compilerOptions {
19- freeCompilerArgs.add( " -Xjvm-default=all-compatibility " )
21+ jvmDefault.set( JvmDefaultMode . ENABLE )
2022 }
2123}
You can’t perform that action at this time.
0 commit comments