[Gradle] Implement KotlinProjectSetupAction extensionPoint

KT-61634
This commit is contained in:
Sebastian Sellmair
2023-10-16 17:56:38 +02:00
committed by Space Team
parent 43929398da
commit ff6b883cb4
3 changed files with 27 additions and 0 deletions
@@ -263,6 +263,8 @@ abstract class KotlinBasePluginWrapper : DefaultKotlinBasePlugin() {
plugin.apply(project)
project.runKotlinProjectSetupActions()
project.addNpmDependencyExtension()
project.registerBuildKotlinToolingMetadataTask()
@@ -0,0 +1,21 @@
package org.jetbrains.kotlin.gradle.plugin
import org.gradle.api.Project
/**
* Generic action to configure/set up a Kotlin Gradle Project.
* Will be invoked after the KotlinPluginWrapper applied the underlying Kotlin Gradle Plugin
*/
internal fun interface KotlinProjectSetupAction {
fun Project.invoke()
companion object {
val extensionPoint = KotlinGradlePluginExtensionPoint<KotlinProjectSetupAction>()
}
}
internal fun Project.runKotlinProjectSetupActions() {
KotlinProjectSetupAction.extensionPoint[this].forEach { action ->
with(action) { invoke() }
}
}
@@ -31,6 +31,10 @@ import org.jetbrains.kotlin.gradle.plugin.diagnostics.checkers.WasmSourceSetsNot
* Active Extensions (using the [KotlinGradlePluginExtensionPoint] infrastructure) will be registered here by the Kotlin Gradle Plugin.
*/
internal fun Project.registerKotlinPluginExtensions() {
KotlinProjectSetupAction.extensionPoint.apply {
}
KotlinGradleProjectChecker.extensionPoint.apply {
register(project, CommonMainOrTestWithDependsOnChecker)
register(project, DeprecatedKotlinNativeTargetsChecker)