From 7910e0d32ce2439f7a098cd097b6288727ae3aae Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Thu, 4 May 2023 10:15:43 +0200 Subject: [PATCH] [Gradle] KotlinPluginLifecycle: Demote .enqueue to implementation As .launch shall be the only entry point for running code within the context of the KotlinPluginLifecycle ^KT-58255 Verification Pending --- .../jetbrains/kotlin/gradle/plugin/KotlinPluginLifecycle.kt | 6 ++---- .../kotlin/gradle/unitTests/KotlinPluginLifecycleTest.kt | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginLifecycle.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginLifecycle.kt index 518d5d98304..b0485bd1539 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginLifecycle.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPluginLifecycle.kt @@ -333,8 +333,6 @@ internal interface KotlinPluginLifecycle { val stage: Stage - fun enqueue(stage: Stage, action: KotlinPluginLifecycle.() -> Unit) - fun launch(block: suspend KotlinPluginLifecycle.() -> Unit) suspend fun await(stage: Stage) @@ -347,7 +345,7 @@ internal interface KotlinPluginLifecycle { Implementation */ -private class KotlinPluginLifecycleImpl(override val project: Project) : KotlinPluginLifecycle { +internal class KotlinPluginLifecycleImpl(override val project: Project) : KotlinPluginLifecycle { private val enqueuedActions: Map Unit>> = Stage.values().associateWith { ArrayDeque() } @@ -441,7 +439,7 @@ private class KotlinPluginLifecycleImpl(override val project: Project) : KotlinP project.configurationResultImpl.complete(ProjectConfigurationResult.Success) } - override fun enqueue(stage: Stage, action: KotlinPluginLifecycle.() -> Unit) { + fun enqueue(stage: Stage, action: KotlinPluginLifecycle.() -> Unit) { if (stage < this.stage) { throw IllegalLifecycleException("Cannot enqueue Action for stage '$stage' in current stage '${this.stage}'") } diff --git a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/KotlinPluginLifecycleTest.kt b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/KotlinPluginLifecycleTest.kt index 0739c0ee0f0..b8227ca0d17 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/KotlinPluginLifecycleTest.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/functionalTest/kotlin/org/jetbrains/kotlin/gradle/unitTests/KotlinPluginLifecycleTest.kt @@ -28,7 +28,7 @@ import kotlin.test.* class KotlinPluginLifecycleTest { private val project = buildProjectWithMPP() - private val lifecycle = project.kotlinPluginLifecycle + private val lifecycle = project.kotlinPluginLifecycle as KotlinPluginLifecycleImpl @Test fun `test - configure phase is executed right away`() {