Skip to content

Commit

Permalink
Turn off -progressive when downgrading from K2
Browse files Browse the repository at this point in the history
Progressive mode should always be used with latest language version.
  • Loading branch information
ting-yuan committed Nov 22, 2023
1 parent 8417548 commit 591bf5e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
fun configureLanguageVersion(kspTask: KotlinCompilationTask<*>) {
kspTask.compilerOptions.useK2.value(false)
val languageVersion = kotlinCompilation.compilerOptions.options.languageVersion
val progressiveMode = kotlinCompilation.compilerOptions.options.progressiveMode
kspTask.compilerOptions.languageVersion.value(
project.provider {
languageVersion.orNull?.let { version ->
Expand All @@ -377,6 +378,18 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool
} ?: KotlinVersion.KOTLIN_1_9
}
)

// Turn off progressive mode if we need to downgrade language version.
kspTask.compilerOptions.progressiveMode.value(
project.provider {
val compileLangVer = languageVersion.orNull ?: KotlinVersion.DEFAULT
if (compileLangVer >= KotlinVersion.KOTLIN_2_0) {
false
} else {
progressiveMode.orNull
}
}
)
}

val isIncremental = project.findProperty("ksp.incremental")?.toString()?.toBoolean() ?: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,24 @@ class PlaygroundIT(val useKSP2: Boolean) {
project.restore(properties.path)
}

@Test
fun testProgressiveMode() {
val buildFile = File(project.root, "workload/build.gradle.kts")
buildFile.appendText(
"""
kotlin {
compilerOptions {
allWarningsAsErrors.value(true)
progressiveMode.value(true)
}
}
""".trimIndent()
)
val gradleRunner = GradleRunner.create().withProjectDir(project.root).withGradleVersion("8.0")
gradleRunner.withArguments("clean", "build").build()
project.restore(buildFile.path)
}

companion object {
@JvmStatic
@Parameterized.Parameters(name = "KSP2={0}")
Expand Down

0 comments on commit 591bf5e

Please sign in to comment.