[Gradle] Use ExtrasProperty

KT-55189
This commit is contained in:
Sebastian Sellmair
2022-12-01 11:52:58 +01:00
committed by Space Team
parent a23e4a1048
commit 4d3880879d
3 changed files with 10 additions and 15 deletions
@@ -7,8 +7,7 @@ package org.jetbrains.kotlin.gradle.idea.tcs.extras
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinBinaryDependency
import org.jetbrains.kotlin.tooling.core.extrasKeyOf
import org.jetbrains.kotlin.tooling.core.getValue
import org.jetbrains.kotlin.tooling.core.setValue
import org.jetbrains.kotlin.tooling.core.readWriteProperty
val isIdeaProjectLevelKey = extrasKeyOf<Boolean>("isIdeaProjectLevel")
@@ -16,7 +15,7 @@ val isIdeaProjectLevelKey = extrasKeyOf<Boolean>("isIdeaProjectLevel")
* Marks any binary dependency as Global in the sense of "this library is considered
* the same, no matter in which Gradle project / IntelliJ module it will be used
*/
var IdeaKotlinBinaryDependency.isIdeaProjectLevel by isIdeaProjectLevelKey
var IdeaKotlinBinaryDependency.isIdeaProjectLevel by isIdeaProjectLevelKey.readWriteProperty.notNull(false)
val isNativeDistributionKey = extrasKeyOf<Boolean>("isNativeDistribution")
@@ -25,7 +24,7 @@ val isNativeDistributionKey = extrasKeyOf<Boolean>("isNativeDistribution")
/**
* Marks this dependency as 'coming from the native distribution'
*/
var IdeaKotlinBinaryDependency.isNativeDistribution by isNativeDistributionKey
var IdeaKotlinBinaryDependency.isNativeDistribution by isNativeDistributionKey.readWriteProperty.notNull(false)
val isNativeStdlibKey = extrasKeyOf<Boolean>("isNativeStdlib")
@@ -33,4 +32,4 @@ val isNativeStdlibKey = extrasKeyOf<Boolean>("isNativeStdlib")
/**
* Marks the dependency as the native stdlib (which is special in the native distribution)
*/
var IdeaKotlinBinaryDependency.isNativeStdlib by isNativeStdlibKey
var IdeaKotlinBinaryDependency.isNativeStdlib by isNativeStdlibKey.readWriteProperty.notNull(false)
@@ -11,11 +11,10 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationConfigurationsContainer
import org.jetbrains.kotlin.gradle.utils.ObservableSet
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
import org.jetbrains.kotlin.tooling.core.MutableExtras
internal interface InternalKotlinCompilation<out T : KotlinCommonOptions> : KotlinCompilation<T> {
val extras: MutableExtras
internal interface InternalKotlinCompilation<out T : KotlinCommonOptions> : KotlinCompilation<T>, HasMutableExtras {
override val kotlinSourceSets: ObservableSet<KotlinSourceSet>
override val allKotlinSourceSets: ObservableSet<KotlinSourceSet>
@@ -15,8 +15,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.addSourcesToKotlinCompileTask
import org.jetbrains.kotlin.gradle.plugin.sources.defaultSourceSetLanguageSettingsChecker
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation
import org.jetbrains.kotlin.tooling.core.extrasFactoryProperty
import org.jetbrains.kotlin.tooling.core.extrasKeyOf
import org.jetbrains.kotlin.tooling.core.getOrPut
import java.util.concurrent.Callable
internal class KotlinCompilationSourceSetInclusion(
@@ -69,16 +69,13 @@ internal class KotlinCompilationSourceSetInclusion(
}
private companion object {
/**
* Key used to store already processed source sets on the compilation instance itself
* Used to store already processed source sets on the compilation instance itself
* to avoid re-processing of unnecessary source sets!
*/
private val includedSourceSetsKey = extrasKeyOf<MutableSet<KotlinSourceSet>>(
KotlinCompilationSourceSetInclusion::class.java.name
)
val InternalKotlinCompilation<*>.includedSourceSets: MutableSet<KotlinSourceSet>
get() = extras.getOrPut(includedSourceSetsKey, { hashSetOf() })
by extrasFactoryProperty(extrasKeyOf(KotlinCompilationSourceSetInclusion::class.java.name), { hashSetOf() })
}