[Gradle] Use ExtrasProperty
KT-55189
This commit is contained in:
committed by
Space Team
parent
a23e4a1048
commit
4d3880879d
+4
-5
@@ -7,8 +7,7 @@ package org.jetbrains.kotlin.gradle.idea.tcs.extras
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinBinaryDependency
|
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinBinaryDependency
|
||||||
import org.jetbrains.kotlin.tooling.core.extrasKeyOf
|
import org.jetbrains.kotlin.tooling.core.extrasKeyOf
|
||||||
import org.jetbrains.kotlin.tooling.core.getValue
|
import org.jetbrains.kotlin.tooling.core.readWriteProperty
|
||||||
import org.jetbrains.kotlin.tooling.core.setValue
|
|
||||||
|
|
||||||
val isIdeaProjectLevelKey = extrasKeyOf<Boolean>("isIdeaProjectLevel")
|
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
|
* 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
|
* 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")
|
val isNativeDistributionKey = extrasKeyOf<Boolean>("isNativeDistribution")
|
||||||
@@ -25,7 +24,7 @@ val isNativeDistributionKey = extrasKeyOf<Boolean>("isNativeDistribution")
|
|||||||
/**
|
/**
|
||||||
* Marks this dependency as 'coming from the native distribution'
|
* 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")
|
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)
|
* 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)
|
||||||
+2
-3
@@ -11,11 +11,10 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationConfigurationsContainer
|
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationConfigurationsContainer
|
||||||
import org.jetbrains.kotlin.gradle.utils.ObservableSet
|
import org.jetbrains.kotlin.gradle.utils.ObservableSet
|
||||||
|
import org.jetbrains.kotlin.tooling.core.HasMutableExtras
|
||||||
import org.jetbrains.kotlin.tooling.core.MutableExtras
|
import org.jetbrains.kotlin.tooling.core.MutableExtras
|
||||||
|
|
||||||
internal interface InternalKotlinCompilation<out T : KotlinCommonOptions> : KotlinCompilation<T> {
|
internal interface InternalKotlinCompilation<out T : KotlinCommonOptions> : KotlinCompilation<T>, HasMutableExtras {
|
||||||
val extras: MutableExtras
|
|
||||||
|
|
||||||
override val kotlinSourceSets: ObservableSet<KotlinSourceSet>
|
override val kotlinSourceSets: ObservableSet<KotlinSourceSet>
|
||||||
override val allKotlinSourceSets: ObservableSet<KotlinSourceSet>
|
override val allKotlinSourceSets: ObservableSet<KotlinSourceSet>
|
||||||
|
|
||||||
|
|||||||
+4
-7
@@ -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.plugin.sources.defaultSourceSetLanguageSettingsChecker
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
||||||
import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation
|
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.extrasKeyOf
|
||||||
import org.jetbrains.kotlin.tooling.core.getOrPut
|
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
internal class KotlinCompilationSourceSetInclusion(
|
internal class KotlinCompilationSourceSetInclusion(
|
||||||
@@ -69,16 +69,13 @@ internal class KotlinCompilationSourceSetInclusion(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
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!
|
* to avoid re-processing of unnecessary source sets!
|
||||||
*/
|
*/
|
||||||
private val includedSourceSetsKey = extrasKeyOf<MutableSet<KotlinSourceSet>>(
|
|
||||||
KotlinCompilationSourceSetInclusion::class.java.name
|
|
||||||
)
|
|
||||||
|
|
||||||
val InternalKotlinCompilation<*>.includedSourceSets: MutableSet<KotlinSourceSet>
|
val InternalKotlinCompilation<*>.includedSourceSets: MutableSet<KotlinSourceSet>
|
||||||
get() = extras.getOrPut(includedSourceSetsKey, { hashSetOf() })
|
by extrasFactoryProperty(extrasKeyOf(KotlinCompilationSourceSetInclusion::class.java.name), { hashSetOf() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user