Skip to content

Commit

Permalink
Don't run in afterEvaluate for min os configuration if not needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
TadeasKriz committed May 9, 2024
1 parent 81ccd8d commit 0404120
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import org.gradle.api.Project
import java.util.Properties

fun SkieTarget.configureMinOsVersionIfNeeded() {
project.kgpShim.launchScheduler.afterEvaluateOrAfterFinaliseRefinesEdges(project) {
project.kgpShim.launchScheduler.whenMinOsVersionCanBeSafelyChanged(project) {
if (!project.isCoroutinesInteropEnabled) {
return@afterEvaluateOrAfterFinaliseRefinesEdges
return@whenMinOsVersionCanBeSafelyChanged
}

val distributionProperties = getDistributionProperties()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@ import org.gradle.api.Project
interface LaunchScheduler {

/**
* KGP 1.8.0..1.8.20: behaves as `afterEvaluate`
* KGP >=1.9.0: behaves as `launchInRequiredStage(KotlinPluginLifecycle.Stage.AfterFinaliseRefinesEdges)`
* Used to safely configure `osVersionMin` and `osVersionMinSinceXcode15` properties.
* "Safely" here means "as late as possible",
* making sure we can pick up overrides defined by users (or possibly other plugins).
*
* - KGP 1.8.0..1.8.20: Checks if `project` is already evaluated,
* if so it runs `block` right away.
* Otherwise, it schedules it with `project.afterEvaluate`.
* ConfigureMinOsVersions at the time of this change already runs in `afterEvaluate`,
* so there's no need to use it again.
* It also runs inside a `configureEach` which disallows `afterEvaluate` calls.
* - KGP >=1.9.0: Always schedules it using `launchInRequiredStage(KotlinPluginLifecycle.Stage.AfterFinaliseRefinesEdges)`.
*/
fun afterEvaluateOrAfterFinaliseRefinesEdges(project: Project, block: () -> Unit)
fun whenMinOsVersionCanBeSafelyChanged(project: Project, block: () -> Unit)

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import org.gradle.api.Project

class LaunchSchedulerImpl : LaunchScheduler {

override fun afterEvaluateOrAfterFinaliseRefinesEdges(project: Project, block: () -> Unit) {
project.afterEvaluate {
override fun whenMinOsVersionCanBeSafelyChanged(project: Project, block: () -> Unit) {
if (project.state.executed) {
block()
} else {
project.afterEvaluate {
block()
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.jetbrains.kotlin.gradle.plugin.launchInRequiredStage

class LaunchSchedulerImpl : LaunchScheduler {

override fun afterEvaluateOrAfterFinaliseRefinesEdges(project: Project, block: () -> Unit) {
override fun whenMinOsVersionCanBeSafelyChanged(project: Project, block: () -> Unit) {
project.launchInRequiredStage(KotlinPluginLifecycle.Stage.AfterFinaliseRefinesEdges) {
block()
}
Expand Down
2 changes: 1 addition & 1 deletion test-runner/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ testing {
maxHeapSize = "4024m"
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)

dependsOn(publishSkieToTempMaven)
inputs.files(publishSkieToTempMaven)

systemProperty("smokeTestRepository", smokeTestRepository.get().asFile.absolutePath)
systemProperty("junit.platform.reporting.open.xml.enabled", "true")
Expand Down

0 comments on commit 0404120

Please sign in to comment.