[Gradle, MPP] Remove the fromPreset convention
#KT-52976 In Progress
This commit is contained in:
committed by
Space Team
parent
93d1932ccb
commit
6c5061a19f
+6
-12
@@ -1,22 +1,16 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-multiplatform'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin.targets.fromPreset(kotlin.presets.js, 'nodeJs') {
|
||||
nodejs()
|
||||
kotlin {
|
||||
js("nodeJs") {
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
+6
-12
@@ -1,22 +1,16 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
apply plugin: "kotlin-multiplatform"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin.targets.fromPreset(kotlin.presets.js, 'browser') {
|
||||
browser()
|
||||
kotlin {
|
||||
js("browser") {
|
||||
browser()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
-50
@@ -44,17 +44,6 @@ abstract class KotlinMultiplatformExtension(project: Project) :
|
||||
targets
|
||||
)
|
||||
|
||||
init {
|
||||
val presetExtensionWithDeprecation = project.objects.newInstance(
|
||||
TargetsFromPresetExtensionWithDeprecation::class.java,
|
||||
project.logger,
|
||||
project.path,
|
||||
presetExtension
|
||||
)
|
||||
@Suppress("DEPRECATION")
|
||||
DslObject(targets).addConvention("fromPreset", presetExtensionWithDeprecation)
|
||||
}
|
||||
|
||||
fun targets(configure: Action<TargetsFromPresetExtension>) {
|
||||
configure.execute(presetExtension)
|
||||
}
|
||||
@@ -147,45 +136,6 @@ internal abstract class DefaultTargetsFromPresetExtension @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract class TargetsFromPresetExtensionWithDeprecation @Inject constructor(
|
||||
private val logger: Logger,
|
||||
private val projectPath: String,
|
||||
private val parentExtension: DefaultTargetsFromPresetExtension
|
||||
) : TargetsFromPresetExtension,
|
||||
NamedDomainObjectCollection<KotlinTarget> by parentExtension.targets {
|
||||
|
||||
override fun <T : KotlinTarget> fromPreset(
|
||||
preset: KotlinTargetPreset<T>,
|
||||
name: String,
|
||||
configureAction: T.() -> Unit
|
||||
): T {
|
||||
printDeprecationMessage(preset, name)
|
||||
return parentExtension.fromPreset(preset, name, configureAction)
|
||||
}
|
||||
|
||||
override fun <T : KotlinTarget> fromPreset(
|
||||
preset: KotlinTargetPreset<T>,
|
||||
name: String,
|
||||
configureAction: Action<T>
|
||||
): T {
|
||||
printDeprecationMessage(preset, name)
|
||||
return parentExtension.fromPreset(preset, name, configureAction)
|
||||
}
|
||||
|
||||
private fun <T : KotlinTarget> printDeprecationMessage(
|
||||
preset: KotlinTargetPreset<T>,
|
||||
targetName: String
|
||||
) {
|
||||
logger.warn(
|
||||
"""
|
||||
Creating Kotlin target ${preset.name}:${targetName} via convention 'target.fromPreset()' in $projectPath project is deprecated!"
|
||||
|
||||
Check https://kotlinlang.org/docs/multiplatform-set-up-targets.html documentation how to create MPP target.
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun KotlinTarget.isProducedFromPreset(kotlinTargetPreset: KotlinTargetPreset<*>): Boolean =
|
||||
preset == kotlinTargetPreset
|
||||
|
||||
|
||||
Reference in New Issue
Block a user