[Gradle/MPP] Refactored KotlinTargetContainerWithPresetFunctions
Android preset functions were moved to a separate interface because we need to write custom deprecation with ReplaceWith due KT-57903. After that we had generated: - all the K/N preset functions - jvm functions. I decided to move jvm function to separate file too, so the whole division to several files would be somewhat sane. I kept the KotlinTargetContainerWithPresetFunctions interface to keep source/binary compatibility for the `android`/ `jvm` preset functions users #KT-57903 In Progress
This commit is contained in:
committed by
Space Team
parent
725cfb4ea5
commit
becf50ee0f
+3
-3
@@ -19,7 +19,7 @@ private val presetsProperty = KotlinTargetsContainerWithPresets::presets.name
|
||||
|
||||
private fun generateKotlinTargetContainerWithPresetFunctionsInterface() {
|
||||
// Generate KotlinMultiplatformExtension subclass with member functions for the presets:
|
||||
val functions = allPresetEntries.map { kotlinPreset ->
|
||||
val functions = nativePresetEntries.map { kotlinPreset ->
|
||||
// magic indent is needed to make the result look pretty
|
||||
val funPrefix = kotlinPreset.deprecation?.let { "\n $it\n @Suppress(\"DEPRECATION\")\n " } ?: ""
|
||||
generatePresetFunctions(kotlinPreset, presetsProperty, "configureOrCreate", funPrefix)
|
||||
@@ -29,11 +29,11 @@ private fun generateKotlinTargetContainerWithPresetFunctionsInterface() {
|
||||
typeName(parentInterface.java.canonicalName)
|
||||
|
||||
val className =
|
||||
typeName("org.jetbrains.kotlin.gradle.dsl.KotlinTargetContainerWithPresetFunctions")
|
||||
typeName("org.jetbrains.kotlin.gradle.dsl.KotlinTargetContainerWithNativePresetFunctions")
|
||||
|
||||
val deprecatedMessageVal = typeName("org.jetbrains.kotlin.konan.target.DEPRECATED_TARGET_MESSAGE")
|
||||
|
||||
val imports = allPresetEntries
|
||||
val imports = nativePresetEntries
|
||||
.flatMap { it.typeNames() }
|
||||
.plus(parentInterfaceName)
|
||||
.plus(deprecatedMessageVal)
|
||||
|
||||
-17
@@ -36,18 +36,6 @@ internal object NativeFQNames {
|
||||
}
|
||||
}
|
||||
|
||||
internal val jvmPresetEntry = KotlinPresetEntry(
|
||||
"jvm",
|
||||
typeName("$MPP_PACKAGE.KotlinJvmTargetPreset"),
|
||||
typeName("org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget")
|
||||
)
|
||||
|
||||
internal val androidPresetEntry = KotlinPresetEntry(
|
||||
"android",
|
||||
typeName("$MPP_PACKAGE.KotlinAndroidTargetPreset"),
|
||||
typeName("$MPP_PACKAGE.KotlinAndroidTarget")
|
||||
)
|
||||
|
||||
// Note: modifying these sets should also be reflected in the MPP plugin code, see 'setupDefaultPresets'
|
||||
private val nativeTargetsWithHostTests =
|
||||
setOf(KonanTarget.LINUX_X64, KonanTarget.MACOS_X64, KonanTarget.MACOS_ARM64, KonanTarget.MINGW_X64)
|
||||
@@ -79,8 +67,3 @@ internal val nativePresetEntries = HostManager().targets
|
||||
|
||||
KotlinPresetEntry(target.presetName, typeName(presetType), typeName(targetType), deprecation)
|
||||
}
|
||||
|
||||
internal val allPresetEntries = listOf(
|
||||
jvmPresetEntry,
|
||||
androidPresetEntry
|
||||
) + nativePresetEntries
|
||||
|
||||
Reference in New Issue
Block a user