[Gradle, JS] Fix warning in case when js target declared twice
^KT-55099 fixed
This commit is contained in:
committed by
Space Team
parent
774bed875a
commit
358943c7cb
+16
@@ -1147,6 +1147,22 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("kotlin/js compiler warning")
|
||||||
|
@GradleTest
|
||||||
|
fun testKotlinJsCompilerWarn(gradleVersion: GradleVersion) {
|
||||||
|
project(
|
||||||
|
"kotlin-js-compiler-warn",
|
||||||
|
gradleVersion,
|
||||||
|
buildOptions = defaultBuildOptions.copy(jsOptions = defaultJsOptions.copy(compileNoWarn = false, jsCompilerType = null))
|
||||||
|
) {
|
||||||
|
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||||
|
|
||||||
|
build("assemble") {
|
||||||
|
assertOutputDoesNotContain("This project currently uses the Kotlin/JS Legacy")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@DisplayName("dependencies are resolved to metadata")
|
@DisplayName("dependencies are resolved to metadata")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testResolveJsProjectDependencyToMetadata(gradleVersion: GradleVersion) {
|
fun testResolveJsProjectDependencyToMetadata(gradleVersion: GradleVersion) {
|
||||||
|
|||||||
+7
-2
@@ -50,6 +50,7 @@ data class BuildOptions(
|
|||||||
val jsCompilerType: KotlinJsCompilerType? = null,
|
val jsCompilerType: KotlinJsCompilerType? = null,
|
||||||
val incrementalJs: Boolean? = null,
|
val incrementalJs: Boolean? = null,
|
||||||
val incrementalJsKlib: Boolean? = null,
|
val incrementalJsKlib: Boolean? = null,
|
||||||
|
val compileNoWarn: Boolean = true
|
||||||
)
|
)
|
||||||
|
|
||||||
fun toArguments(
|
fun toArguments(
|
||||||
@@ -113,9 +114,13 @@ data class BuildOptions(
|
|||||||
jsOptions.incrementalJsKlib?.let { arguments.add("-Pkotlin.incremental.js.klib=$it") }
|
jsOptions.incrementalJsKlib?.let { arguments.add("-Pkotlin.incremental.js.klib=$it") }
|
||||||
jsOptions.useIrBackend?.let { arguments.add("-Pkotlin.js.useIrBackend=$it") }
|
jsOptions.useIrBackend?.let { arguments.add("-Pkotlin.js.useIrBackend=$it") }
|
||||||
jsOptions.jsCompilerType?.let { arguments.add("-Pkotlin.js.compiler=$it") }
|
jsOptions.jsCompilerType?.let { arguments.add("-Pkotlin.js.compiler=$it") }
|
||||||
|
// because we have legacy compiler tests, we need nowarn for compiler testing
|
||||||
|
if (jsOptions.compileNoWarn) {
|
||||||
|
arguments.add("-Pkotlin.js.compiler.nowarn=true")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
arguments.add("-Pkotlin.js.compiler.nowarn=true")
|
||||||
}
|
}
|
||||||
// because we have legacy compiler tests, we need nowarn for compiler testing
|
|
||||||
arguments.add("-Pkotlin.js.compiler.nowarn=true")
|
|
||||||
|
|
||||||
if (androidVersion != null) {
|
if (androidVersion != null) {
|
||||||
arguments.add("-Pandroid_tools_version=${androidVersion}")
|
arguments.add("-Pandroid_tools_version=${androidVersion}")
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.BOTH as BOTH_TYPE
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
js(BOTH)
|
||||||
|
js(BOTH_TYPE) {
|
||||||
|
useCommonJs()
|
||||||
|
browser {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
js {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
rootProject.name = "kotlin-js-browser"
|
||||||
|
|
||||||
|
include("base")
|
||||||
|
include("lib")
|
||||||
|
include("app")
|
||||||
+5
-3
@@ -85,8 +85,10 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal(
|
|||||||
): KotlinJsTargetDsl {
|
): KotlinJsTargetDsl {
|
||||||
val existingTarget = getExistingTarget(name, compiler)
|
val existingTarget = getExistingTarget(name, compiler)
|
||||||
|
|
||||||
val compilerOrDefault = compiler
|
val kotlinJsCompilerType = (compiler
|
||||||
?: existingTarget?.calculateJsCompilerType()
|
?: existingTarget?.calculateJsCompilerType())
|
||||||
|
|
||||||
|
val compilerOrDefault = kotlinJsCompilerType
|
||||||
?: defaultJsCompilerType
|
?: defaultJsCompilerType
|
||||||
|
|
||||||
val targetName = getTargetName(name, compilerOrDefault)
|
val targetName = getTargetName(name, compilerOrDefault)
|
||||||
@@ -111,7 +113,7 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal(
|
|||||||
) as KotlinTargetPreset<KotlinJsTargetDsl>,
|
) as KotlinTargetPreset<KotlinJsTargetDsl>,
|
||||||
configure
|
configure
|
||||||
).also { target ->
|
).also { target ->
|
||||||
warnAboutDeprecatedCompiler(target.project, compiler ?: compilerTypeFromProperties)
|
warnAboutDeprecatedCompiler(target.project, kotlinJsCompilerType ?: compilerTypeFromProperties)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user