[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 {
|
plugins {
|
||||||
repositories {
|
id("org.jetbrains.kotlin.multiplatform")
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'kotlin-multiplatform'
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin.targets.fromPreset(kotlin.presets.js, 'nodeJs') {
|
kotlin {
|
||||||
nodejs()
|
js("nodeJs") {
|
||||||
|
nodejs()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
+6
-12
@@ -1,22 +1,16 @@
|
|||||||
buildscript {
|
plugins {
|
||||||
repositories {
|
id("org.jetbrains.kotlin.multiplatform")
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: "kotlin-multiplatform"
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin.targets.fromPreset(kotlin.presets.js, 'browser') {
|
kotlin {
|
||||||
browser()
|
js("browser") {
|
||||||
|
browser()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
-50
@@ -44,17 +44,6 @@ abstract class KotlinMultiplatformExtension(project: Project) :
|
|||||||
targets
|
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>) {
|
fun targets(configure: Action<TargetsFromPresetExtension>) {
|
||||||
configure.execute(presetExtension)
|
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 =
|
internal fun KotlinTarget.isProducedFromPreset(kotlinTargetPreset: KotlinTargetPreset<*>): Boolean =
|
||||||
preset == kotlinTargetPreset
|
preset == kotlinTargetPreset
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user