[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
This commit is contained in:
Sebastian Sellmair
2023-05-04 10:15:43 +02:00
committed by Space Team
parent b53bf4b148
commit 7910e0d32c
2 changed files with 3 additions and 5 deletions
@@ -333,8 +333,6 @@ internal interface KotlinPluginLifecycle {
val stage: Stage val stage: Stage
fun enqueue(stage: Stage, action: KotlinPluginLifecycle.() -> Unit)
fun launch(block: suspend KotlinPluginLifecycle.() -> Unit) fun launch(block: suspend KotlinPluginLifecycle.() -> Unit)
suspend fun await(stage: Stage) suspend fun await(stage: Stage)
@@ -347,7 +345,7 @@ internal interface KotlinPluginLifecycle {
Implementation Implementation
*/ */
private class KotlinPluginLifecycleImpl(override val project: Project) : KotlinPluginLifecycle { internal class KotlinPluginLifecycleImpl(override val project: Project) : KotlinPluginLifecycle {
private val enqueuedActions: Map<Stage, ArrayDeque<KotlinPluginLifecycle.() -> Unit>> = private val enqueuedActions: Map<Stage, ArrayDeque<KotlinPluginLifecycle.() -> Unit>> =
Stage.values().associateWith { ArrayDeque() } Stage.values().associateWith { ArrayDeque() }
@@ -441,7 +439,7 @@ private class KotlinPluginLifecycleImpl(override val project: Project) : KotlinP
project.configurationResultImpl.complete(ProjectConfigurationResult.Success) project.configurationResultImpl.complete(ProjectConfigurationResult.Success)
} }
override fun enqueue(stage: Stage, action: KotlinPluginLifecycle.() -> Unit) { fun enqueue(stage: Stage, action: KotlinPluginLifecycle.() -> Unit) {
if (stage < this.stage) { if (stage < this.stage) {
throw IllegalLifecycleException("Cannot enqueue Action for stage '$stage' in current stage '${this.stage}'") throw IllegalLifecycleException("Cannot enqueue Action for stage '$stage' in current stage '${this.stage}'")
} }
@@ -28,7 +28,7 @@ import kotlin.test.*
class KotlinPluginLifecycleTest { class KotlinPluginLifecycleTest {
private val project = buildProjectWithMPP() private val project = buildProjectWithMPP()
private val lifecycle = project.kotlinPluginLifecycle private val lifecycle = project.kotlinPluginLifecycle as KotlinPluginLifecycleImpl
@Test @Test
fun `test - configure phase is executed right away`() { fun `test - configure phase is executed right away`() {