[Gradle] Rename KotlinExtensionPoint to KotlinGradlePluginExtensionPoint

KT-61634
This commit is contained in:
Sebastian Sellmair
2023-10-10 10:17:48 +02:00
committed by Space Team
parent d471a5ed4a
commit 4c15509776
7 changed files with 21 additions and 26 deletions
@@ -896,7 +896,7 @@ public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinExecuti
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinExecution$ExecutionSource { public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinExecution$ExecutionSource {
} }
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinExtensionPoint { public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinGradlePluginExtensionPoint {
public abstract fun get (Lorg/gradle/api/Project;)Ljava/util/List; public abstract fun get (Lorg/gradle/api/Project;)Ljava/util/List;
public abstract fun register (Lorg/gradle/api/Project;Ljava/lang/Object;)V public abstract fun register (Lorg/gradle/api/Project;Ljava/lang/Object;)V
} }
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
* Note: Not stable for implementation: Custom implementations of this interface will not be supported by the Kotlin Gradle Plugin! * Note: Not stable for implementation: Custom implementations of this interface will not be supported by the Kotlin Gradle Plugin!
* *
* #### Motivation * #### Motivation
* This [KotlinExtensionPoint] will be used to 'generically' extend parts of the Kotlin Gradle Plugin (internally and externally). * This [KotlinGradlePluginExtensionPoint] will be used to 'generically' extend parts of the Kotlin Gradle Plugin (internally and externally).
* General Kotlin Gradle Plugin code will call into this 'semantically' structured extension points to load logic * General Kotlin Gradle Plugin code will call into this 'semantically' structured extension points to load logic
* Such extension points are to be used for public as well as for internal extension points. * Such extension points are to be used for public as well as for internal extension points.
* *
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
* [org.jetbrains.kotlin.gradle.plugin.registerKotlinPluginExtensions] entry point. * [org.jetbrains.kotlin.gradle.plugin.registerKotlinPluginExtensions] entry point.
*/ */
@ExperimentalKotlinGradlePluginApi @ExperimentalKotlinGradlePluginApi
interface KotlinExtensionPoint<T> { interface KotlinGradlePluginExtensionPoint<T> {
/** /**
* @return all currently registered extension points. * @return all currently registered extension points.
* The returned list is *not* live and just represents the current snapshot. * The returned list is *not* live and just represents the current snapshot.
@@ -10,20 +10,20 @@ import org.jetbrains.kotlin.gradle.utils.storedProjectProperty
import org.jetbrains.kotlin.tooling.core.UnsafeApi import org.jetbrains.kotlin.tooling.core.UnsafeApi
/** /**
* Creates a new [KotlinExtensionPoint] * Creates a new [KotlinGradlePluginExtensionPoint]
* See [KotlinExtensionPoint] documentation for the intended usage! * See [KotlinGradlePluginExtensionPoint] documentation for the intended usage!
*/ */
internal fun <T> KotlinExtensionPoint(): KotlinExtensionPoint<T> { internal fun <T> KotlinGradlePluginExtensionPoint(): KotlinGradlePluginExtensionPoint<T> {
@OptIn(UnsafeApi::class) @OptIn(UnsafeApi::class)
return KotlinExtensionPointInternal() return KotlinGradlePluginExtensionPointInternal()
} }
/** /**
* Only intended implementation of [KotlinExtensionPoint]! * Only intended implementation of [KotlinGradlePluginExtensionPoint]!
* Visible for tests to allow test utils to overwrite certain extension points * Visible for tests to allow test utils to overwrite certain extension points
*/ */
@UnsafeApi("Visible for tests only") @UnsafeApi("Visible for tests only")
internal class KotlinExtensionPointInternal<T> : KotlinExtensionPoint<T> { internal class KotlinGradlePluginExtensionPointInternal<T> : KotlinGradlePluginExtensionPoint<T> {
private val Project.registeredExtensions by storedProjectProperty<MutableList<T>> { mutableListOf() } private val Project.registeredExtensions by storedProjectProperty<MutableList<T>> { mutableListOf() }
@@ -7,14 +7,10 @@ package org.jetbrains.kotlin.gradle.plugin.diagnostics
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.dsl.AndroidMainSourceSetConventionsChecker
import org.jetbrains.kotlin.gradle.dsl.IosSourceSetConventionChecker
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.PlatformSourceSetConventionsChecker import org.jetbrains.kotlin.gradle.plugin.KotlinGradlePluginExtensionPoint
import org.jetbrains.kotlin.gradle.plugin.KotlinExtensionPoint
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.*
/** /**
* Interface for generic checks of a Gradle Project with any Kotlin Gradle Plugin applied. * Interface for generic checks of a Gradle Project with any Kotlin Gradle Plugin applied.
@@ -97,7 +93,7 @@ internal interface KotlinGradleProjectChecker {
suspend fun KotlinGradleProjectCheckerContext.runChecks(collector: KotlinToolingDiagnosticsCollector) suspend fun KotlinGradleProjectCheckerContext.runChecks(collector: KotlinToolingDiagnosticsCollector)
companion object { companion object {
val extensionPoint = KotlinExtensionPoint<KotlinGradleProjectChecker>() val extensionPoint = KotlinGradlePluginExtensionPoint<KotlinGradleProjectChecker>()
} }
} }
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.gradle.dsl.AndroidMainSourceSetConventionsChecker
import org.jetbrains.kotlin.gradle.dsl.IosSourceSetConventionChecker import org.jetbrains.kotlin.gradle.dsl.IosSourceSetConventionChecker
import org.jetbrains.kotlin.gradle.dsl.PlatformSourceSetConventionsChecker import org.jetbrains.kotlin.gradle.dsl.PlatformSourceSetConventionsChecker
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectChecker import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinGradleProjectChecker
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.*
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.AndroidPluginWithoutAndroidTargetChecker import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.AndroidPluginWithoutAndroidTargetChecker
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.AndroidSourceSetLayoutV1SourceSetsNotFoundChecker import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.AndroidSourceSetLayoutV1SourceSetsNotFoundChecker
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.CommonMainOrTestWithDependsOnChecker import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.CommonMainOrTestWithDependsOnChecker
@@ -29,7 +28,7 @@ import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.UnusedSourceSetsC
import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.WasmSourceSetsNotFoundChecker import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.WasmSourceSetsNotFoundChecker
/** /**
* Active Extensions (using the [KotlinExtensionPoint] infrastructure) will be registered here by the Kotlin Gradle Plugin. * Active Extensions (using the [KotlinGradlePluginExtensionPoint] infrastructure) will be registered here by the Kotlin Gradle Plugin.
*/ */
internal fun Project.registerKotlinPluginExtensions() { internal fun Project.registerKotlinPluginExtensions() {
KotlinGradleProjectChecker.extensionPoint.apply { KotlinGradleProjectChecker.extensionPoint.apply {
@@ -9,15 +9,15 @@ package org.jetbrains.kotlin.gradle.unitTests
import org.jetbrains.kotlin.gradle.util.buildProject import org.jetbrains.kotlin.gradle.util.buildProject
import org.jetbrains.kotlin.gradle.util.set import org.jetbrains.kotlin.gradle.util.set
import org.jetbrains.kotlin.gradle.plugin.KotlinExtensionPoint import org.jetbrains.kotlin.gradle.plugin.KotlinGradlePluginExtensionPoint
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
class KotlinExtensionPointTest { class KotlinGradlePluginExtensionPointTest {
@Test @Test
fun `test - simple extension point`() { fun `test - simple extension point`() {
val extensionPoint = KotlinExtensionPoint<String>() val extensionPoint = KotlinGradlePluginExtensionPoint<String>()
val projectA = buildProject() val projectA = buildProject()
val projectB = buildProject() val projectB = buildProject()
@@ -33,7 +33,7 @@ class KotlinExtensionPointTest {
@Test @Test
fun `test - overwrite`() { fun `test - overwrite`() {
val extensionPoint = KotlinExtensionPoint<Int>() val extensionPoint = KotlinGradlePluginExtensionPoint<Int>()
val project = buildProject() val project = buildProject()
extensionPoint.register(project, 0) extensionPoint.register(project, 0)
@@ -6,15 +6,15 @@
package org.jetbrains.kotlin.gradle.util package org.jetbrains.kotlin.gradle.util
import org.gradle.api.Project import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.plugin.KotlinExtensionPoint import org.jetbrains.kotlin.gradle.plugin.KotlinGradlePluginExtensionPoint
import org.jetbrains.kotlin.gradle.plugin.KotlinExtensionPointInternal import org.jetbrains.kotlin.gradle.plugin.KotlinGradlePluginExtensionPointInternal
import org.jetbrains.kotlin.tooling.core.UnsafeApi import org.jetbrains.kotlin.tooling.core.UnsafeApi
/** /**
* Completely overwrites the currently registered extensions on this [KotlinExtensionPoint] in this project. * Completely overwrites the currently registered extensions on this [KotlinGradlePluginExtensionPoint] in this project.
*/ */
@OptIn(UnsafeApi::class) @OptIn(UnsafeApi::class)
operator fun <T> KotlinExtensionPoint<T>.set(project: Project, extensions: List<T>) { operator fun <T> KotlinGradlePluginExtensionPoint<T>.set(project: Project, extensions: List<T>) {
(this as KotlinExtensionPointInternal<T>) (this as KotlinGradlePluginExtensionPointInternal<T>)
set(project, extensions) set(project, extensions)
} }