[Gradle] KotlinPluginLifecycle: Rename .configured to .configurationResult

^KT-58255 Verification Pending
This commit is contained in:
Sebastian Sellmair
2023-05-04 10:18:41 +02:00
committed by Space Team
parent 08055b6188
commit b437c3e0e9
3 changed files with 16 additions and 14 deletions
@@ -137,7 +137,7 @@ internal val Project.kotlinPluginLifecycle: KotlinPluginLifecycle
* will lead to:
* ```kotlin
* project.launch {
* val result = project.configured.await()
* val result = project.configurationResult.await()
* val result as Failure
* val exception = result.failures.first()
* println(exception.message) // 'My Error'
@@ -149,7 +149,7 @@ internal val Project.kotlinPluginLifecycle: KotlinPluginLifecycle
* Even in case of failure it is still okay to further launch a new coroutine
* ```kotlin
* project.launch {
* val result = project.configured.await() as Failure
* val result = project.configurationResult.await() as Failure
* val anotherJob = project.launch { ... } // <- executed right away
* val someFutureEvaluation = project.someFuture.getOrThrow() // <- will return value if all 'requirements' have been met.
* }
@@ -158,12 +158,12 @@ internal val Project.kotlinPluginLifecycle: KotlinPluginLifecycle
* Note: [Future.getOrThrow] will throw if e.g. the lifecycle fails in a very early stage, but the Future requires
* some later data to be available. In this case, the Future still will only return 'sane' data.
*/
internal val Project.configured: Future<ProjectConfigurationResult>
get() = configuredImpl
internal val Project.configurationResult: Future<ProjectConfigurationResult>
get() = configurationResultImpl
private val Project.configuredImpl: CompletableFuture<ProjectConfigurationResult>
get() = extraProperties.getOrPut("org.jetbrains.kotlin.gradle.plugin.configured") { CompletableFuture() }
private val Project.configurationResultImpl: CompletableFuture<ProjectConfigurationResult>
get() = extraProperties.getOrPut("org.jetbrains.kotlin.gradle.plugin.configurationResult") { CompletableFuture() }
/**
@@ -505,13 +505,13 @@ private class KotlinPluginLifecycleImpl(override val project: Project) : KotlinP
assert(failures.isNotEmpty())
assert(isStarted.get())
assert(!isFinishedWithFailures.getAndSet(true))
project.configuredImpl.complete(ProjectConfigurationResult.Failure(failures))
project.configurationResultImpl.complete(ProjectConfigurationResult.Failure(failures))
}
private fun finishSuccessfully() {
assert(isStarted.get())
assert(!isFinishedSuccessfully.getAndSet(true))
project.configuredImpl.complete(ProjectConfigurationResult.Success)
project.configurationResultImpl.complete(ProjectConfigurationResult.Success)
}
override fun enqueue(stage: Stage, action: KotlinPluginLifecycle.() -> Unit) {
@@ -258,7 +258,7 @@ abstract class KotlinBasePluginWrapper : DefaultKotlinBasePlugin() {
private fun Project.launchDiagnosticChecksAndReporting() {
project.launchKotlinGradleProjectCheckers()
project.launch {
project.configured.await()
project.configurationResult.await()
renderReportedDiagnostics(
project.kotlinToolingDiagnosticsCollector.getDiagnosticsForProject(project),
project.logger,
@@ -214,7 +214,8 @@ class KotlinPluginLifecycleTest {
fail("AfterEvaluate based stage is not expected to be launched because of exception during .evaluate()", throwable)
}
val exceptions = project.configured.getOrThrow().cast<Failure>().failures.withClosure<Throwable> { listOfNotNull(it.cause) }
val exceptions = project.configurationResult.getOrThrow().cast<Failure>()
.failures.withClosure<Throwable> { listOfNotNull(it.cause) }
if (thrownException !in exceptions) fail("Expected 'thrownException' in lifecycle.finished")
}
@@ -224,7 +225,8 @@ class KotlinPluginLifecycleTest {
val executedAfterLifecycleFinished = AtomicBoolean(false)
project.launch {
val exceptions = project.configured.await().cast<Failure>().failures.withClosure<Throwable> { listOfNotNull(it.cause) }
val exceptions = project.configurationResult.await().cast<Failure>()
.failures.withClosure<Throwable> { listOfNotNull(it.cause) }
assertFalse(executedAfterLifecycleFinished.getAndSet(true))
if (thrownException !in exceptions) fail("Expected 'thrownException' in lifecycle.finished")
}
@@ -252,7 +254,7 @@ class KotlinPluginLifecycleTest {
}
project.launch secondAction@{
project.configured.await()
project.configurationResult.await()
assertEquals(AfterEvaluateBuildscript, stage)
assertEquals(42, future.getOrThrow())
assertEquals(420, project.future { AfterEvaluateBuildscript.await(); 420 }.getOrThrow())
@@ -280,14 +282,14 @@ class KotlinPluginLifecycleTest {
}
project.launch {
project.configured.await()
project.configurationResult.await()
project.launchInStage(AfterEvaluateBuildscript.nextOrThrow) thirdAction@{
assertFalse(thirdActionExecuted.getAndSet(true))
}
}
project.launch fourthAction@{
project.configured.await()
project.configurationResult.await()
AfterEvaluateBuildscript.nextOrThrow.await()
assertFalse(fourthActionExecuted.getAndSet(true))
}