Drop leftovers usages 'forUseAtConfigurationTime'

This commit is contained in:
Yahor Berdnikau
2023-02-09 21:02:14 +01:00
committed by Space Team
parent 7819e2bf54
commit db9c440e90
2 changed files with 25 additions and 14 deletions
@@ -1,4 +1,5 @@
import java.net.URI import java.net.URI
import org.gradle.util.GradleVersion
/* /*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
@@ -10,10 +11,18 @@ import java.net.URI
// apply from: 'cache-redirector.settings.gradle.kts' // apply from: 'cache-redirector.settings.gradle.kts'
// } // }
// This script is also being used in the Gradle integration tests which runs older Gradle versions
fun <T : Any> Provider<T>.forUseAtConfigurationTimeCompat(): Provider<T> =
if (GradleVersion.current() < GradleVersion.version("7.4")) {
forUseAtConfigurationTime()
} else {
this
}
internal val Settings.cacheRedirectorEnabled: Provider<Boolean> internal val Settings.cacheRedirectorEnabled: Provider<Boolean>
get() = providers get() = providers
.gradleProperty("cacheRedirectorEnabled") .gradleProperty("cacheRedirectorEnabled")
.forUseAtConfigurationTime() .forUseAtConfigurationTimeCompat()
.map { it.toBoolean() } .map { it.toBoolean() }
.orElse(false) .orElse(false)
@@ -151,9 +160,11 @@ fun Project.overrideNativeCompilerDownloadUrl() {
fun Project.addCheckRepositoriesTask() { fun Project.addCheckRepositoriesTask() {
val checkRepoTask = tasks.register("checkRepositories") { val checkRepoTask = tasks.register("checkRepositories") {
val isTeamcityBuildInput = providers.provider { val isTeamcityBuildInput = providers
project.hasProperty("teamcity") || System.getenv("TEAMCITY_VERSION") != null .provider {
}.forUseAtConfigurationTime() project.hasProperty("teamcity") || System.getenv("TEAMCITY_VERSION") != null
}
.forUseAtConfigurationTimeCompat()
doLast { doLast {
val testName = "$name in ${project.displayName}" val testName = "$name in ${project.displayName}"
@@ -101,14 +101,14 @@ private val localProperties = providers.of(PropertiesValueSource::class.java) {
fileName.set("local.properties") fileName.set("local.properties")
rootDir.set(kotlinRootDir) rootDir.set(kotlinRootDir)
} }
}.forUseAtConfigurationTime() }
private val rootGradleProperties = providers.of(PropertiesValueSource::class.java) { private val rootGradleProperties = providers.of(PropertiesValueSource::class.java) {
parameters { parameters {
fileName.set("gradle.properties") fileName.set("gradle.properties")
rootDir.set(kotlinRootDir) rootDir.set(kotlinRootDir)
} }
}.forUseAtConfigurationTime() }
fun loadLocalOrGradleProperty( fun loadLocalOrGradleProperty(
propertyName: String propertyName: String
@@ -116,13 +116,13 @@ fun loadLocalOrGradleProperty(
// Workaround for https://github.com/gradle/gradle/issues/19114 // Workaround for https://github.com/gradle/gradle/issues/19114
// as in the includedBuild GradleProperties are empty on configuration cache reuse // as in the includedBuild GradleProperties are empty on configuration cache reuse
return if ((gradle as GradleInternal).isRootBuild()) { return if ((gradle as GradleInternal).isRootBuild()) {
localProperties.map { it.getProperty(propertyName) }.forUseAtConfigurationTime() localProperties.map { it.getProperty(propertyName) }
.orElse(providers.gradleProperty(propertyName).forUseAtConfigurationTime()) .orElse(providers.gradleProperty(propertyName))
.orElse(rootGradleProperties.map { it.getProperty(propertyName) }.forUseAtConfigurationTime()) .orElse(rootGradleProperties.map { it.getProperty(propertyName) })
} else { } else {
localProperties.map { it.getProperty(propertyName) }.forUseAtConfigurationTime() localProperties.map { it.getProperty(propertyName) }
.orElse(rootSettings.providers.gradleProperty(propertyName).forUseAtConfigurationTime()) .orElse(rootSettings.providers.gradleProperty(propertyName))
.orElse(rootGradleProperties.map { it.getProperty(propertyName) }.forUseAtConfigurationTime()) .orElse(rootGradleProperties.map { it.getProperty(propertyName) })
} }
} }
@@ -218,7 +218,7 @@ fun Settings.applyBootstrapConfiguration(
} }
val isLocalBootstrapEnabled: Provider<Boolean> = loadLocalOrGradleProperty(Config.LOCAL_BOOTSTRAP) val isLocalBootstrapEnabled: Provider<Boolean> = loadLocalOrGradleProperty(Config.LOCAL_BOOTSTRAP)
.mapToBoolean().orElse(false).forUseAtConfigurationTime() .mapToBoolean().orElse(false)
val localBootstrapVersion: Provider<String> = loadLocalOrGradleProperty(Config.LOCAL_BOOTSTRAP_VERSION) val localBootstrapVersion: Provider<String> = loadLocalOrGradleProperty(Config.LOCAL_BOOTSTRAP_VERSION)
.orElse(loadLocalOrGradleProperty(Config.DEFAULT_SNAPSHOT_VERSION)) .orElse(loadLocalOrGradleProperty(Config.DEFAULT_SNAPSHOT_VERSION))
@@ -232,7 +232,7 @@ val customBootstrapVersion = loadLocalOrGradleProperty(Config.CUSTOM_BOOTSTRAP_V
val customBootstrapRepo = loadLocalOrGradleProperty(Config.CUSTOM_BOOTSTRAP_REPO) val customBootstrapRepo = loadLocalOrGradleProperty(Config.CUSTOM_BOOTSTRAP_REPO)
val defaultBootstrapVersion = loadLocalOrGradleProperty(Config.DEFAULT_BOOTSTRAP_VERSION) val defaultBootstrapVersion = loadLocalOrGradleProperty(Config.DEFAULT_BOOTSTRAP_VERSION)
val isJpsBuildEnabled = loadLocalOrGradleProperty(Config.IS_JPS_BUILD_ENABLED) val isJpsBuildEnabled = loadLocalOrGradleProperty(Config.IS_JPS_BUILD_ENABLED)
.mapToBoolean().orElse(false).forUseAtConfigurationTime() .mapToBoolean().orElse(false)
var Project.bootstrapKotlinVersion: String var Project.bootstrapKotlinVersion: String
get() = property(Config.PROJECT_KOTLIN_VERSION) as String get() = property(Config.PROJECT_KOTLIN_VERSION) as String