[Gradle, JS] Remove js compiler property from MPP plugin
This commit is contained in:
+12
-4
@@ -5,8 +5,10 @@ import org.gradle.util.ConfigureUtil
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetsContainerWithPresets
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.JsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
|
||||
// DO NOT EDIT MANUALLY! Generated by org.jetbrains.kotlin.generators.gradle.dsl.MppPresetFunctionsCodegenKt
|
||||
|
||||
@@ -28,18 +30,24 @@ interface KotlinTargetContainerWithPresetFunctions : KotlinTargetsContainerWithP
|
||||
fun jvm(configure: Closure<*>) = jvm { ConfigureUtil.configure(configure, this) }
|
||||
|
||||
fun js(
|
||||
compiler: JsCompilerType = JsCompilerType.legacy,
|
||||
name: String = "js",
|
||||
configure: KotlinJsTargetDsl.() -> Unit = { }
|
||||
): KotlinJsTargetDsl =
|
||||
configureOrCreate(
|
||||
name,
|
||||
presets.getByName("js") as KotlinTargetPreset<KotlinJsTargetDsl>,
|
||||
presets.getByName(
|
||||
lowerCamelCaseName(
|
||||
"js",
|
||||
if (compiler == JsCompilerType.legacy) "" else compiler.name
|
||||
)
|
||||
) as KotlinTargetPreset<KotlinJsTargetDsl>,
|
||||
configure
|
||||
)
|
||||
|
||||
fun js() = js("js") { }
|
||||
fun js(name: String) = js(name) { }
|
||||
fun js(name: String, configure: Closure<*>) = js(name) { ConfigureUtil.configure(configure, this) }
|
||||
fun js() = js(name = "js") { }
|
||||
fun js(name: String) = js(name = name) { }
|
||||
fun js(name: String, configure: Closure<*>) = js(name = name) { ConfigureUtil.configure(configure, this) }
|
||||
fun js(configure: Closure<*>) = js { ConfigureUtil.configure(configure, this) }
|
||||
|
||||
fun android(
|
||||
|
||||
+18
-21
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.gradle.plugin.sources.checkSourceSetVisibilityRequir
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.sourceSetDependencyConfigurationByScope
|
||||
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
|
||||
import org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin
|
||||
import org.jetbrains.kotlin.gradle.targets.js.JsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
@@ -75,10 +74,10 @@ class KotlinMultiplatformPlugin(
|
||||
addExtension("presets", presets)
|
||||
|
||||
isGradleMetadataAvailable =
|
||||
featurePreviews.activeFeatures.find { it.name == "GRADLE_METADATA" }?.let { metadataFeature ->
|
||||
isGradleMetadataExperimental = true
|
||||
featurePreviews.isFeatureEnabled(metadataFeature)
|
||||
} ?: true // the feature entry will be gone once the feature is stable
|
||||
featurePreviews.activeFeatures.find { it.name == "GRADLE_METADATA" }?.let { metadataFeature ->
|
||||
isGradleMetadataExperimental = true
|
||||
featurePreviews.isFeatureEnabled(metadataFeature)
|
||||
} ?: true // the feature entry will be gone once the feature is stable
|
||||
}
|
||||
|
||||
setupDefaultPresets(project)
|
||||
@@ -136,7 +135,7 @@ class KotlinMultiplatformPlugin(
|
||||
|
||||
// Also set ad-hoc free compiler args from the internal project property
|
||||
freeCompilerArgsProvider = project.provider {
|
||||
val propertyValue = with (project.extensions.extraProperties) {
|
||||
val propertyValue = with(project.extensions.extraProperties) {
|
||||
val sourceSetFreeCompilerArgsPropertyName = sourceSetFreeCompilerArgsPropertyName(sourceSet.name)
|
||||
if (has(sourceSetFreeCompilerArgsPropertyName)) {
|
||||
get(sourceSetFreeCompilerArgsPropertyName)
|
||||
@@ -154,21 +153,17 @@ class KotlinMultiplatformPlugin(
|
||||
}
|
||||
|
||||
fun setupDefaultPresets(project: Project) {
|
||||
val propertiesProvider = PropertiesProvider(project)
|
||||
|
||||
with(project.multiplatformExtension.presets) {
|
||||
add(KotlinJvmTargetPreset(project, kotlinPluginVersion))
|
||||
when (propertiesProvider.jsCompiler) {
|
||||
JsCompilerType.legacy -> add(KotlinJsTargetPreset(project, kotlinPluginVersion, null))
|
||||
JsCompilerType.ir -> add(KotlinJsIrTargetPreset(project, kotlinPluginVersion, false))
|
||||
JsCompilerType.both -> add(
|
||||
KotlinJsTargetPreset(
|
||||
project,
|
||||
kotlinPluginVersion,
|
||||
KotlinJsIrTargetPreset(project, kotlinPluginVersion, true)
|
||||
)
|
||||
add(KotlinJsTargetPreset(project, kotlinPluginVersion, null))
|
||||
add(KotlinJsIrTargetPreset(project, kotlinPluginVersion, false))
|
||||
add(
|
||||
KotlinJsTargetPreset(
|
||||
project,
|
||||
kotlinPluginVersion,
|
||||
KotlinJsIrTargetPreset(project, kotlinPluginVersion, true)
|
||||
)
|
||||
}
|
||||
)
|
||||
add(KotlinAndroidTargetPreset(project, kotlinPluginVersion))
|
||||
add(KotlinJvmWithJavaTargetPreset(project, kotlinPluginVersion))
|
||||
|
||||
@@ -215,7 +210,9 @@ class KotlinMultiplatformPlugin(
|
||||
|
||||
// Publish the root publication only if Gradle metadata publishing is enabled:
|
||||
project.tasks.withType(AbstractPublishToMaven::class.java).configureEach { publishTask ->
|
||||
publishTask.onlyIf { publishTask.publication != rootPublication || project.multiplatformExtension.isGradleMetadataAvailable }
|
||||
publishTask.onlyIf {
|
||||
publishTask.publication != rootPublication || project.multiplatformExtension.isGradleMetadataAvailable
|
||||
}
|
||||
}
|
||||
|
||||
// Enforce the order of creating the publications, since the metadata publication is used in the other publications:
|
||||
@@ -224,8 +221,8 @@ class KotlinMultiplatformPlugin(
|
||||
.withType(AbstractKotlinTarget::class.java).matching { it.publishable && it.name != METADATA_TARGET_NAME }
|
||||
.all {
|
||||
if (it is KotlinAndroidTarget || it is KotlinMetadataTarget)
|
||||
// Android targets have their variants created in afterEvaluate; TODO handle this better?
|
||||
// Kotlin Metadata targets rely on complete source sets hierearchy and cannot be inspected for publication earlier
|
||||
// Android targets have their variants created in afterEvaluate; TODO handle this better?
|
||||
// Kotlin Metadata targets rely on complete source sets hierearchy and cannot be inspected for publication earlier
|
||||
project.whenEvaluated { it.createMavenPublications(publishing.publications) }
|
||||
else
|
||||
it.createMavenPublications(publishing.publications)
|
||||
|
||||
+9
-3
@@ -10,12 +10,13 @@ package org.jetbrains.kotlin.gradle.plugin.mpp
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.targets.js.JsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTargetConfigurator
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.IR_TARGET_SUFFIX
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetConfigurator
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
|
||||
open class KotlinJsTargetPreset(
|
||||
project: Project,
|
||||
@@ -50,7 +51,12 @@ open class KotlinJsTargetPreset(
|
||||
kotlinPluginVersion
|
||||
)
|
||||
|
||||
override fun getName(): String = PRESET_NAME
|
||||
override fun getName(): String {
|
||||
return lowerCamelCaseName(
|
||||
PRESET_NAME,
|
||||
irPreset?.let { JsCompilerType.both.name }
|
||||
)
|
||||
}
|
||||
|
||||
override fun createCompilationFactory(forTarget: KotlinOnlyTarget<KotlinJsCompilation>): KotlinJsCompilationFactory {
|
||||
return KotlinJsCompilationFactory(project, forTarget, irPreset?.let { (forTarget as KotlinJsTarget).irTarget })
|
||||
|
||||
+6
-1
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinCompilationFactory
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinOnlyTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.targets.js.JsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
|
||||
open class KotlinJsIrTargetPreset(
|
||||
project: Project,
|
||||
@@ -39,7 +41,10 @@ open class KotlinJsIrTargetPreset(
|
||||
KotlinJsIrCompilationFactory(project, forTarget)
|
||||
|
||||
companion object {
|
||||
const val PRESET_NAME = "js"
|
||||
val PRESET_NAME = lowerCamelCaseName(
|
||||
"js",
|
||||
JsCompilerType.ir.name
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user