Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off -progressive when downgrading from K2 #1615

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading