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