From 6e8493fa52397c62f99e4853389eafb6dd68715f Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Mon, 27 Mar 2023 16:32:46 +0200 Subject: [PATCH] [mpp] Minor: drop support for "kotlin.native.restrictedDistribution" --- .../native/NativeDownloadAndPlatformLibsIT.kt | 10 ----- .../gradle/plugin/PropertiesProvider.kt | 6 --- .../native/NativeCompilerDownloader.kt | 6 +-- .../native/internal/NativeDistributionType.kt | 45 +++---------------- 4 files changed, 10 insertions(+), 57 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadAndPlatformLibsIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadAndPlatformLibsIT.kt index 6f6559ab4d2..432e83c25f4 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadAndPlatformLibsIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativeDownloadAndPlatformLibsIT.kt @@ -173,16 +173,6 @@ class NativeDownloadAndPlatformLibsIT : BaseGradleIT() { } } - @Test - fun testDeprecatedRestrictedDistributionProperty() = with(platformLibrariesProject("linuxX64")) { - // We allow using this deprecated property for 1.4 too. Just download the distribution without platform libs in this case. - build("tasks", "-Pkotlin.native.restrictedDistribution=true") { - assertSuccessful() - assertContains("Warning: Project property 'kotlin.native.restrictedDistribution' is deprecated. Please use 'kotlin.native.distribution.type=light' instead") - assertContainsRegex("Kotlin/Native distribution: .*kotlin-native-$platformName".toRegex()) - } - } - @Test fun testSettingGenerationMode() = with(platformLibrariesProject("linuxX64")) { // Check that user can change generation mode used by the cinterop tool. diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt index 378e7b20dad..119350111fe 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/plugin/PropertiesProvider.kt @@ -314,12 +314,6 @@ internal class PropertiesProvider private constructor(private val project: Proje val nativeDownloadFromMaven: Boolean get() = this.booleanProperty("kotlin.native.distribution.downloadFromMaven") ?: false - /** - * A property that was used to choose a restricted distribution in 1.3. - */ - val nativeDeprecatedRestricted: Boolean? - get() = booleanProperty("kotlin.native.restrictedDistribution") - /** * Allows a user to force a particular cinterop mode for platform libraries generation. Available modes: sourcecode, metadata. * A main purpose of this property is working around potential problems with the metadata mode. diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeCompilerDownloader.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeCompilerDownloader.kt index ed640979eeb..f64b8c4719c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeCompilerDownloader.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/NativeCompilerDownloader.kt @@ -48,7 +48,7 @@ class NativeCompilerDownloader( private val kotlinProperties get() = PropertiesProvider(project) private val distributionType: NativeDistributionType - get() = NativeDistributionTypeProvider(project).getDistributionType(compilerVersion) + get() = NativeDistributionTypeProvider(project).getDistributionType() private val simpleOsName: String get() = HostManager.platformName() @@ -207,8 +207,8 @@ internal fun Project.setupNativeCompiler(konanTarget: KonanTarget) { logger.info("User-provided Kotlin/Native distribution: $konanHome") } - val distributionType = NativeDistributionTypeProvider(project).getDistributionType(konanVersion) + val distributionType = NativeDistributionTypeProvider(project).getDistributionType() if (distributionType.mustGeneratePlatformLibs) { PlatformLibrariesGenerator(project, konanTarget).generatePlatformLibsIfNeeded() } -} \ No newline at end of file +} diff --git a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/NativeDistributionType.kt b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/NativeDistributionType.kt index 80116c8001d..77fa4f38ee3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/NativeDistributionType.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/NativeDistributionType.kt @@ -14,10 +14,6 @@ import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly internal enum class NativeDistributionType(val suffix: String?, val mustGeneratePlatformLibs: Boolean) { LIGHT(null, true), PREBUILT("prebuilt", false), - - // Distribution types for 1.3: - LIGHT_1_3("restricted", false), // aka "restricted" distribution without platform libs for Apple targets. - PREBUILT_1_3(null, false) } internal class NativeDistributionTypeProvider(private val project: Project) { @@ -25,42 +21,15 @@ internal class NativeDistributionTypeProvider(private val project: Project) { private fun warning(message: String) = SingleWarningPerBuild.show(project, "Warning: $message") - private fun chooseDistributionType( - prebuiltType: NativeDistributionType, - lightType: NativeDistributionType, - defaultType: NativeDistributionType - ): NativeDistributionType { - val requestedByUser = propertiesProvider.nativeDistributionType?.toLowerCaseAsciiOnly() - val deprecatedRestricted = propertiesProvider.nativeDeprecatedRestricted - - // A case when a deprecated property (kotlin.native.restrictedDistribution) is used to choose the restricted distribution. - // Effectively the restricted distribution from 1.3 and the light distribution from 1.4 are the same, - // so we allow user to specify kotlin.native.restrictedDistribution in both 1.3 and 1.4 - if (requestedByUser == null && deprecatedRestricted != null) { - return if (deprecatedRestricted) { - lightType - } else { - defaultType - } - } - - // A normal path: no deprecated properties, only kotlin.native.distribution.type. - return when (requestedByUser) { - null -> defaultType - "prebuilt" -> prebuiltType - "light" -> lightType + fun getDistributionType(): NativeDistributionType { + return when (propertiesProvider.nativeDistributionType?.toLowerCaseAsciiOnly()) { + null -> PREBUILT + "prebuilt" -> PREBUILT + "light" -> LIGHT else -> { - warning("Unknown Kotlin/Native distribution type: $requestedByUser. Available values: prebuilt, light") - defaultType + warning("Unknown Kotlin/Native distribution type: ${propertiesProvider.nativeDistributionType?.toLowerCaseAsciiOnly()}. Available values: prebuilt, light") + PREBUILT } } } - - fun getDistributionType(version: String): NativeDistributionType { - if (propertiesProvider.nativeDeprecatedRestricted != null) { - warning("Project property 'kotlin.native.restrictedDistribution' is deprecated. Please use 'kotlin.native.distribution.type=light' instead") - } - - return chooseDistributionType(prebuiltType = PREBUILT, lightType = LIGHT, defaultType = PREBUILT) - } }