Introduce KotlinBasePlugin
This interface is a top-level interface for all Kotlin plugins. Additionally it provides 'pluginVersion' property allowing to get current applied plugin version ^KT-50869 Fixed ^KT-48008 Fixed
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
/**
|
||||
* Base Kotlin plugin that is responsible for creating basic build services, configurations,
|
||||
* and other setup that is common for all Kotlin projects.
|
||||
*/
|
||||
interface KotlinBasePlugin : Plugin<Project> {
|
||||
/** Gets the current version of the Kotlin Gradle plugin. */
|
||||
val pluginVersion: String
|
||||
}
|
||||
-3
@@ -23,9 +23,6 @@ interface KotlinJvmFactory {
|
||||
/** Instance of DSL object that should be used to configure Kotlin compilation pipeline. */
|
||||
val kotlinExtension: KotlinTopLevelExtensionConfig
|
||||
|
||||
/** Gets the current version of the Kotlin Gradle plugin. */
|
||||
val pluginVersion: String
|
||||
|
||||
/** Creates instance of DSL object that should be used to configure JVM/android specific compilation. */
|
||||
fun createKotlinJvmOptions(): KotlinJvmOptions
|
||||
|
||||
|
||||
+1
-5
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.logging.Logging
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.TaskProvider
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
|
||||
@@ -21,10 +20,7 @@ import org.jetbrains.kotlin.gradle.tasks.configuration.KaptWithoutKotlincConfig
|
||||
import org.jetbrains.kotlin.gradle.tasks.configuration.KotlinCompileConfig
|
||||
|
||||
/** Plugin that can be used by third-party plugins to create Kotlin-specific DSL and tasks (compilation and KAPT) for JVM platform. */
|
||||
abstract class KotlinBaseApiPlugin : KotlinBasePlugin(), KotlinJvmFactory {
|
||||
|
||||
private val logger = Logging.getLogger(KotlinBaseApiPlugin::class.java)
|
||||
override val pluginVersion = getKotlinPluginVersion(logger)
|
||||
abstract class KotlinBaseApiPlugin : DefaultKotlinBasePlugin(), KotlinJvmFactory {
|
||||
|
||||
private lateinit var myProject: Project
|
||||
private val taskCreator = KotlinTasksProvider()
|
||||
|
||||
+6
-2
@@ -21,6 +21,7 @@ import org.gradle.api.NamedDomainObjectFactory
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.logging.Logger
|
||||
import org.gradle.api.logging.Logging
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import org.jetbrains.kotlin.compilerRunner.registerCommonizerClasspathConfigurationIfNecessary
|
||||
@@ -59,7 +60,10 @@ import kotlin.reflect.KClass
|
||||
* Base Kotlin plugin that is responsible for creating basic build services, configurations,
|
||||
* and other setup that is common for all Kotlin projects.
|
||||
*/
|
||||
abstract class KotlinBasePlugin : Plugin<Project> {
|
||||
abstract class DefaultKotlinBasePlugin : KotlinBasePlugin {
|
||||
|
||||
private val logger = Logging.getLogger(DefaultKotlinBasePlugin::class.java)
|
||||
override val pluginVersion: String = getKotlinPluginVersion(logger)
|
||||
|
||||
override fun apply(project: Project) {
|
||||
val kotlinPluginVersion = project.getKotlinPluginVersion()
|
||||
@@ -127,7 +131,7 @@ abstract class KotlinBasePlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
|
||||
abstract class KotlinBasePluginWrapper : KotlinBasePlugin() {
|
||||
abstract class KotlinBasePluginWrapper : DefaultKotlinBasePlugin() {
|
||||
|
||||
open val projectExtensionClass: KClass<out KotlinTopLevelExtension> get() = KotlinProjectExtension::class
|
||||
|
||||
|
||||
Reference in New Issue
Block a user