Print in info level logs applied plugin variant
^KT-49227 Fixed
This commit is contained in:
+3
@@ -9,6 +9,8 @@ import org.gradle.api.logging.configuration.WarningMode
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs
|
||||
import org.junit.jupiter.api.condition.OS
|
||||
import org.junit.jupiter.api.io.TempDir
|
||||
import java.nio.file.Path
|
||||
import kotlin.io.path.appendText
|
||||
@@ -114,6 +116,7 @@ class PublishingIT : KGPBaseTest() {
|
||||
@DisplayName("Publication with old 'maven' plugin is working")
|
||||
@GradleTest
|
||||
@GradleTestVersions(maxVersion = TestVersions.Gradle.G_6_9)
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
fun testOldMavenPublishing(
|
||||
gradleVersion: GradleVersion,
|
||||
@TempDir localRepoDir: Path
|
||||
|
||||
+17
@@ -209,4 +209,21 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
||||
build(":main-project:compileKotlin")
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Proper Gradle plugin variant is used")
|
||||
@GradleTestVersions(additionalVersions = [TestVersions.Gradle.G_7_0])
|
||||
@GradleTest
|
||||
internal fun pluginVariantIsUsed(gradleVersion: GradleVersion) {
|
||||
project("kotlinProject", gradleVersion) {
|
||||
build("tasks") {
|
||||
val expectedVariant = if (gradleVersion < GradleVersion.version("7.0")) {
|
||||
"main"
|
||||
} else {
|
||||
"gradle70"
|
||||
}
|
||||
|
||||
assertOutputContains("Using Kotlin Gradle Plugin $expectedVariant variant")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -57,6 +57,8 @@ abstract class KotlinBasePluginWrapper : Plugin<Project> {
|
||||
|
||||
open val projectExtensionClass: KClass<out KotlinTopLevelExtension> get() = KotlinProjectExtension::class
|
||||
|
||||
abstract val pluginVariant: String
|
||||
|
||||
internal open fun kotlinSourceSetFactory(project: Project): NamedDomainObjectFactory<KotlinSourceSet> =
|
||||
if (PropertiesProvider(project).experimentalKpmModelMapping)
|
||||
FragmentMappedKotlinSourceSetFactory(project)
|
||||
@@ -65,6 +67,8 @@ abstract class KotlinBasePluginWrapper : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
val kotlinPluginVersion = project.getKotlinPluginVersion()
|
||||
|
||||
project.logger.info("Using Kotlin Gradle Plugin $pluginVariant variant")
|
||||
|
||||
val statisticsReporter = KotlinBuildStatsService.getOrCreateInstance(project)
|
||||
statisticsReporter?.report(StringMetrics.KOTLIN_COMPILER_VERSION, kotlinPluginVersion)
|
||||
|
||||
|
||||
+23
-7
@@ -13,30 +13,46 @@ import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val PLUGIN_VARIANT_NAME = "gradle70"
|
||||
|
||||
open class KotlinPluginWrapper @Inject constructor(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
) : AbstractKotlinPluginWrapper(registry)
|
||||
) : AbstractKotlinPluginWrapper(registry) {
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
}
|
||||
|
||||
open class KotlinCommonPluginWrapper @Inject constructor(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
) : AbstractKotlinCommonPluginWrapper(registry)
|
||||
) : AbstractKotlinCommonPluginWrapper(registry) {
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
}
|
||||
|
||||
open class KotlinAndroidPluginWrapper @Inject constructor(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
) : AbstractKotlinAndroidPluginWrapper(registry)
|
||||
) : AbstractKotlinAndroidPluginWrapper(registry) {
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
open class Kotlin2JsPluginWrapper @Inject constructor(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
) : AbstractKotlin2JsPluginWrapper(registry)
|
||||
) : AbstractKotlin2JsPluginWrapper(registry) {
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
}
|
||||
|
||||
open class KotlinMultiplatformPluginWrapper : AbstractKotlinMultiplatformPluginWrapper()
|
||||
open class KotlinMultiplatformPluginWrapper : AbstractKotlinMultiplatformPluginWrapper() {
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
}
|
||||
|
||||
open class KotlinJsPluginWrapper : AbstractKotlinJsPluginWrapper()
|
||||
open class KotlinJsPluginWrapper : AbstractKotlinJsPluginWrapper() {
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
}
|
||||
|
||||
open class KotlinPm20PluginWrapper @Inject constructor(
|
||||
objectFactory: ObjectFactory
|
||||
) : AbstractKotlinPm20PluginWrapper(objectFactory)
|
||||
) : AbstractKotlinPm20PluginWrapper(objectFactory) {
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
}
|
||||
|
||||
open class KotlinPlatformJvmPlugin : KotlinPlatformImplementationPluginBase("jvm") {
|
||||
override fun apply(project: Project) {
|
||||
|
||||
+23
@@ -15,9 +15,14 @@ import org.jetbrains.kotlin.gradle.plugin.internal.MavenPluginConfigurator
|
||||
import org.jetbrains.kotlin.gradle.plugin.internal.MavenPluginConfiguratorG6
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val PLUGIN_VARIANT_NAME = "main"
|
||||
|
||||
open class KotlinPluginWrapper @Inject constructor(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
) : AbstractKotlinPluginWrapper(registry) {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
@@ -27,6 +32,9 @@ open class KotlinPluginWrapper @Inject constructor(
|
||||
open class KotlinCommonPluginWrapper @Inject constructor(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
) : AbstractKotlinCommonPluginWrapper(registry) {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
@@ -36,6 +44,9 @@ open class KotlinCommonPluginWrapper @Inject constructor(
|
||||
open class KotlinAndroidPluginWrapper @Inject constructor(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
) : AbstractKotlinAndroidPluginWrapper(registry) {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
@@ -46,6 +57,9 @@ open class KotlinAndroidPluginWrapper @Inject constructor(
|
||||
open class Kotlin2JsPluginWrapper @Inject constructor(
|
||||
registry: ToolingModelBuilderRegistry
|
||||
) : AbstractKotlin2JsPluginWrapper(registry) {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
@@ -53,6 +67,9 @@ open class Kotlin2JsPluginWrapper @Inject constructor(
|
||||
}
|
||||
|
||||
open class KotlinMultiplatformPluginWrapper : AbstractKotlinMultiplatformPluginWrapper() {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
@@ -60,6 +77,9 @@ open class KotlinMultiplatformPluginWrapper : AbstractKotlinMultiplatformPluginW
|
||||
}
|
||||
|
||||
open class KotlinJsPluginWrapper : AbstractKotlinJsPluginWrapper() {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
@@ -69,6 +89,9 @@ open class KotlinJsPluginWrapper : AbstractKotlinJsPluginWrapper() {
|
||||
open class KotlinPm20PluginWrapper @Inject constructor(
|
||||
objectFactory: ObjectFactory
|
||||
) : AbstractKotlinPm20PluginWrapper(objectFactory) {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
|
||||
Reference in New Issue
Block a user