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 {
|
dependencies {
|
||||||
compileOnlyConfigurationName(kotlinStdlib())
|
compileOnlyConfigurationName(kotlinStdlib())
|
||||||
"commonGradleApiCompileOnly"("dev.gradleplugins:gradle-api:7.2")
|
"commonGradleApiCompileOnly"("dev.gradleplugins:gradle-api:7.5")
|
||||||
if (this@createGradleCommonSourceSet.name != "kotlin-gradle-plugin-api" &&
|
if (this@createGradleCommonSourceSet.name != "kotlin-gradle-plugin-api" &&
|
||||||
this@createGradleCommonSourceSet.name != "android-test-fixes"
|
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.Nested
|
||||||
import org.gradle.api.tasks.OutputFile
|
import org.gradle.api.tasks.OutputFile
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import org.jetbrains.kotlin.gradle.utils.notCompatibleWithConfigurationCache
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.inject.Inject
|
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.Attribute
|
||||||
import org.gradle.api.attributes.AttributeContainer
|
import org.gradle.api.attributes.AttributeContainer
|
||||||
|
import org.gradle.api.provider.Provider
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
// TODO better implementation: attribute invariants (no attrs with same name and different types allowed), thread safety?
|
// 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 }
|
val filterParentAttributes: (Attribute<*>) -> Boolean = { true }
|
||||||
) : AttributeContainer {
|
) : AttributeContainer {
|
||||||
private val attributesMap = Collections.synchronizedMap(mutableMapOf<Attribute<*>, Any>())
|
private val attributesMap = Collections.synchronizedMap(mutableMapOf<Attribute<*>, Any>())
|
||||||
|
private val lazyAttributesMap = Collections.synchronizedMap(mutableMapOf<Attribute<*>, Provider<out Any>>())
|
||||||
|
|
||||||
private fun getFilteredParentAttribute(key: Attribute<*>) =
|
private fun getFilteredParentAttribute(key: Attribute<*>) =
|
||||||
if (parent != null && filterParentAttributes(key)) parent.getAttribute(key) else null
|
if (parent != null && filterParentAttributes(key)) parent.getAttribute(key) else null
|
||||||
|
|
||||||
override fun contains(key: Attribute<*>): Boolean =
|
override fun contains(key: Attribute<*>): Boolean =
|
||||||
attributesMap.contains(key) || getFilteredParentAttribute(key) != null
|
lazyAttributesMap.contains(key) ||
|
||||||
|
attributesMap.contains(key) ||
|
||||||
|
getFilteredParentAttribute(key) != null
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun <T : Any> getAttribute(key: Attribute<T>): T? =
|
override fun <T : Any> getAttribute(key: Attribute<T>): T? = lazyAttributesMap[key]?.get() as T?
|
||||||
attributesMap.get(key as Attribute<*>) as T? ?: getFilteredParentAttribute(key) 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 {
|
override fun <T : Any> attribute(key: Attribute<T>, value: T): AttributeContainer {
|
||||||
val checkedValue = requireNotNull(value as Any?) { "null values for attributes are not supported" }
|
val checkedValue = requireNotNull(value as Any?) { "null values for attributes are not supported" }
|
||||||
attributesMap[key] = checkedValue
|
attributesMap[key] = checkedValue
|
||||||
|
lazyAttributesMap.remove(key)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAttributes(): AttributeContainer = 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.ResolvedMetadataFilesProvider
|
||||||
import org.jetbrains.kotlin.gradle.targets.metadata.dependsOnClosureWithInterCompilationDependencies
|
import org.jetbrains.kotlin.gradle.targets.metadata.dependsOnClosureWithInterCompilationDependencies
|
||||||
import org.jetbrains.kotlin.gradle.utils.getValue
|
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 java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -36,7 +36,9 @@ open class MetadataDependencyTransformationTask
|
|||||||
) : DefaultTask() {
|
) : DefaultTask() {
|
||||||
|
|
||||||
init {
|
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
|
@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.tasks.withType
|
||||||
import org.jetbrains.kotlin.gradle.utils.filesProvider
|
import org.jetbrains.kotlin.gradle.utils.filesProvider
|
||||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
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.gradle.utils.outputFilesProvider
|
||||||
import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION
|
import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION
|
||||||
import org.jetbrains.kotlin.project.model.KpmModuleIdentifier
|
import org.jetbrains.kotlin.project.model.KpmModuleIdentifier
|
||||||
@@ -112,7 +112,9 @@ internal open class CInteropMetadataDependencyTransformationTask @Inject constru
|
|||||||
) : DefaultTask() {
|
) : DefaultTask() {
|
||||||
|
|
||||||
init {
|
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 {
|
sealed class OutputLibraryFilesDiscovery : Serializable {
|
||||||
|
|||||||
+2
-11
@@ -28,7 +28,7 @@ internal fun Project.readSystemPropertyAtConfigurationTime(key: String): Provide
|
|||||||
internal fun unavailableValueError(propertyName: String): Nothing =
|
internal fun unavailableValueError(propertyName: String): Nothing =
|
||||||
error("'$propertyName' should be available at configuration time but unavailable on configuration cache reuse")
|
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 reportConfigurationCacheWarnings = try {
|
||||||
val startParameters = project.gradle.startParameter as? StartParameterInternal
|
val startParameters = project.gradle.startParameter as? StartParameterInternal
|
||||||
startParameters?.run { isConfigurationCache && !isConfigurationCacheQuiet } ?: false
|
startParameters?.run { isConfigurationCache && !isConfigurationCacheQuiet } ?: false
|
||||||
@@ -43,14 +43,5 @@ fun Task.notCompatibleWithConfigurationCache(reason: String) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
notCompatibleWithConfigurationCache(reason)
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user