Create plugin for test to set language and api kotlin versions
This commit is contained in:
committed by
Space Team
parent
1c2f34ab4e
commit
d6a9bca5ec
@@ -104,6 +104,8 @@ fun Project.excludeGradleCommonDependencies(sourceSet: SourceSet) {
|
||||
configurations[sourceSet.runtimeOnlyConfigurationName].excludeGradleCommonDependencies()
|
||||
}
|
||||
|
||||
private val testPlugins = listOf("kotlin-gradle-plugin-api", "android-test-fixes", "gradle-warnings-detector", "kotlin-compiler-args-properties")
|
||||
|
||||
/**
|
||||
* Common sources for all variants.
|
||||
* Should contain classes that are independent of Gradle API version or using minimal supported Gradle api.
|
||||
@@ -123,10 +125,7 @@ fun Project.createGradleCommonSourceSet(): SourceSet {
|
||||
dependencies {
|
||||
compileOnlyConfigurationName(kotlinStdlib())
|
||||
"commonGradleApiCompileOnly"("dev.gradleplugins:gradle-api:7.6")
|
||||
if (this@createGradleCommonSourceSet.name != "kotlin-gradle-plugin-api" &&
|
||||
this@createGradleCommonSourceSet.name != "android-test-fixes" &&
|
||||
this@createGradleCommonSourceSet.name != "gradle-warnings-detector"
|
||||
) {
|
||||
if (this@createGradleCommonSourceSet.name !in testPlugins) {
|
||||
compileOnlyConfigurationName(project(":kotlin-gradle-plugin-api")) {
|
||||
capabilities {
|
||||
requireCapability("org.jetbrains.kotlin:kotlin-gradle-plugin-api-common")
|
||||
@@ -276,10 +275,7 @@ fun Project.reconfigureMainSourcesSetForGradlePlugin(
|
||||
// Decoupling gradle-api artifact from current project Gradle version. Later would be useful for
|
||||
// gradle plugin variants
|
||||
"compileOnly"("dev.gradleplugins:gradle-api:${GradlePluginVariant.GRADLE_MIN.gradleApiVersion}")
|
||||
if (this@reconfigureMainSourcesSetForGradlePlugin.name != "kotlin-gradle-plugin-api" &&
|
||||
this@reconfigureMainSourcesSetForGradlePlugin.name != "android-test-fixes" &&
|
||||
this@reconfigureMainSourcesSetForGradlePlugin.name != "gradle-warnings-detector"
|
||||
) {
|
||||
if (this@reconfigureMainSourcesSetForGradlePlugin.name !in testPlugins) {
|
||||
"api"(project(":kotlin-gradle-plugin-api"))
|
||||
}
|
||||
}
|
||||
@@ -463,10 +459,7 @@ fun Project.createGradlePluginVariant(
|
||||
dependencies {
|
||||
variantSourceSet.compileOnlyConfigurationName(kotlinStdlib())
|
||||
variantSourceSet.compileOnlyConfigurationName("dev.gradleplugins:gradle-api:${variant.gradleApiVersion}")
|
||||
if (this@createGradlePluginVariant.name != "kotlin-gradle-plugin-api" &&
|
||||
this@createGradlePluginVariant.name != "android-test-fixes" &&
|
||||
this@createGradlePluginVariant.name != "gradle-warnings-detector"
|
||||
) {
|
||||
if (this@createGradlePluginVariant.name !in testPlugins) {
|
||||
variantSourceSet.apiConfigurationName(project(":kotlin-gradle-plugin-api")) {
|
||||
capabilities {
|
||||
requireCapability("org.jetbrains.kotlin:kotlin-gradle-plugin-api-${variant.sourceSetName}")
|
||||
@@ -567,6 +560,7 @@ fun Project.addBomCheckTask() {
|
||||
val exceptions = listOf(
|
||||
project(":gradle:android-test-fixes").path,
|
||||
project(":gradle:gradle-warnings-detector").path,
|
||||
project(":gradle:kotlin-compiler-args-properties").path,
|
||||
project(":kotlin-gradle-build-metrics").path,
|
||||
project(":kotlin-gradle-statistics").path,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
## Description
|
||||
|
||||
Contains a plugin for Gradle tests to set Kotlin arguments (api and language version) via 'gradle.properties'
|
||||
@@ -0,0 +1,37 @@
|
||||
import plugins.KotlinBuildPublishingPlugin
|
||||
|
||||
plugins {
|
||||
id("gradle-plugin-common-configuration")
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
commonApi(project(":kotlin-gradle-plugin-api"))
|
||||
commonApi(project(":kotlin-gradle-plugin"))
|
||||
commonCompileOnly(gradleKotlinDsl())
|
||||
}
|
||||
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("kotlin-compiler-args-properties") {
|
||||
id = "org.jetbrains.kotlin.test.kotlin-compiler-args-properties"
|
||||
displayName = "GradleKotlinCompilerArgumentsPlugin"
|
||||
description = displayName
|
||||
implementationClass = "org.jetbrains.kotlin.gradle.arguments.GradleKotlinCompilerArgumentsPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable releasing for this plugin
|
||||
// It is not intended to be released publicly
|
||||
tasks.withType<PublishToMavenRepository>()
|
||||
.configureEach {
|
||||
if (name.endsWith("PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository")) {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("publishPlugins") {
|
||||
enabled = false
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.arguments
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.ExtensionContainer
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.provider.ProviderFactory
|
||||
import org.gradle.kotlin.dsl.withType
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import javax.inject.Inject
|
||||
|
||||
class GradleKotlinCompilerArgumentsPlugin @Inject constructor(
|
||||
private val providerFactory: ProviderFactory
|
||||
) : KotlinBasePlugin {
|
||||
override val pluginVersion = "test"
|
||||
|
||||
override fun apply(project: Project) {
|
||||
val properties = KotlinTaskProperties(providerFactory)
|
||||
project.configureKotlinVersions(properties)
|
||||
}
|
||||
|
||||
private fun Project.configureKotlinVersions(properties: KotlinTaskProperties) {
|
||||
plugins.withType<KotlinBasePlugin>().configureEach(configureTask(properties))
|
||||
}
|
||||
|
||||
private fun Project.configureTask(properties: KotlinTaskProperties): Action<KotlinBasePlugin> = Action {
|
||||
tasks.withType<KotlinCompilationTask<*>>().configureEach {
|
||||
configureKotlinOption(properties, it.compilerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ExtensionContainer.projectCompilerOptions(): KotlinCommonCompilerOptions? =
|
||||
findByType(KotlinJvmProjectExtension::class.java)?.compilerOptions
|
||||
?: findByType(KotlinAndroidProjectExtension::class.java)?.compilerOptions
|
||||
|
||||
private fun Project.projectLevelLanguageVersion(): Provider<KotlinVersion> {
|
||||
return extensions.projectCompilerOptions()?.languageVersion ?: providers.provider { null }
|
||||
}
|
||||
|
||||
private fun Project.projectLevelApiVersion(): Provider<KotlinVersion> {
|
||||
return extensions.projectCompilerOptions()?.apiVersion ?: providers.provider { null }
|
||||
}
|
||||
|
||||
private fun Project.configureKotlinOption(properties: KotlinTaskProperties, taskOptions: KotlinCommonCompilerOptions) {
|
||||
taskOptions.languageVersion.convention(properties.kotlinLanguageVersion.orElse(projectLevelLanguageVersion()))
|
||||
taskOptions.apiVersion.convention(properties.kotlinApiVersion.orElse(projectLevelApiVersion()))
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.arguments
|
||||
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.provider.ProviderFactory
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
|
||||
class KotlinTaskProperties(providerFactory: ProviderFactory) {
|
||||
val kotlinLanguageVersion: Provider<KotlinVersion> = readKotlinVersionProperty(KOTLIN_LANGUAGE_VERSION_PROPERTY, providerFactory)
|
||||
val kotlinApiVersion: Provider<KotlinVersion> = readKotlinVersionProperty(KOTLIN_API_VERSION_PROPERTY, providerFactory)
|
||||
|
||||
companion object {
|
||||
private const val KOTLIN_LANGUAGE_VERSION_PROPERTY = "kotlin.test.languageVersion"
|
||||
private const val KOTLIN_API_VERSION_PROPERTY = "kotlin.test.apiVersion"
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun readKotlinVersionProperty(propertyName: String, providerFactory: ProviderFactory): Provider<KotlinVersion> {
|
||||
return if (GradleVersion.current() < GradleVersion.version("7.4")) {
|
||||
providerFactory.gradleProperty(propertyName)
|
||||
.forUseAtConfigurationTime()
|
||||
.map { KotlinVersion.fromVersion(it as String) }
|
||||
} else {
|
||||
providerFactory.gradleProperty(propertyName)
|
||||
.map { KotlinVersion.fromVersion(it as String) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -333,6 +333,7 @@ tasks.withType<Test> {
|
||||
dependsOnKotlinGradlePluginInstall()
|
||||
dependsOn(":gradle:android-test-fixes:install")
|
||||
dependsOn(":gradle:gradle-warnings-detector:install")
|
||||
dependsOn(":gradle:kotlin-compiler-args-properties:install")
|
||||
dependsOn(":examples:annotation-processor-example:install")
|
||||
dependsOn(":kotlin-dom-api-compat:install")
|
||||
|
||||
|
||||
+6
-10
@@ -274,8 +274,8 @@ abstract class BaseGradleIT {
|
||||
val configurationCache: Boolean = false,
|
||||
val configurationCacheProblems: ConfigurationCacheProblems = ConfigurationCacheProblems.FAIL,
|
||||
val warningMode: WarningMode = WarningMode.Fail,
|
||||
val useFir: Boolean = false,
|
||||
val languageVersion: String? = null,
|
||||
val languageApiVersion: String? = null,
|
||||
val customEnvironmentVariables: Map<String, String> = mapOf(),
|
||||
val dryRun: Boolean = false,
|
||||
val abiSnapshot: Boolean = false,
|
||||
@@ -312,7 +312,7 @@ abstract class BaseGradleIT {
|
||||
open val resourcesRoot = File(resourcesRootFile, "testProject/$resourceDirName")
|
||||
val projectDir = File(workingDir.canonicalFile, projectName)
|
||||
|
||||
open fun setupWorkingDir(enableCacheRedirector: Boolean = true, applyAndroidTestFixes: Boolean = true) {
|
||||
open fun setupWorkingDir(enableCacheRedirector: Boolean = true, applyAndroidTestFixes: Boolean = true, applyLanguageVersion: Boolean = true) {
|
||||
if (!projectDir.isDirectory || projectDir.listFiles().isEmpty()) {
|
||||
copyRecursively(this.resourcesRoot, workingDir)
|
||||
if (addHeapDumpOptions) {
|
||||
@@ -323,6 +323,7 @@ abstract class BaseGradleIT {
|
||||
addPluginManagementToSettings()
|
||||
if (enableCacheRedirector) enableCacheRedirector()
|
||||
if (applyAndroidTestFixes) applyAndroidTestFixes()
|
||||
if (applyLanguageVersion) applyKotlinCompilerArgsPlugin()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -937,14 +938,6 @@ abstract class BaseGradleIT {
|
||||
add("-Pkotlin.js.compiler=$it")
|
||||
}
|
||||
|
||||
if (options.useFir) {
|
||||
add("-Pkotlin.useK2=true")
|
||||
}
|
||||
|
||||
if(options.languageVersion != null) {
|
||||
add("-Pkotlin.internal.languageVersion=${options.languageVersion}")
|
||||
}
|
||||
|
||||
if (options.dryRun) {
|
||||
add("--dry-run")
|
||||
}
|
||||
@@ -979,6 +972,9 @@ abstract class BaseGradleIT {
|
||||
if (supportFailingBuildOnWarning && options.warningMode == WarningMode.Fail) {
|
||||
add("--warning-mode=${WarningMode.Fail.name.lowercase(Locale.getDefault())}")
|
||||
}
|
||||
options.languageVersion?.also { add("-Pkotlin.test.languageVersion=$it") }
|
||||
options.languageApiVersion?.also { add("-Pkotlin.test.apiVersion=$it") }
|
||||
|
||||
addAll(options.freeCommandLineArgs)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -317,7 +317,7 @@ class IncrementalCompilationJvmMultiProjectWithPreciseBackupIT : IncrementalComp
|
||||
}
|
||||
|
||||
class IncrementalCompilationFirJvmMultiProjectIT : IncrementalCompilationJvmMultiProjectIT() {
|
||||
override val defaultBuildOptions: BuildOptions = super.defaultBuildOptions.copy(useFir = true)
|
||||
override val defaultBuildOptions: BuildOptions = super.defaultBuildOptions.copy(languageVersion = "2.0")
|
||||
}
|
||||
|
||||
open class IncrementalCompilationOldICJvmMultiProjectIT : IncrementalCompilationJvmMultiProjectIT() {
|
||||
|
||||
+1
-1
@@ -239,7 +239,7 @@ open class IncrementalJavaChangeDisablePreciseIT : IncrementalCompilationJavaCha
|
||||
|
||||
@DisplayName("Default incremental compilation with disabled precise java tracking and enabled FIR")
|
||||
class IncrementalFirJavaChangeDisablePreciseIT : IncrementalJavaChangeDisablePreciseIT() {
|
||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(useFir = true)
|
||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(languageVersion = "2.0")
|
||||
}
|
||||
|
||||
@JvmGradlePluginTests
|
||||
|
||||
+2
-6
@@ -77,16 +77,12 @@ abstract class KotlinJsIrLibraryGradlePluginITBase : KGPBaseTest() {
|
||||
@DisplayName("Kotlin/JS K1 IR library")
|
||||
@JsGradlePluginTests
|
||||
class KotlinK1JsIrLibraryGradlePluginIT : KotlinJsIrLibraryGradlePluginITBase() {
|
||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(
|
||||
useFir = false
|
||||
)
|
||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(languageVersion = null)
|
||||
}
|
||||
|
||||
@GradleTestVersions(minVersion = TestVersions.Gradle.G_7_0)
|
||||
@DisplayName("Kotlin/JS K2 IR library")
|
||||
@JsGradlePluginTests
|
||||
class KotlinK2JsIrLibraryGradlePluginIT : KotlinJsIrLibraryGradlePluginITBase() {
|
||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(
|
||||
useFir = true
|
||||
)
|
||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(languageVersion = "2.0")
|
||||
}
|
||||
|
||||
+2
-1
@@ -232,7 +232,8 @@ abstract class AndroidAndJavaConsumeMppLibIT : BaseGradleIT() {
|
||||
"\ninclude(\":${dependencyProject.projectName}:lib\")"
|
||||
)
|
||||
}
|
||||
setupWorkingDir()
|
||||
|
||||
setupWorkingDir(applyLanguageVersion = withKotlinVersion != oldKotlinVersion)
|
||||
|
||||
gradleBuildScript("Lib").apply {
|
||||
writeText(
|
||||
|
||||
+7
-9
@@ -34,9 +34,9 @@ data class BuildOptions(
|
||||
val androidVersion: String? = null,
|
||||
val jsOptions: JsOptions? = null,
|
||||
val buildReport: List<BuildReportType> = emptyList(),
|
||||
val useFir: Boolean = false,
|
||||
val usePreciseJavaTracking: Boolean? = null,
|
||||
val languageVersion: String? = null,
|
||||
val languageApiVersion: String? = null,
|
||||
val freeArgs: List<String> = emptyList(),
|
||||
val statisticsForceValidation: Boolean = true,
|
||||
val usePreciseOutputsBackup: Boolean? = null,
|
||||
@@ -140,14 +140,6 @@ data class BuildOptions(
|
||||
arguments.add("-Pkotlin.build.report.output=${buildReport.joinToString()}")
|
||||
}
|
||||
|
||||
if (useFir) {
|
||||
arguments.add("-Pkotlin.useK2=true")
|
||||
}
|
||||
|
||||
if (languageVersion != null) {
|
||||
arguments.add("-Pkotlin.internal.languageVersion=$languageVersion")
|
||||
}
|
||||
|
||||
if (usePreciseJavaTracking != null) {
|
||||
arguments.add("-Pkotlin.incremental.usePreciseJavaTracking=$usePreciseJavaTracking")
|
||||
}
|
||||
@@ -159,6 +151,12 @@ data class BuildOptions(
|
||||
if (usePreciseOutputsBackup != null) {
|
||||
arguments.add("-Pkotlin.compiler.preciseCompilationResultsBackup=$usePreciseOutputsBackup")
|
||||
}
|
||||
if (languageApiVersion != null) {
|
||||
arguments.add("-Pkotlin.test.apiVersion=$languageApiVersion")
|
||||
}
|
||||
if (languageVersion != null) {
|
||||
arguments.add("-Pkotlin.test.languageVersion=$languageVersion")
|
||||
}
|
||||
|
||||
if (keepIncrementalCompilationCachesInMemory != null) {
|
||||
arguments.add("-Pkotlin.compiler.keepIncrementalCompilationCachesInMemory=$keepIncrementalCompilationCachesInMemory")
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.testbase
|
||||
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
|
||||
fun Path.applyKotlinCompilerArgsPlugin() {
|
||||
toFile().walkTopDown()
|
||||
.filter { it.name in listOf("build.gradle", "build.gradle.kts", "settings.gradle", "settings.gradle.kts") }
|
||||
.forEach { file ->
|
||||
when (file.name) {
|
||||
"build.gradle" -> file.updateBuildGradle()
|
||||
"build.gradle.kts" -> file.updateBuildKtsGradle()
|
||||
"settings.gradle.kts" -> file.updateSettingsKtsGradle()
|
||||
"settings.gradle" -> file.updateSettingsGradle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun File.updateSettingsKtsGradle() {
|
||||
modify {
|
||||
if (it.contains("pluginManagement {")) {
|
||||
it.replaceFirst(
|
||||
"plugins {", "plugins {\n" +
|
||||
"id(\"org.jetbrains.kotlin.test.kotlin-compiler-args-properties\") version test_fixes_version"
|
||||
)
|
||||
} else it
|
||||
}
|
||||
}
|
||||
|
||||
private fun File.updateSettingsGradle() {
|
||||
modify {
|
||||
if (it.contains("pluginManagement {")) {
|
||||
it.replaceFirst("plugins {", "plugins {\n"+
|
||||
"id \"org.jetbrains.kotlin.test.kotlin-compiler-args-properties\" version \"${'$'}test_fixes_version\"")
|
||||
} else it
|
||||
}
|
||||
}
|
||||
|
||||
private fun File.updateBuildKtsGradle() {
|
||||
modify {
|
||||
if (it.contains("buildscript {")) {
|
||||
it.replaceFirst(
|
||||
"dependencies {", "dependencies {\n" +
|
||||
"classpath(\"org.jetbrains.kotlin:kotlin-compiler-args-properties:${'$'}test_fixes_version\")"
|
||||
)
|
||||
} else {
|
||||
it.replace(
|
||||
"plugins {",
|
||||
"plugins {\nid(\"org.jetbrains.kotlin.test.kotlin-compiler-args-properties\")"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun File.updateBuildGradle() {
|
||||
modify {
|
||||
if (it.contains("buildscript {")) {
|
||||
it.replaceFirst(
|
||||
"dependencies {", "dependencies {\n" +
|
||||
"classpath \"org.jetbrains.kotlin:kotlin-compiler-args-properties:${'$'}test_fixes_version\""
|
||||
)
|
||||
} else {
|
||||
it.replace(
|
||||
"plugins {",
|
||||
"plugins {\nid \"org.jetbrains.kotlin.test.kotlin-compiler-args-properties\""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -37,6 +37,7 @@ internal val DEFAULT_GROOVY_SETTINGS_FILE =
|
||||
id "org.jetbrains.kotlin.gradle-subplugin-example" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.atomicfu" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.test.gradle-warnings-detector" version "${'$'}test_fixes_version"
|
||||
id "org.jetbrains.kotlin.test.kotlin-compiler-args-properties" version "${'$'}test_fixes_version"
|
||||
}
|
||||
|
||||
resolutionStrategy {
|
||||
@@ -96,6 +97,7 @@ internal val DEFAULT_KOTLIN_SETTINGS_FILE =
|
||||
id("org.jetbrains.kotlin.gradle-subplugin-example") version kotlin_version
|
||||
id("org.jetbrains.kotlin.plugin.atomicfu") version kotlin_version
|
||||
id("org.jetbrains.kotlin.test.gradle-warnings-detector") version test_fixes_version
|
||||
id("org.jetbrains.kotlin.test.kotlin-compiler-args-properties") version test_fixes_version
|
||||
}
|
||||
|
||||
resolutionStrategy {
|
||||
|
||||
+22
@@ -74,6 +74,7 @@ fun KGPBaseTest.project(
|
||||
)
|
||||
localRepoDir?.let { testProject.configureLocalRepository(localRepoDir) }
|
||||
if (buildJdk != null) testProject.setupNonDefaultJdk(buildJdk)
|
||||
testProject.addKotlinCompilerArgumentsPlugin()
|
||||
|
||||
val result = runCatching {
|
||||
testProject.test()
|
||||
@@ -314,6 +315,27 @@ class TestProject(
|
||||
) : GradleProject(projectName, projectPath) {
|
||||
fun subProject(name: String) = GradleProject(name, projectPath.resolve(name))
|
||||
|
||||
fun addKotlinCompilerArgumentsPlugin() {
|
||||
if (buildOptions.languageVersion != null || buildOptions.languageApiVersion != null ) {
|
||||
projectPath.toFile().walkTopDown().forEach { file ->
|
||||
when {
|
||||
file.name.equals("build.gradle") -> file.modify {
|
||||
it.replaceFirst(
|
||||
"plugins {",
|
||||
"plugins {\nid \"org.jetbrains.kotlin.test.kotlin-compiler-args-properties\""
|
||||
)
|
||||
}
|
||||
file.name.equals("build.gradle.kts") -> file.modify {
|
||||
it.replaceFirst(
|
||||
"plugins {",
|
||||
"plugins {\nid(\"org.jetbrains.kotlin.test.kotlin-compiler-args-properties\")"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun includeOtherProjectAsSubmodule(
|
||||
otherProjectName: String,
|
||||
pathPrefix: String
|
||||
|
||||
+2
-1
@@ -3,9 +3,10 @@ pluginManagement {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
val test_fixes_version: String by settings
|
||||
plugins {
|
||||
val kotlin_version: String by settings
|
||||
val test_fixes_version: String by settings
|
||||
kotlin("multiplatform").version(kotlin_version)
|
||||
id("org.jetbrains.kotlin.test.fixes.android") version test_fixes_version
|
||||
}
|
||||
|
||||
+1
-1
@@ -3,8 +3,8 @@ pluginManagement {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
val kotlin_version: String by settings
|
||||
plugins {
|
||||
val kotlin_version: String by settings
|
||||
val test_fixes_version: String by settings
|
||||
kotlin("multiplatform").version(kotlin_version)
|
||||
id("org.jetbrains.kotlin.test.fixes.android") version test_fixes_version
|
||||
|
||||
-3
@@ -197,9 +197,6 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val useK2: Boolean?
|
||||
get() = booleanProperty("kotlin.useK2")
|
||||
|
||||
val languageVersion: String?
|
||||
get() = property("kotlin.internal.languageVersion")
|
||||
|
||||
val keepMppDependenciesIntactInPoms: Boolean?
|
||||
get() = booleanProperty("kotlin.mpp.keepMppDependenciesIntactInPoms")
|
||||
|
||||
|
||||
+1
-1
@@ -8,5 +8,5 @@ package org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinCompilationImplFactory
|
||||
|
||||
internal val DefaultKotlinCompilationPreConfigure = KotlinCompilationImplFactory.PreConfigure.composite(
|
||||
KotlinCompilationLanguageVersionConfigurator, KotlinCompilationK2MultiplatformConfigurator
|
||||
KotlinCompilationK2MultiplatformConfigurator
|
||||
)
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.mpp.compilationImpl
|
||||
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.factory.KotlinCompilationImplFactory
|
||||
|
||||
internal object KotlinCompilationLanguageVersionConfigurator : KotlinCompilationImplFactory.PreConfigure {
|
||||
override fun configure(compilation: KotlinCompilationImpl) {
|
||||
compilation.project.kotlinPropertiesProvider.languageVersion?.let { languageVersionString ->
|
||||
compilation.compilerOptions.options.languageVersion.convention(KotlinVersion.fromVersion(languageVersionString))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,7 @@ class CodeConformanceTest : TestCase() {
|
||||
"libraries/tools/atomicfu/build",
|
||||
"libraries/tools/gradle/android-test-fixes/build",
|
||||
"libraries/tools/gradle/gradle-warnings-detector/build",
|
||||
"libraries/tools/gradle/kotlin-compiler-args-properties/build",
|
||||
"libraries/tools/kotlin-allopen/build",
|
||||
"libraries/tools/kotlin-assignment/build",
|
||||
"libraries/tools/kotlin-gradle-build-metrics/build",
|
||||
|
||||
@@ -203,6 +203,7 @@ include ":kotlin-imports-dumper-compiler-plugin",
|
||||
":kotlin-gradle-plugins-bom",
|
||||
":gradle:android-test-fixes",
|
||||
":gradle:gradle-warnings-detector",
|
||||
":gradle:kotlin-compiler-args-properties",
|
||||
":gradle:regression-benchmark-templates",
|
||||
":gradle:regression-benchmarks",
|
||||
":kotlin-tooling-metadata",
|
||||
@@ -716,6 +717,7 @@ project(':kotlin-gradle-plugin-integration-tests').projectDir = "$rootDir/librar
|
||||
project(':kotlin-gradle-plugins-bom').projectDir = "$rootDir/libraries/tools/kotlin-gradle-plugins-bom" as File
|
||||
project(':gradle:android-test-fixes').projectDir = "$rootDir/libraries/tools/gradle/android-test-fixes" as File
|
||||
project(':gradle:gradle-warnings-detector').projectDir = "$rootDir/libraries/tools/gradle/gradle-warnings-detector" as File
|
||||
project(':gradle:kotlin-compiler-args-properties').projectDir = "$rootDir/libraries/tools/gradle/kotlin-compiler-args-properties" as File
|
||||
project(":gradle:regression-benchmark-templates").projectDir = "$rootDir/libraries/tools/gradle/regression-benchmark-templates" as File
|
||||
project(":gradle:regression-benchmarks").projectDir = "$rootDir/libraries/tools/gradle/regression-benchmarks" as File
|
||||
project(':kotlin-tooling-metadata').projectDir = "$rootDir/libraries/tools/kotlin-tooling-metadata" as File
|
||||
|
||||
Reference in New Issue
Block a user