[Gradle] Add Gradle 7.6+ variant
#KT-54634 In Progress
This commit is contained in:
committed by
Space Team
parent
900a3e59ff
commit
f839d5d4c2
+3
-2
@@ -215,14 +215,15 @@ class SimpleKotlinGradleIT : KGPBaseTest() {
|
||||
|
||||
@DisplayName("Proper Gradle plugin variant is used")
|
||||
@GradleTestVersions(
|
||||
additionalVersions = [TestVersions.Gradle.G_7_0, TestVersions.Gradle.G_7_1, TestVersions.Gradle.G_7_4],
|
||||
maxVersion = TestVersions.Gradle.G_7_5
|
||||
additionalVersions = [TestVersions.Gradle.G_7_0, TestVersions.Gradle.G_7_1, TestVersions.Gradle.G_7_4, TestVersions.Gradle.G_7_5],
|
||||
maxVersion = TestVersions.Gradle.G_7_6
|
||||
)
|
||||
@GradleTest
|
||||
internal fun pluginVariantIsUsed(gradleVersion: GradleVersion) {
|
||||
project("kotlinProject", gradleVersion) {
|
||||
build("tasks") {
|
||||
val expectedVariant = when (gradleVersion) {
|
||||
GradleVersion.version(TestVersions.Gradle.G_7_6) -> "gradle76"
|
||||
GradleVersion.version(TestVersions.Gradle.G_7_5) -> "gradle75"
|
||||
in GradleVersion.version(TestVersions.Gradle.G_7_1)..GradleVersion.version(TestVersions.Gradle.G_7_4) -> "gradle71"
|
||||
GradleVersion.version(TestVersions.Gradle.G_7_0) -> "gradle70"
|
||||
|
||||
+2
-1
@@ -18,7 +18,8 @@ interface TestVersions {
|
||||
const val G_7_2 = "7.2"
|
||||
const val G_7_3 = "7.3.3"
|
||||
const val G_7_4 = "7.4.2"
|
||||
const val G_7_5 = "7.5"
|
||||
const val G_7_5 = "7.5.1"
|
||||
const val G_7_6 = "7.6"
|
||||
// https://gradle.org/nightly/
|
||||
// Retention policy is 3 months
|
||||
const val G_8_0 = "8.0-20221126231700+0000"
|
||||
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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 com.android.build.gradle.BaseExtension
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.gradle.api.model.ObjectFactory
|
||||
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val PLUGIN_VARIANT_NAME = "gradle76"
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinMultiplatformPluginWrapper : AbstractKotlinMultiplatformPluginWrapper() {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinJsPluginWrapper : AbstractKotlinJsPluginWrapper() {
|
||||
|
||||
override val pluginVariant: String = PLUGIN_VARIANT_NAME
|
||||
|
||||
override fun apply(project: Project) {
|
||||
project.registerVariantImplementations()
|
||||
super.apply(project)
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinPlatformJvmPlugin : KotlinPlatformImplementationPluginBase("jvm") {
|
||||
override fun apply(project: Project) {
|
||||
project.applyPlugin<KotlinPluginWrapper>()
|
||||
super.apply(project)
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinPlatformJsPlugin : KotlinPlatformImplementationPluginBase("js") {
|
||||
override fun apply(project: Project) {
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
project.applyPlugin<Kotlin2JsPluginWrapper>()
|
||||
super.apply(project)
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinPlatformAndroidPlugin : KotlinPlatformImplementationPluginBase("android") {
|
||||
override fun apply(project: Project) {
|
||||
project.applyPlugin<KotlinAndroidPluginWrapper>()
|
||||
super.apply(project)
|
||||
}
|
||||
|
||||
override fun namedSourceSetsContainer(project: Project): NamedDomainObjectContainer<*> =
|
||||
(project.extensions.getByName("android") as BaseExtension).sourceSets
|
||||
|
||||
override fun addCommonSourceSetToPlatformSourceSet(commonSourceSet: Named, platformProject: Project) {
|
||||
val androidExtension = platformProject.extensions.getByName("android") as BaseExtension
|
||||
val androidSourceSet = androidExtension.sourceSets.findByName(commonSourceSet.name) ?: return
|
||||
val kotlinSourceSet = androidSourceSet.getExtension<SourceDirectorySet>(KOTLIN_DSL_NAME)
|
||||
?: return
|
||||
kotlinSourceSet.source(getKotlinSourceDirectorySetSafe(commonSourceSet)!!)
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinPlatformCommonPlugin : KotlinPlatformPluginBase("common") {
|
||||
override fun apply(project: Project) {
|
||||
warnAboutKotlin12xMppDeprecation(project)
|
||||
project.applyPlugin<KotlinCommonPluginWrapper>()
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UnusedReceiverParameter")
|
||||
private fun Project.registerVariantImplementations() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user