Update Gradle plugins common Gradle API version to 7.5
^KT-54142 Fixed
This commit is contained in:
@@ -114,7 +114,7 @@ fun Project.createGradleCommonSourceSet(): SourceSet {
|
||||
|
||||
dependencies {
|
||||
compileOnlyConfigurationName(kotlinStdlib())
|
||||
"commonGradleApiCompileOnly"("dev.gradleplugins:gradle-api:7.2")
|
||||
"commonGradleApiCompileOnly"("dev.gradleplugins:gradle-api:7.5")
|
||||
if (this@createGradleCommonSourceSet.name != "kotlin-gradle-plugin-api" &&
|
||||
this@createGradleCommonSourceSet.name != "android-test-fixes"
|
||||
) {
|
||||
|
||||
-1
@@ -11,7 +11,6 @@ import org.gradle.api.tasks.Internal
|
||||
import org.gradle.api.tasks.Nested
|
||||
import org.gradle.api.tasks.OutputFile
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.jetbrains.kotlin.gradle.utils.notCompatibleWithConfigurationCache
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
+24
-5
@@ -17,6 +17,7 @@ package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||
|
||||
import org.gradle.api.attributes.Attribute
|
||||
import org.gradle.api.attributes.AttributeContainer
|
||||
import org.gradle.api.provider.Provider
|
||||
import java.util.*
|
||||
|
||||
// TODO better implementation: attribute invariants (no attrs with same name and different types allowed), thread safety?
|
||||
@@ -32,26 +33,44 @@ class HierarchyAttributeContainer(
|
||||
val filterParentAttributes: (Attribute<*>) -> Boolean = { true }
|
||||
) : AttributeContainer {
|
||||
private val attributesMap = Collections.synchronizedMap(mutableMapOf<Attribute<*>, Any>())
|
||||
private val lazyAttributesMap = Collections.synchronizedMap(mutableMapOf<Attribute<*>, Provider<out Any>>())
|
||||
|
||||
private fun getFilteredParentAttribute(key: Attribute<*>) =
|
||||
if (parent != null && filterParentAttributes(key)) parent.getAttribute(key) else null
|
||||
|
||||
override fun contains(key: Attribute<*>): Boolean =
|
||||
attributesMap.contains(key) || getFilteredParentAttribute(key) != null
|
||||
lazyAttributesMap.contains(key) ||
|
||||
attributesMap.contains(key) ||
|
||||
getFilteredParentAttribute(key) != null
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : Any> getAttribute(key: Attribute<T>): T? =
|
||||
attributesMap.get(key as Attribute<*>) as T? ?: getFilteredParentAttribute(key) as T?
|
||||
override fun <T : Any> getAttribute(key: Attribute<T>): T? = lazyAttributesMap[key]?.get() as T?
|
||||
?: attributesMap[key] as T?
|
||||
?: getFilteredParentAttribute(key) as T?
|
||||
|
||||
override fun isEmpty(): Boolean = attributesMap.isEmpty() && (parent?.keySet().orEmpty().filter(filterParentAttributes).isEmpty())
|
||||
override fun isEmpty(): Boolean = lazyAttributesMap.isEmpty() &&
|
||||
attributesMap.isEmpty() &&
|
||||
(parent?.keySet().orEmpty().filter(filterParentAttributes).isEmpty())
|
||||
|
||||
override fun keySet(): Set<Attribute<*>> = attributesMap.keys + parent?.keySet().orEmpty().filter(filterParentAttributes)
|
||||
override fun keySet(): Set<Attribute<*>> = lazyAttributesMap.keys +
|
||||
attributesMap.keys +
|
||||
parent?.keySet().orEmpty().filter(filterParentAttributes)
|
||||
|
||||
override fun <T : Any> attribute(key: Attribute<T>, value: T): AttributeContainer {
|
||||
val checkedValue = requireNotNull(value as Any?) { "null values for attributes are not supported" }
|
||||
attributesMap[key] = checkedValue
|
||||
lazyAttributesMap.remove(key)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun getAttributes(): AttributeContainer = this
|
||||
|
||||
override fun <T : Any> attributeProvider(
|
||||
key: Attribute<T>,
|
||||
provider: Provider<out T>
|
||||
): AttributeContainer {
|
||||
lazyAttributesMap[key] = provider
|
||||
attributesMap.remove(key)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.gradle.targets.metadata.KotlinMetadataTargetConfigur
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.ResolvedMetadataFilesProvider
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.dependsOnClosureWithInterCompilationDependencies
|
||||
import org.jetbrains.kotlin.gradle.utils.getValue
|
||||
import org.jetbrains.kotlin.gradle.utils.notCompatibleWithConfigurationCache
|
||||
import org.jetbrains.kotlin.gradle.utils.notCompatibleWithConfigurationCacheCompat
|
||||
import java.io.File
|
||||
import javax.inject.Inject
|
||||
|
||||
@@ -36,7 +36,9 @@ open class MetadataDependencyTransformationTask
|
||||
) : DefaultTask() {
|
||||
|
||||
init {
|
||||
notCompatibleWithConfigurationCache("Task $name does not support Gradle Configuration Cache. Check KT-49933 for more info")
|
||||
notCompatibleWithConfigurationCacheCompat(
|
||||
"Task $name does not support Gradle Configuration Cache. Check KT-49933 for more info"
|
||||
)
|
||||
}
|
||||
|
||||
@get:OutputDirectory
|
||||
|
||||
+4
-2
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.gradle.tasks.locateOrRegisterTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||
import org.jetbrains.kotlin.gradle.utils.filesProvider
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
import org.jetbrains.kotlin.gradle.utils.notCompatibleWithConfigurationCache
|
||||
import org.jetbrains.kotlin.gradle.utils.notCompatibleWithConfigurationCacheCompat
|
||||
import org.jetbrains.kotlin.gradle.utils.outputFilesProvider
|
||||
import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION
|
||||
import org.jetbrains.kotlin.project.model.KpmModuleIdentifier
|
||||
@@ -112,7 +112,9 @@ internal open class CInteropMetadataDependencyTransformationTask @Inject constru
|
||||
) : DefaultTask() {
|
||||
|
||||
init {
|
||||
notCompatibleWithConfigurationCache("Task $name does not support Gradle Configuration Cache. Check KT-49933 for more info")
|
||||
notCompatibleWithConfigurationCacheCompat(
|
||||
"Task $name does not support Gradle Configuration Cache. Check KT-49933 for more info"
|
||||
)
|
||||
}
|
||||
|
||||
sealed class OutputLibraryFilesDiscovery : Serializable {
|
||||
|
||||
+2
-11
@@ -28,7 +28,7 @@ internal fun Project.readSystemPropertyAtConfigurationTime(key: String): Provide
|
||||
internal fun unavailableValueError(propertyName: String): Nothing =
|
||||
error("'$propertyName' should be available at configuration time but unavailable on configuration cache reuse")
|
||||
|
||||
fun Task.notCompatibleWithConfigurationCache(reason: String) {
|
||||
fun Task.notCompatibleWithConfigurationCacheCompat(reason: String) {
|
||||
val reportConfigurationCacheWarnings = try {
|
||||
val startParameters = project.gradle.startParameter as? StartParameterInternal
|
||||
startParameters?.run { isConfigurationCache && !isConfigurationCacheQuiet } ?: false
|
||||
@@ -43,14 +43,5 @@ fun Task.notCompatibleWithConfigurationCache(reason: String) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
val taskClass = Task::class.java
|
||||
val method = taskClass.getMethod("notCompatibleWithConfigurationCache", String::class.java)
|
||||
|
||||
method.invoke(this, reason)
|
||||
} catch (e: ReflectiveOperationException) {
|
||||
if (reportConfigurationCacheWarnings) {
|
||||
logger.warn("Reflection issue - task $name is not compatible with configuration cache: $reason", e)
|
||||
}
|
||||
}
|
||||
notCompatibleWithConfigurationCache(reason)
|
||||
}
|
||||
Reference in New Issue
Block a user