[Gradle, JS] No error on default compiler
^KT-57480 fixed
This commit is contained in:
committed by
Space Team
parent
38138bf079
commit
723aa84ea7
+4
-17
@@ -15,6 +15,7 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion
|
|||||||
import org.gradle.jvm.toolchain.JavaToolchainSpec
|
import org.gradle.jvm.toolchain.JavaToolchainSpec
|
||||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsSingleTargetPreset
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsSingleTargetPreset
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||||
@@ -231,14 +232,13 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun warnAboutDeprecatedCompiler(project: Project, compilerType: KotlinJsCompilerType?) {
|
internal fun warnAboutDeprecatedCompiler(project: Project, compilerType: KotlinJsCompilerType) {
|
||||||
if (PropertiesProvider(project).jsCompilerNoWarn) return
|
if (PropertiesProvider(project).jsCompilerNoWarn) return
|
||||||
val logger = project.logger
|
val logger = project.logger
|
||||||
when (compilerType) {
|
when (compilerType) {
|
||||||
KotlinJsCompilerType.LEGACY -> logger.warn(LEGACY_DEPRECATED)
|
KotlinJsCompilerType.LEGACY -> logger.warn(LEGACY_DEPRECATED)
|
||||||
KotlinJsCompilerType.IR -> {}
|
KotlinJsCompilerType.IR -> {}
|
||||||
KotlinJsCompilerType.BOTH -> logger.warn(BOTH_DEPRECATED)
|
KotlinJsCompilerType.BOTH -> logger.warn(BOTH_DEPRECATED)
|
||||||
null -> throw GradleException(DEFAULT_COMPILER_ERROR)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,19 +264,6 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
|||||||
|==========
|
|==========
|
||||||
|
|
|
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
|
|
||||||
private val DEFAULT_COMPILER_ERROR =
|
|
||||||
"""
|
|
||||||
|
|
|
||||||
|==========
|
|
||||||
|This project currently uses the Kotlin/JS Legacy compiler backend, which has been deprecated and will be removed in a future release.
|
|
||||||
|Please migrate the project to the new IR-based compiler (https://kotl.in/jsir) by adding:
|
|
||||||
|- kotlin.js.compiler=ir to your gradle.properties file.
|
|
||||||
|- js(IR) { ... } to your build file.
|
|
||||||
|You can continue to use the deprecated legacy compiler in the current version of the toolchain by specifying it explicitly.
|
|
||||||
|==========
|
|
||||||
|
|
|
||||||
""".trimMargin()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use js() instead", ReplaceWith("js()"))
|
@Deprecated("Use js() instead", ReplaceWith("js()"))
|
||||||
@@ -289,7 +276,7 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
|||||||
return _target!!
|
return _target!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override var compilerTypeFromProperties: KotlinJsCompilerType? = null
|
override val compilerTypeFromProperties: KotlinJsCompilerType? = project.kotlinPropertiesProvider.jsCompiler
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
private fun jsInternal(
|
private fun jsInternal(
|
||||||
@@ -307,7 +294,7 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
|||||||
val compilerOrFromProperties = compiler ?: compilerTypeFromProperties
|
val compilerOrFromProperties = compiler ?: compilerTypeFromProperties
|
||||||
val compilerOrDefault = compilerOrFromProperties ?: defaultJsCompilerType
|
val compilerOrDefault = compilerOrFromProperties ?: defaultJsCompilerType
|
||||||
reportJsCompilerMode(compilerOrDefault)
|
reportJsCompilerMode(compilerOrDefault)
|
||||||
warnAboutDeprecatedCompiler(project, compilerOrFromProperties)
|
warnAboutDeprecatedCompiler(project, compilerOrDefault)
|
||||||
val target: KotlinJsTargetDsl = when (compilerOrDefault) {
|
val target: KotlinJsTargetDsl = when (compilerOrDefault) {
|
||||||
KotlinJsCompilerType.LEGACY -> legacyPreset
|
KotlinJsCompilerType.LEGACY -> legacyPreset
|
||||||
.also {
|
.also {
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal(
|
|||||||
) as KotlinTargetPreset<KotlinJsTargetDsl>,
|
) as KotlinTargetPreset<KotlinJsTargetDsl>,
|
||||||
configure
|
configure
|
||||||
).also { target ->
|
).also { target ->
|
||||||
warnAboutDeprecatedCompiler(target.project, kotlinJsCompilerType ?: compilerTypeFromProperties)
|
warnAboutDeprecatedCompiler(target.project, compilerOrDefault)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -288,7 +288,7 @@ abstract class AbstractKotlin2JsPluginWrapper(
|
|||||||
|
|
||||||
abstract class AbstractKotlinJsPluginWrapper : KotlinBasePluginWrapper() {
|
abstract class AbstractKotlinJsPluginWrapper : KotlinBasePluginWrapper() {
|
||||||
override fun getPlugin(project: Project): Plugin<Project> =
|
override fun getPlugin(project: Project): Plugin<Project> =
|
||||||
KotlinJsPlugin(project.getKotlinPluginVersion())
|
KotlinJsPlugin()
|
||||||
|
|
||||||
override val projectExtensionClass: KClass<out KotlinJsProjectExtension>
|
override val projectExtensionClass: KClass<out KotlinJsProjectExtension>
|
||||||
get() = KotlinJsProjectExtension::class
|
get() = KotlinJsProjectExtension::class
|
||||||
|
|||||||
+1
-4
@@ -19,9 +19,7 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.setupGeneralKotlinExtensionParamet
|
|||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
||||||
import org.jetbrains.kotlin.gradle.utils.*
|
import org.jetbrains.kotlin.gradle.utils.*
|
||||||
|
|
||||||
open class KotlinJsPlugin(
|
open class KotlinJsPlugin: Plugin<Project> {
|
||||||
private val kotlinPluginVersion: String
|
|
||||||
) : Plugin<Project> {
|
|
||||||
|
|
||||||
override fun apply(project: Project) {
|
override fun apply(project: Project) {
|
||||||
project.setupGeneralKotlinExtensionParameters()
|
project.setupGeneralKotlinExtensionParameters()
|
||||||
@@ -41,7 +39,6 @@ open class KotlinJsPlugin(
|
|||||||
kotlinExtension.apply {
|
kotlinExtension.apply {
|
||||||
irPreset = KotlinJsIrSingleTargetPreset(project)
|
irPreset = KotlinJsIrSingleTargetPreset(project)
|
||||||
legacyPreset = KotlinJsSingleTargetPreset(project)
|
legacyPreset = KotlinJsSingleTargetPreset(project)
|
||||||
compilerTypeFromProperties = PropertiesProvider(project).jsCompiler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.runProjectConfigurationHealthCheckWhenEvaluated {
|
project.runProjectConfigurationHealthCheckWhenEvaluated {
|
||||||
|
|||||||
Reference in New Issue
Block a user