[Gradle, JS] Remove K/JS legacy support from Gradle plugin
This commit is contained in:
committed by
Space Team
parent
61dbe7fb75
commit
54debac4c5
@@ -980,18 +980,18 @@ public final class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType$Compa
|
||||
}
|
||||
|
||||
public abstract interface class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder {
|
||||
public abstract fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public abstract synthetic fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public abstract fun getCompilerTypeFromProperties ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public abstract fun getDefaultJsCompilerType ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public abstract fun getIR ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public abstract fun getLEGACY ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public abstract synthetic fun getLEGACY ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder$DefaultImpls {
|
||||
public static fun getBOTH (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public static synthetic fun getBOTH (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public static fun getDefaultJsCompilerType (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public static fun getIR (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public static fun getLEGACY (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public static synthetic fun getLEGACY (Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeHolder;)Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
}
|
||||
|
||||
public final class org/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerTypeKt {
|
||||
|
||||
+3
@@ -30,9 +30,12 @@ enum class KotlinJsCompilerType {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("This method is planned to be removed")
|
||||
val KotlinJsCompilerType.lowerName
|
||||
get() = name.toLowerCase(Locale.ENGLISH)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("This method is planned to be removed")
|
||||
fun String.removeJsCompilerSuffix(compilerType: KotlinJsCompilerType): String {
|
||||
val truncatedString = removeSuffix(compilerType.lowerName)
|
||||
if (this != truncatedString) {
|
||||
|
||||
+4
-3
@@ -8,20 +8,21 @@
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
interface KotlinJsCompilerTypeHolder {
|
||||
@Deprecated("Because only IR compiler is left, no more necessary to know about compiler type in properties")
|
||||
val compilerTypeFromProperties: KotlinJsCompilerType?
|
||||
|
||||
val defaultJsCompilerType: KotlinJsCompilerType
|
||||
get() = compilerTypeFromProperties ?: KotlinJsCompilerType.IR
|
||||
get() = KotlinJsCompilerType.IR
|
||||
|
||||
// Necessary to get rid of KotlinJsCompilerType import in build script
|
||||
@Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler")
|
||||
@Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler", level = DeprecationLevel.HIDDEN)
|
||||
val LEGACY: KotlinJsCompilerType
|
||||
get() = KotlinJsCompilerType.LEGACY
|
||||
|
||||
val IR: KotlinJsCompilerType
|
||||
get() = KotlinJsCompilerType.IR
|
||||
|
||||
@Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler")
|
||||
@Deprecated("Legacy compiler is deprecated. Migrate your project to the new IR-based compiler", level = DeprecationLevel.HIDDEN)
|
||||
val BOTH: KotlinJsCompilerType
|
||||
get() = KotlinJsCompilerType.BOTH
|
||||
}
|
||||
+1
-11
@@ -13,7 +13,6 @@ import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM
|
||||
import org.jetbrains.kotlin.gradle.model.ModelContainer
|
||||
import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.report.BuildReportType
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
@@ -248,13 +247,12 @@ abstract class BaseGradleIT {
|
||||
}
|
||||
|
||||
// the second parameter is for using with ToolingAPI, that do not like --daemon/--no-daemon options at all
|
||||
data class BuildOptions constructor(
|
||||
data class BuildOptions(
|
||||
val withDaemon: Boolean = false,
|
||||
val daemonOptionSupported: Boolean = true,
|
||||
val incremental: Boolean? = null,
|
||||
val incrementalJs: Boolean? = null,
|
||||
val incrementalJsKlib: Boolean? = null,
|
||||
val jsIrBackend: Boolean? = null,
|
||||
val androidHome: File? = null,
|
||||
val javaHome: File? = null,
|
||||
val gradleUserHome: File? = null,
|
||||
@@ -269,7 +267,6 @@ abstract class BaseGradleIT {
|
||||
val withBuildCache: Boolean = false,
|
||||
val kaptOptions: KaptOptions? = null,
|
||||
val parallelTasksInProject: Boolean = false,
|
||||
val jsCompilerType: KotlinJsCompilerType? = null,
|
||||
val configurationCache: Boolean = false,
|
||||
val configurationCacheProblems: ConfigurationCacheProblems = ConfigurationCacheProblems.FAIL,
|
||||
val warningMode: WarningMode = WarningMode.Fail,
|
||||
@@ -881,9 +878,6 @@ abstract class BaseGradleIT {
|
||||
}
|
||||
options.incrementalJs?.let { add("-Pkotlin.incremental.js=$it") }
|
||||
options.incrementalJsKlib?.let { add("-Pkotlin.incremental.js.klib=$it") }
|
||||
options.jsIrBackend?.let { add("-Pkotlin.js.useIrBackend=$it") }
|
||||
// because we have legacy compiler tests, we need nowarn for compiler testing
|
||||
add("-Pkotlin.js.compiler.nowarn=true")
|
||||
options.usePreciseJavaTracking?.let { add("-Pkotlin.incremental.usePreciseJavaTracking=$it") }
|
||||
options.useClasspathSnapshot?.let { add("-P${COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM.property}=$it") }
|
||||
options.androidGradlePluginVersion?.let { add("-Pandroid_tools_version=$it") }
|
||||
@@ -915,10 +909,6 @@ abstract class BaseGradleIT {
|
||||
|
||||
if (options.parallelTasksInProject) add("--parallel") else add("--no-parallel")
|
||||
|
||||
options.jsCompilerType?.let {
|
||||
add("-Pkotlin.js.compiler=$it")
|
||||
}
|
||||
|
||||
if (options.dryRun) {
|
||||
add("--dry-run")
|
||||
}
|
||||
|
||||
+6
@@ -21,6 +21,12 @@ class ExecutionStrategyJsIT : ExecutionStrategyIT() {
|
||||
) +
|
||||
"""
|
||||
|
|
||||
|kotlin {
|
||||
| js {
|
||||
|
|
||||
| }
|
||||
|}
|
||||
|
|
||||
|afterEvaluate {
|
||||
| tasks.named('compileKotlinJs') {
|
||||
| kotlinOptions.outputFile = "${'$'}{project.projectDir}/web/js/"
|
||||
|
||||
+4
-7
@@ -10,7 +10,6 @@ import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.internals.MULTIPLATFORM_PROJECT_METADATA_JSON_FILE_NAME
|
||||
import org.jetbrains.kotlin.gradle.internals.parseKotlinSourceSetMetadataFromJson
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinProjectStructureMetadata
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.ModuleDependencyIdentifier
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.SourceSetMetadataLayout
|
||||
@@ -287,12 +286,11 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("Works with published JS library")
|
||||
fun testHmppWithPublishedJsBothDependency(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||
fun testHmppWithPublishedJsIrDependency(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||
@Suppress("DEPRECATION")
|
||||
publishThirdPartyLib(
|
||||
projectName = "hierarchical-mpp-with-js-published-modules/third-party-lib",
|
||||
withGranularMetadata = true,
|
||||
jsCompilerType = KotlinJsCompilerType.BOTH,
|
||||
gradleVersion = gradleVersion,
|
||||
localRepoDir = tempDir
|
||||
)
|
||||
@@ -302,7 +300,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
"hierarchical-mpp-with-js-published-modules/my-lib-foo",
|
||||
gradleVersion,
|
||||
localRepoDir = tempDir,
|
||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = KotlinJsCompilerType.IR))
|
||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions())
|
||||
)
|
||||
) {
|
||||
build("publish", "assemble")
|
||||
@@ -316,7 +314,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
nativeProject(
|
||||
projectName = "hierarchical-mpp-with-js-project-dependency",
|
||||
gradleVersion = gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = KotlinJsCompilerType.IR))
|
||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions())
|
||||
)
|
||||
) {
|
||||
build("assemble")
|
||||
@@ -385,7 +383,6 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
private fun publishThirdPartyLib(
|
||||
projectName: String = "third-party-lib".withPrefix,
|
||||
withGranularMetadata: Boolean,
|
||||
jsCompilerType: KotlinJsCompilerType = KotlinJsCompilerType.IR,
|
||||
gradleVersion: GradleVersion,
|
||||
localRepoDir: Path,
|
||||
beforePublishing: TestProject.() -> Unit = { }
|
||||
@@ -394,7 +391,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
projectName = projectName,
|
||||
gradleVersion = gradleVersion,
|
||||
localRepoDir = localRepoDir,
|
||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = jsCompilerType))
|
||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions())
|
||||
).apply {
|
||||
beforePublishing()
|
||||
|
||||
|
||||
+6
-14
@@ -6,15 +6,13 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
|
||||
abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) : KGPBaseTest() {
|
||||
@JsGradlePluginTests
|
||||
abstract class JsIrConfigurationCacheIT : KGPBaseTest() {
|
||||
@Suppress("DEPRECATION")
|
||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||
useIrBackend = irBackend,
|
||||
jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY,
|
||||
)
|
||||
|
||||
final override val defaultBuildOptions =
|
||||
@@ -47,7 +45,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
||||
":app:packageJson",
|
||||
":app:publicPackageJson",
|
||||
":app:compileKotlinJs",
|
||||
if (irBackend) ":app:compileProductionExecutableKotlinJs" else ":app:processDceKotlinJs",
|
||||
":app:compileProductionExecutableKotlinJs",
|
||||
":app:browserProductionWebpack",
|
||||
)
|
||||
)
|
||||
@@ -68,7 +66,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
||||
assertTasksUpToDate(
|
||||
":app:packageJson",
|
||||
":app:publicPackageJson",
|
||||
if (irBackend) ":app:compileProductionExecutableKotlinJs" else ":app:processDceKotlinJs",
|
||||
":app:compileProductionExecutableKotlinJs",
|
||||
":app:browserProductionWebpack",
|
||||
)
|
||||
}
|
||||
@@ -88,7 +86,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
||||
":rootPackageJson",
|
||||
":compileKotlinJs",
|
||||
":nodeTest",
|
||||
) + if (irBackend) listOf(":compileProductionExecutableKotlinJs") else emptyList()
|
||||
) + listOf(":compileProductionExecutableKotlinJs")
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -110,7 +108,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
||||
":rootPackageJson",
|
||||
":compileKotlinJs",
|
||||
":nodeTest",
|
||||
) + if (irBackend) listOf(":compileProductionExecutableKotlinJs") else emptyList()
|
||||
) + listOf(":compileProductionExecutableKotlinJs")
|
||||
assertTasksUpToDate(*upToDateTasks.toTypedArray())
|
||||
}
|
||||
}
|
||||
@@ -151,9 +149,3 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
class JsConfigurationCacheIT : AbstractJsConfigurationCacheIT(irBackend = false)
|
||||
|
||||
@JsGradlePluginTests
|
||||
class JsIrConfigurationCacheIT : AbstractJsConfigurationCacheIT(irBackend = true)
|
||||
|
||||
-7
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.condition.OS
|
||||
@@ -18,15 +17,9 @@ import org.junit.jupiter.api.condition.OS
|
||||
@OsCondition(supportedOn = [OS.LINUX, OS.MAC, OS.WINDOWS], enabledOnCI = [OS.LINUX, OS.MAC, OS.WINDOWS])
|
||||
@NativeGradlePluginTests
|
||||
class JsSetupConfigurationCacheIT : KGPBaseTest() {
|
||||
@Suppress("DEPRECATION")
|
||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||
useIrBackend = true,
|
||||
jsCompilerType = KotlinJsCompilerType.IR
|
||||
)
|
||||
|
||||
override val defaultBuildOptions =
|
||||
super.defaultBuildOptions.copy(
|
||||
jsOptions = defaultJsOptions,
|
||||
configurationCache = true,
|
||||
configurationCacheProblems = BaseGradleIT.ConfigurationCacheProblems.FAIL
|
||||
)
|
||||
|
||||
+82
-319
@@ -10,7 +10,6 @@ import com.google.gson.JsonNull
|
||||
import com.google.gson.JsonObject
|
||||
import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KLIB_TYPE
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject
|
||||
@@ -22,8 +21,6 @@ import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockCopyTask.Companion.YA
|
||||
import org.jetbrains.kotlin.gradle.tasks.USING_JS_IR_BACKEND_MESSAGE
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions.Gradle.G_7_6
|
||||
import org.jetbrains.kotlin.gradle.util.jsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.util.normalizePath
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.condition.DisabledIf
|
||||
import java.nio.file.Files
|
||||
@@ -33,7 +30,7 @@ import kotlin.streams.toList
|
||||
import kotlin.test.*
|
||||
|
||||
@JsGradlePluginTests
|
||||
class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
||||
class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
|
||||
|
||||
@DisplayName("TS type declarations are generated")
|
||||
@GradleTest
|
||||
@@ -245,7 +242,7 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
||||
|
||||
assertEquals(
|
||||
setOf(
|
||||
projectPath.resolve("build/js/packages/kotlin-js-browser-app/kotlin/kotlin-js-browser-base-js-ir.mjs").toFile(),
|
||||
projectPath.resolve("build/js/packages/kotlin-js-browser-app/kotlin/kotlin-js-browser-base.mjs").toFile(),
|
||||
projectPath.resolve("build/js/packages/kotlin-js-browser-app/kotlin/foo/foo.txt").toFile(),
|
||||
),
|
||||
modified.toSet()
|
||||
@@ -682,145 +679,9 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
class Kotlin2JsGradlePluginIT : AbstractKotlin2JsGradlePluginIT(false) {
|
||||
@DisplayName("builtins are loaded")
|
||||
@GradleTest
|
||||
fun testKotlinJsBuiltins(gradleVersion: GradleVersion) {
|
||||
project("kotlinBuiltins", gradleVersion) {
|
||||
subProject("app").buildGradle.modify { originalScript ->
|
||||
buildString {
|
||||
append(
|
||||
originalScript.replace(
|
||||
"id \"org.jetbrains.kotlin.jvm\"",
|
||||
"id \"org.jetbrains.kotlin.js\""
|
||||
)
|
||||
)
|
||||
append(
|
||||
"""
|
||||
|
|
||||
|afterEvaluate {
|
||||
| tasks.named('compileKotlinJs') {
|
||||
| kotlinOptions.outputFile = "${'$'}{project.projectDir}/out/out.js"
|
||||
| kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
| }
|
||||
|}
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
build("build")
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("js files from dependency are installed")
|
||||
@GradleTest
|
||||
fun testKotlinJsDependencyWithJsFiles(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-dependency-with-js-files", gradleVersion) {
|
||||
build("packageJson") {
|
||||
val dependency = "2p-parser-core"
|
||||
val version = "0.11.1"
|
||||
|
||||
val dependencyDirectory = projectPath.resolve("build/js/packages_imported/$dependency/$version")
|
||||
assertDirectoryExists(dependencyDirectory)
|
||||
|
||||
val packageJson = dependencyDirectory
|
||||
.resolve(NpmProject.PACKAGE_JSON)
|
||||
.let {
|
||||
Gson().fromJson(it.readText(), PackageJson::class.java)
|
||||
}
|
||||
|
||||
assertEquals(dependency, packageJson.name)
|
||||
assertEquals(version, packageJson.version)
|
||||
assertEquals("$dependency.js", packageJson.main)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("DCE in dev mode replaces outdated dependencies on incremental build")
|
||||
@GradleTest
|
||||
fun testIncrementalDceDevModeOnExternalDependency(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-browser-project", gradleVersion) {
|
||||
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
build(":base:jsLegacyJar")
|
||||
|
||||
val baseSubproject = subProject("base")
|
||||
val libSubproject = subProject("lib")
|
||||
val baseJar = baseSubproject.projectPath.resolve("build/libs/base-legacy.jar")
|
||||
val originalBaseJar = libSubproject.projectPath.resolve("base.1.jar")
|
||||
val modifiedBaseJar = libSubproject.projectPath.resolve("base.2.jar")
|
||||
Files.copy(baseJar, originalBaseJar)
|
||||
|
||||
baseSubproject.kotlinSourcesDir().resolve("Base.kt").appendText(
|
||||
"""
|
||||
|
|
||||
|fun bestRandom() = 4
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build(":base:jsLegacyJar")
|
||||
|
||||
Files.copy(baseJar, modifiedBaseJar)
|
||||
|
||||
val baseBuildscript = baseSubproject.buildGradleKts
|
||||
val libBuildscript = libSubproject.buildGradleKts
|
||||
baseBuildscript.modify {
|
||||
it.replace("js(\"both\")", "js(\"both\") { moduleName = \"base2\" }")
|
||||
}
|
||||
libBuildscript.modify {
|
||||
it.replace("implementation(project(\":base\"))", "implementation(files(\"${normalizePath(originalBaseJar.toString())}\"))")
|
||||
}
|
||||
libBuildscript.appendText(
|
||||
"""
|
||||
|
|
||||
|kotlin.js().browser {
|
||||
| dceTask {
|
||||
| dceOptions.devMode = true
|
||||
| }
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
val baseDceFile = projectPath.resolve("build/js/packages/kotlin-js-browser-lib/kotlin-dce/kotlin-js-browser-base-js-legacy.js")
|
||||
|
||||
build(":lib:processDceKotlinJs") {
|
||||
assertFileDoesNotContain(baseDceFile, "bestRandom")
|
||||
}
|
||||
|
||||
libBuildscript.modify {
|
||||
it.replace(normalizePath(originalBaseJar.toString()), normalizePath(modifiedBaseJar.toString()))
|
||||
}
|
||||
|
||||
build(":lib:processDceKotlinJs") {
|
||||
assertFileContains(baseDceFile, "bestRandom")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean) : KGPBaseTest() {
|
||||
@Suppress("DEPRECATION")
|
||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||
useIrBackend = irBackend,
|
||||
jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY,
|
||||
)
|
||||
|
||||
final override val defaultBuildOptions =
|
||||
super.defaultBuildOptions.copy(
|
||||
jsOptions = defaultJsOptions,
|
||||
)
|
||||
|
||||
protected fun BuildResult.checkIrCompilationMessage() {
|
||||
if (irBackend) {
|
||||
assertOutputContains(USING_JS_IR_BACKEND_MESSAGE)
|
||||
} else {
|
||||
assertOutputDoesNotContain(USING_JS_IR_BACKEND_MESSAGE)
|
||||
}
|
||||
assertOutputContains(USING_JS_IR_BACKEND_MESSAGE)
|
||||
}
|
||||
|
||||
@DisplayName("js customized output is included into jar")
|
||||
@@ -854,11 +715,8 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
":compileKotlin2Js",
|
||||
":compileTestKotlin2Js"
|
||||
)
|
||||
if (irBackend) {
|
||||
assertFileInProjectExists("build/kotlin2js/main/default/manifest")
|
||||
} else {
|
||||
assertFileInProjectExists("build/kotlin2js/main/module.js")
|
||||
}
|
||||
assertFileInProjectExists("build/kotlin2js/main/default/manifest")
|
||||
|
||||
assertFileInProjectExists("build/kotlin2js/test/module-tests.js")
|
||||
}
|
||||
}
|
||||
@@ -878,44 +736,42 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
@GradleTest
|
||||
fun testKotlinJsSourceMap(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsProjectWithSourceMap", gradleVersion) {
|
||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
||||
if (irBackend) {
|
||||
val appSourceMap = subProject("app").projectPath
|
||||
.resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-app.js.map")
|
||||
assertFileContains(
|
||||
appSourceMap,
|
||||
"\"../../../../../../src/main/kotlin/main.kt\"",
|
||||
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||
"\"sourcesContent\":[null",
|
||||
)
|
||||
build("compileDevelopmentExecutableKotlinJs") {
|
||||
val appSourceMap = subProject("app").projectPath
|
||||
.resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-app.js.map")
|
||||
assertFileContains(
|
||||
appSourceMap,
|
||||
"\"../../../../../../src/main/kotlin/main.kt\"",
|
||||
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||
"\"sourcesContent\":[null",
|
||||
)
|
||||
|
||||
// The default should be generating simple names.
|
||||
assertFileContains(appSourceMap, "somewhereOverTheRainbow")
|
||||
assertFileDoesNotContain(appSourceMap, "\"names\":[]")
|
||||
assertFileDoesNotContain(appSourceMap, "app.C.somewhereOverTheRainbow")
|
||||
// The default should be generating simple names.
|
||||
assertFileContains(appSourceMap, "somewhereOverTheRainbow")
|
||||
assertFileDoesNotContain(appSourceMap, "\"names\":[]")
|
||||
assertFileDoesNotContain(appSourceMap, "app.C.somewhereOverTheRainbow")
|
||||
|
||||
val libSourceMap = subProject("app").projectPath
|
||||
.resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-lib.js.map")
|
||||
assertFileContains(
|
||||
libSourceMap,
|
||||
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||
"\"sourcesContent\":[null",
|
||||
)
|
||||
val libSourceMap = subProject("app").projectPath
|
||||
.resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-lib.js.map")
|
||||
assertFileContains(
|
||||
libSourceMap,
|
||||
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||
"\"sourcesContent\":[null",
|
||||
)
|
||||
|
||||
// The default should be generating simple names.
|
||||
assertFileDoesNotContain(libSourceMap, "\"names\":[]")
|
||||
// The default should be generating simple names.
|
||||
assertFileDoesNotContain(libSourceMap, "\"names\":[]")
|
||||
|
||||
val libSourceMap2 = projectPath
|
||||
.resolve("build/js/packages/$projectName-app/kotlin/$projectName-lib.js.map")
|
||||
assertFileContains(
|
||||
libSourceMap2,
|
||||
"\"../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||
"\"sourcesContent\":[null",
|
||||
)
|
||||
val libSourceMap2 = projectPath
|
||||
.resolve("build/js/packages/$projectName-app/kotlin/$projectName-lib.js.map")
|
||||
assertFileContains(
|
||||
libSourceMap2,
|
||||
"\"../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||
"\"sourcesContent\":[null",
|
||||
)
|
||||
|
||||
// The default should be generating simple names.
|
||||
assertFileDoesNotContain(libSourceMap2, "\"names\":[]")
|
||||
}
|
||||
// The default should be generating simple names.
|
||||
assertFileDoesNotContain(libSourceMap2, "\"names\":[]")
|
||||
assertFileContains(
|
||||
projectPath
|
||||
.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map"),
|
||||
@@ -927,50 +783,11 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("prefix is added to paths in source map")
|
||||
@DisabledIf(
|
||||
"org.jetbrains.kotlin.gradle.AbstractKotlin2JsGradlePluginIT#getIrBackend",
|
||||
disabledReason = "Source maps are not supported in IR backend"
|
||||
)
|
||||
@GradleTest
|
||||
fun testKotlinJsSourceMapCustomPrefix(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsProjectWithSourceMap", gradleVersion) {
|
||||
buildGradleKts.appendText(
|
||||
"""
|
||||
|project("app") {
|
||||
| tasks.withType<KotlinJsCompile> {
|
||||
| kotlinOptions.sourceMapPrefix = "appPrefix/"
|
||||
| }
|
||||
|}
|
||||
|
|
||||
|project("lib") {
|
||||
| tasks.withType<KotlinJsCompile> {
|
||||
| kotlinOptions.sourceMapPrefix = "libPrefix/"
|
||||
| }
|
||||
|}
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
||||
val mapFilePath = projectPath
|
||||
.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map")
|
||||
assertFileContains(
|
||||
mapFilePath,
|
||||
"\"appPrefix/src/main/kotlin/main.kt\"",
|
||||
"\"appPrefix/libPrefix/src/main/kotlin/foo.kt\"",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("path in source maps are remapped for custom outputFile")
|
||||
@GradleTest
|
||||
fun testKotlinJsSourceMapCustomOutputFile(gradleVersion: GradleVersion) {
|
||||
project("kotlin2JsProjectWithSourceMap", gradleVersion) {
|
||||
val taskSelector = if (irBackend)
|
||||
"named<KotlinJsIrLink>(\"compileDevelopmentExecutableKotlinJs\")"
|
||||
else
|
||||
"withType<KotlinJsCompile>"
|
||||
val taskSelector = "named<KotlinJsIrLink>(\"compileDevelopmentExecutableKotlinJs\")"
|
||||
buildGradleKts.appendText(
|
||||
"""
|
||||
|project("app") {
|
||||
@@ -981,17 +798,12 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
||||
build("compileDevelopmentExecutableKotlinJs") {
|
||||
val mapFilePath = subProject("app").projectPath
|
||||
.resolve("build/kotlin2js/app.js.map")
|
||||
assertFileContains(mapFilePath, "\"../../src/main/kotlin/main.kt\"")
|
||||
if (irBackend) {
|
||||
// The IR BE generates correct paths for dependencies
|
||||
assertFileContains(mapFilePath, "\"../../../lib/src/main/kotlin/foo.kt\"")
|
||||
} else {
|
||||
// The legacy BE doesn't.
|
||||
assertFileContains(mapFilePath, "\"../../../../../lib/src/main/kotlin/foo.kt\"")
|
||||
}
|
||||
// The IR BE generates correct paths for dependencies
|
||||
assertFileContains(mapFilePath, "\"../../../lib/src/main/kotlin/foo.kt\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1010,7 +822,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
||||
build("compileDevelopmentExecutableKotlinJs") {
|
||||
val jsFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js")
|
||||
assertFileExists(jsFilePath)
|
||||
assertFileNotExists(Path("$jsFilePath.map"))
|
||||
@@ -1040,7 +852,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
||||
build("compileDevelopmentExecutableKotlinJs") {
|
||||
val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map")
|
||||
assertFileContains(
|
||||
mapFilePath,
|
||||
@@ -1073,7 +885,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
|
|
||||
""".trimMargin()
|
||||
)
|
||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
||||
build("compileDevelopmentExecutableKotlinJs") {
|
||||
val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map")
|
||||
assertFileDoesNotContain(
|
||||
mapFilePath,
|
||||
@@ -1089,24 +901,19 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
|
||||
@DisplayName("smoke test of org.jetbrains.kotlin.js plugin")
|
||||
@GradleTest
|
||||
@DisabledIf(
|
||||
"org.jetbrains.kotlin.gradle.AbstractKotlin2JsGradlePluginIT#getIrBackend",
|
||||
disabledReason = "kotlinx.html doesn't support IR"
|
||||
)
|
||||
fun testNewKotlinJsPlugin(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-plugin-project", gradleVersion) {
|
||||
build("publish", "processDceKotlinJs", "test", "processDceBenchmarkKotlinJs") {
|
||||
build("publish", "assemble", "test", "compileBenchmarkKotlinJs") {
|
||||
assertTasksExecuted(
|
||||
":compileKotlinJs", ":compileTestKotlinJs", ":compileBenchmarkKotlinJs",
|
||||
":processDceKotlinJs", ":processDceBenchmarkKotlinJs"
|
||||
":compileKotlinJs", ":compileTestKotlinJs", ":compileBenchmarkKotlinJs"
|
||||
)
|
||||
|
||||
val moduleDir = projectPath.resolve("build/repo/com/example/kotlin-js-plugin/1.0/")
|
||||
|
||||
val publishedJar = moduleDir.resolve("kotlin-js-plugin-1.0.jar")
|
||||
val publishedJar = moduleDir.resolve("kotlin-js-plugin-1.0.klib")
|
||||
ZipFile(publishedJar.toFile()).use { zip ->
|
||||
val entries = zip.entries().asSequence().map { it.name }
|
||||
assertTrue { "kotlin-js-plugin.js" in entries }
|
||||
assertTrue { "default/manifest" in entries }
|
||||
}
|
||||
|
||||
val publishedPom = moduleDir.resolve("kotlin-js-plugin-1.0.pom")
|
||||
@@ -1117,17 +924,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
|
||||
assertFileExists(moduleDir.resolve("kotlin-js-plugin-1.0-sources.jar"))
|
||||
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin/kotlin.js")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin/kotlin.js.map")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-test/kotlin-test.js")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-test/kotlin-test.js.map")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-test-js-runner/kotlin-test-nodejs-runner.js")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-test-js-runner/kotlin-test-nodejs-runner.js.map")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin/kotlin/kotlin-js-plugin.js")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin/kotlin/kotlin-js-plugin.js.map")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js")
|
||||
assertFileInProjectExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js.map")
|
||||
|
||||
assertTestResults(projectPath.resolve("tests.xml"), "nodeTest")
|
||||
}
|
||||
}
|
||||
@@ -1182,7 +978,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
build("jsJar") {
|
||||
val archive = projectPath
|
||||
.resolve("build/libs")
|
||||
.allFilesWithExtension(if (irBackend) KLIB_TYPE else "jar")
|
||||
.allFilesWithExtension(KLIB_TYPE)
|
||||
.single()
|
||||
|
||||
ZipFile(archive.toFile()).use { zipFile ->
|
||||
@@ -1253,7 +1049,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
build("jsJar") {
|
||||
val archive = Files.list(projectPath.resolve("build").resolve("libs")).use { files ->
|
||||
files
|
||||
.filter { it.extension == if (irBackend) KLIB_TYPE else "jar" }
|
||||
.filter { it.extension == KLIB_TYPE }
|
||||
.toList()
|
||||
.single()
|
||||
}
|
||||
@@ -1278,59 +1074,31 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
project("kotlin-js-browser-project", gradleVersion) {
|
||||
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
if (irBackend) {
|
||||
gradleProperties.appendText(jsCompilerType(KotlinJsCompilerType.IR))
|
||||
}
|
||||
|
||||
if (irBackend) {
|
||||
build("compileProductionExecutableKotlinJs") {
|
||||
assertTasksExecuted(":app:compileProductionExecutableKotlinJs")
|
||||
assert(task(":kotlinNpmInstall") == null) {
|
||||
printBuildOutput()
|
||||
"NPM install should not be run"
|
||||
}
|
||||
build("compileProductionExecutableKotlinJs") {
|
||||
assertTasksExecuted(":app:compileProductionExecutableKotlinJs")
|
||||
assert(task(":kotlinNpmInstall") == null) {
|
||||
printBuildOutput()
|
||||
"NPM install should not be run"
|
||||
}
|
||||
}
|
||||
|
||||
build("assemble") {
|
||||
assertTasksExecuted(":app:browserProductionWebpack")
|
||||
|
||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base-js-ir")
|
||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base-js-legacy")
|
||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base")
|
||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-lib")
|
||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-app")
|
||||
|
||||
if (irBackend) {
|
||||
assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/app.js")
|
||||
} else {
|
||||
assertFileInProjectExists("app/build/distributions/app.js")
|
||||
}
|
||||
|
||||
if (!irBackend) {
|
||||
assertTasksExecuted(":app:processDceKotlinJs")
|
||||
|
||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce")
|
||||
|
||||
assertFileInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce/kotlin.js")
|
||||
assertFileInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce/kotlin-js-browser-app.js")
|
||||
assertFileInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce/kotlin-js-browser-lib.js")
|
||||
assertFileInProjectExists("build/js/packages/kotlin-js-browser-app/kotlin-dce/kotlin-js-browser-base-js-legacy.js")
|
||||
|
||||
assertFileInProjectExists("app/build/distributions/app.js.map")
|
||||
}
|
||||
assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/app.js")
|
||||
}
|
||||
|
||||
build("clean", "browserDistribution") {
|
||||
assertTasksExecuted(
|
||||
":app:processResources",
|
||||
if (irBackend) ":app:browserProductionExecutableDistributeResources" else ":app:browserDistributeResources"
|
||||
":app:browserProductionExecutableDistributeResources"
|
||||
)
|
||||
|
||||
if (irBackend) {
|
||||
assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/index.html")
|
||||
} else {
|
||||
assertFileInProjectExists("app/build/distributions/index.html")
|
||||
}
|
||||
assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/index.html")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1359,22 +1127,6 @@ 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("NodeJs test with custom fork options")
|
||||
@GradleTest
|
||||
fun testNodeJsForkOptions(gradleVersion: GradleVersion) {
|
||||
@@ -1791,19 +1543,6 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
class GeneralKotlin2JsGradlePluginIT : KGPBaseTest() {
|
||||
@DisplayName("js with both backends mode builds successfully")
|
||||
@GradleTest
|
||||
fun testJsBothModeWithTests(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-both-mode-with-tests", gradleVersion) {
|
||||
build("build") {
|
||||
assertNoBuildWarnings(setOf("w: 'kotlin-js' Gradle plugin is deprecated and will be removed in the future."))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("nodejs up-to-date check works")
|
||||
@GradleTest
|
||||
@@ -1900,4 +1639,28 @@ class GeneralKotlin2JsGradlePluginIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("js files from dependency are installed")
|
||||
@GradleTest
|
||||
fun testKotlinJsDependencyWithJsFiles(gradleVersion: GradleVersion) {
|
||||
project("kotlin-js-dependency-with-js-files", gradleVersion) {
|
||||
build("packageJson") {
|
||||
val dependency = "2p-parser-core"
|
||||
val version = "0.11.1"
|
||||
|
||||
val dependencyDirectory = projectPath.resolve("build/js/packages_imported/$dependency/$version")
|
||||
assertDirectoryExists(dependencyDirectory)
|
||||
|
||||
val packageJson = dependencyDirectory
|
||||
.resolve(NpmProject.PACKAGE_JSON)
|
||||
.let {
|
||||
Gson().fromJson(it.readText(), PackageJson::class.java)
|
||||
}
|
||||
|
||||
assertEquals(dependency, packageJson.name)
|
||||
assertEquals(version, packageJson.version)
|
||||
assertEquals("$dependency.js", packageJson.main)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-2
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.Disabled
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
@@ -38,7 +37,6 @@ class Kotlin2FirJsIrBeIncrementalCompilationIT : Kotlin2JsIrBeIncrementalCompila
|
||||
open class Kotlin2JsIrBeIncrementalCompilationIT : KGPBaseTest() {
|
||||
override val defaultBuildOptions = BuildOptions(
|
||||
jsOptions = BuildOptions.JsOptions(
|
||||
jsCompilerType = KotlinJsCompilerType.IR,
|
||||
incrementalJsKlib = true,
|
||||
incrementalJsIr = true
|
||||
),
|
||||
|
||||
-3
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
|
||||
@@ -14,8 +13,6 @@ import org.junit.jupiter.api.DisplayName
|
||||
class KotlinJsDomApiDependencyIT : KGPBaseTest() {
|
||||
|
||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||
useIrBackend = true,
|
||||
jsCompilerType = KotlinJsCompilerType.IR
|
||||
)
|
||||
|
||||
override val defaultBuildOptions =
|
||||
|
||||
-10
@@ -8,13 +8,10 @@ package org.jetbrains.kotlin.gradle
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.testkit.runner.BuildResult
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.tasks.USING_JS_INCREMENTAL_COMPILATION_MESSAGE
|
||||
import org.jetbrains.kotlin.gradle.tasks.USING_JS_IR_BACKEND_MESSAGE
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import kotlin.io.path.*
|
||||
import kotlin.test.*
|
||||
|
||||
@JsGradlePluginTests
|
||||
open class KotlinJsIr10IncrementalGradlePluginIT : AbstractKotlinJsIncrementalGradlePluginIT(
|
||||
@@ -29,19 +26,12 @@ class KotlinJsFirIncrementalGradlePluginIT : KotlinJsIr10IncrementalGradlePlugin
|
||||
)
|
||||
}
|
||||
|
||||
@JsGradlePluginTests
|
||||
open class KotlinJsLegacy10IncrementalGradlePluginIT : AbstractKotlinJsIncrementalGradlePluginIT(
|
||||
irBackend = false
|
||||
)
|
||||
|
||||
@JsGradlePluginTests
|
||||
abstract class AbstractKotlinJsIncrementalGradlePluginIT(
|
||||
protected val irBackend: Boolean
|
||||
) : KGPBaseTest() {
|
||||
@Suppress("DEPRECATION")
|
||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||
useIrBackend = irBackend,
|
||||
jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY
|
||||
)
|
||||
|
||||
override val defaultBuildOptions =
|
||||
|
||||
-3
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonObject
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.Distribution.Companion.DIST
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
@@ -21,8 +20,6 @@ abstract class KotlinJsIrLibraryGradlePluginITBase : KGPBaseTest() {
|
||||
|
||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(
|
||||
jsOptions = BuildOptions.JsOptions(
|
||||
useIrBackend = true,
|
||||
jsCompilerType = KotlinJsCompilerType.IR
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
+3
@@ -86,6 +86,9 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
|
||||
gradleProperties.appendText(
|
||||
"\nkotlin.stdlib.default.dependency=false"
|
||||
)
|
||||
gradleProperties.appendText(
|
||||
"\nkotlin.js.stdlib.dom.api.included=false"
|
||||
)
|
||||
checkTaskCompileClasspath(
|
||||
"compileKotlinJs",
|
||||
listOf(),
|
||||
|
||||
+11
-148
@@ -14,10 +14,8 @@ import org.jetbrains.kotlin.gradle.native.*
|
||||
import org.jetbrains.kotlin.gradle.native.MPPNativeTargets
|
||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProject
|
||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProjectWithPluginDsl
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.plugin.ProjectLocalConfigurations
|
||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
||||
import org.jetbrains.kotlin.gradle.plugin.lowerName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.UnsatisfiedSourceSetVisibilityException
|
||||
@@ -257,72 +255,27 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun testLibAndAppJsLegacy() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
KotlinJsCompilerType.LEGACY
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppJsIr() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
KotlinJsCompilerType.IR
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun testLibAndAppJsBoth() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
KotlinJsCompilerType.BOTH
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDslJsLegacy() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
KotlinJsCompilerType.LEGACY
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDslJsIr() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
KotlinJsCompilerType.IR
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDslJsBoth() = doTestLibAndAppJsBothCompilers(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
KotlinJsCompilerType.BOTH
|
||||
)
|
||||
|
||||
private fun doTestLibAndAppJsBothCompilers(
|
||||
libProjectName: String,
|
||||
appProjectName: String,
|
||||
jsCompilerType: KotlinJsCompilerType,
|
||||
) {
|
||||
val libProject = transformProjectWithPluginsDsl(libProjectName, directoryPrefix = "both-js-lib-and-app")
|
||||
val appProject = transformProjectWithPluginsDsl(appProjectName, directoryPrefix = "both-js-lib-and-app")
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val compileTasksNames =
|
||||
listOf(
|
||||
*(if (jsCompilerType != KotlinJsCompilerType.BOTH) {
|
||||
arrayOf("NodeJs")
|
||||
} else {
|
||||
arrayOf(
|
||||
"NodeJs${KotlinJsCompilerType.LEGACY.lowerName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}",
|
||||
"NodeJs${KotlinJsCompilerType.IR.lowerName.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }}",
|
||||
)
|
||||
}),
|
||||
).map { ":compileKotlin$it" }
|
||||
val compileTasksNames = listOf(":compileKotlinNodeJs")
|
||||
|
||||
with(libProject) {
|
||||
gradleProperties().appendText(
|
||||
@@ -333,7 +286,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
)
|
||||
build(
|
||||
"publish",
|
||||
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
|
||||
options = defaultBuildOptions()
|
||||
) {
|
||||
assertSuccessful()
|
||||
assertTasksNotExecuted(":compileCommonMainKotlinMetadata")
|
||||
@@ -342,7 +295,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
val groupDir = projectDir.resolve("repo/com/example")
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val jsExtension = if (jsCompilerType == KotlinJsCompilerType.LEGACY) "jar" else "klib"
|
||||
val jsExtension = "klib"
|
||||
val jsJarName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension"
|
||||
val metadataJarName = "sample-lib/1.0/sample-lib-1.0.jar"
|
||||
|
||||
@@ -365,21 +318,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
when (jsCompilerType) {
|
||||
KotlinJsCompilerType.LEGACY -> {
|
||||
val jsJar = ZipFile(groupDir.resolve(jsJarName))
|
||||
val compiledJs = jsJar.getInputStream(jsJar.getEntry("sample-lib.js")).reader().readText()
|
||||
Assert.assertTrue("function id(" in compiledJs)
|
||||
Assert.assertTrue("function idUsage(" in compiledJs)
|
||||
Assert.assertTrue("function expectedFun(" in compiledJs)
|
||||
Assert.assertTrue("function main(" in compiledJs)
|
||||
}
|
||||
KotlinJsCompilerType.IR -> {
|
||||
groupDir.resolve(jsJarName).exists()
|
||||
}
|
||||
KotlinJsCompilerType.BOTH -> {}
|
||||
}
|
||||
groupDir.resolve(jsJarName).exists()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,46 +337,17 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
// we use `maven { setUrl(...) }` because this syntax actually works both for Groovy and Kotlin DSLs in Gradle
|
||||
gradleBuildScript().appendText("\nrepositories { maven { setUrl(\"$libLocalRepoUri\") } }")
|
||||
|
||||
fun CompiledProject.checkAppBuild(compilerType: KotlinJsCompilerType) {
|
||||
fun CompiledProject.checkAppBuild() {
|
||||
assertSuccessful()
|
||||
val compileTaskNames = if (jsCompilerType == compilerType) {
|
||||
compileTasksNames.toTypedArray()
|
||||
} else {
|
||||
arrayOf(":compileKotlinNodeJs")
|
||||
}
|
||||
assertTasksExecuted(*compileTaskNames)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
if (jsCompilerType == KotlinJsCompilerType.LEGACY) {
|
||||
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
|
||||
Assert.assertTrue(contains("console.info"))
|
||||
Assert.assertTrue(contains("function nodeJsMain("))
|
||||
}
|
||||
}
|
||||
assertTasksExecuted(compileTasksNames)
|
||||
}
|
||||
|
||||
build(
|
||||
"assemble",
|
||||
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
|
||||
options = defaultBuildOptions()
|
||||
) {
|
||||
checkAppBuild(jsCompilerType)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
if (jsCompilerType == KotlinJsCompilerType.BOTH) {
|
||||
@Suppress("DEPRECATION")
|
||||
listOf(
|
||||
KotlinJsCompilerType.LEGACY,
|
||||
KotlinJsCompilerType.IR
|
||||
).forEach {
|
||||
build(
|
||||
"assemble",
|
||||
"--rerun-tasks",
|
||||
options = defaultBuildOptions().copy(jsCompilerType = it)
|
||||
) {
|
||||
checkAppBuild(it)
|
||||
}
|
||||
}
|
||||
checkAppBuild()
|
||||
}
|
||||
|
||||
// Now run again with a project dependency instead of a module one:
|
||||
@@ -453,9 +363,9 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
"clean",
|
||||
"assemble",
|
||||
"--rerun-tasks",
|
||||
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
|
||||
options = defaultBuildOptions()
|
||||
) {
|
||||
checkAppBuild(jsCompilerType)
|
||||
checkAppBuild()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1021,7 +931,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
@Suppress("DEPRECATION")
|
||||
libProject.build(
|
||||
"publish",
|
||||
options = buildOptions.copy(jsCompilerType = KotlinJsCompilerType.BOTH)
|
||||
options = buildOptions
|
||||
) {
|
||||
assertSuccessful()
|
||||
}
|
||||
@@ -1063,25 +973,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
build(
|
||||
"printMetadataFiles",
|
||||
options = buildOptions.copy(jsCompilerType = KotlinJsCompilerType.IR)
|
||||
) {
|
||||
// After introducing Resolvable Metadata Dependencies configuration
|
||||
// resolving nodeJsMainResolvableDependenciesMetadata is expected to fail for dependencies that have published
|
||||
// both Legacy and IR klibs.
|
||||
// Previously these Metadata Dependencies Configurations got resolved into platform artifacts which is incorrect
|
||||
// and is just result of gradle's attempt to resolve to anything.
|
||||
// TODO: Remove this test after removing Resolvable Metadata Dependencies for platform source sets.
|
||||
assertFailed()
|
||||
|
||||
assertContains(
|
||||
"However we cannot choose between the following variants of com.example:sample-lib-nodejs:1.0:",
|
||||
"- nodeJsIrApiElements-published",
|
||||
"- nodeJsLegacyApiElements-published",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1518,34 +1409,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testJsDceInMpp() = with(Project("new-mpp-js-dce", gradleVersion)) {
|
||||
setupWorkingDir()
|
||||
gradleProperties().appendText(
|
||||
"""
|
||||
|
||||
kotlin.compiler.execution.strategy=in-process
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
build(
|
||||
"runRhino",
|
||||
options = defaultBuildOptions().copy(jsCompilerType = KotlinJsCompilerType.LEGACY)
|
||||
) {
|
||||
assertSuccessful()
|
||||
assertTasksExecuted(":mainProject:processDceBrowserKotlinJs")
|
||||
|
||||
val pathPrefix = "mainProject/build/kotlin-js-min/"
|
||||
assertFileExists("$pathPrefix/exampleapp.js.map")
|
||||
assertFileExists("$pathPrefix/examplelib.js.map")
|
||||
assertFileContains("$pathPrefix/exampleapp.js.map", "\"../../src/browserMain/kotlin/exampleapp/main.kt\"")
|
||||
|
||||
assertFileExists("$pathPrefix/kotlin.js")
|
||||
assertTrue(fileInWorkingDir("$pathPrefix/kotlin.js").length() < 500 * 1000, "Looks like kotlin.js file was not minified by DCE")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDefaultSourceSetsDsl() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
setupWorkingDir()
|
||||
|
||||
-9
@@ -6,8 +6,6 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
@@ -41,13 +39,6 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
||||
testResolveAllConfigurations(subproject = innerProject.projectName) {
|
||||
assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.klib")
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
gradleProperties().appendText(jsCompilerType(KotlinJsCompilerType.LEGACY))
|
||||
|
||||
testResolveAllConfigurations(subproject = innerProject.projectName, skipSetup = true) {
|
||||
assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.jar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-1
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
|
||||
|
||||
+1
-13
@@ -11,7 +11,6 @@ import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM
|
||||
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||
import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.report.BuildReportType
|
||||
import org.junit.jupiter.api.condition.OS
|
||||
import java.util.*
|
||||
@@ -57,12 +56,9 @@ data class BuildOptions(
|
||||
)
|
||||
|
||||
data class JsOptions(
|
||||
val useIrBackend: Boolean? = null,
|
||||
val jsCompilerType: KotlinJsCompilerType? = null,
|
||||
val incrementalJs: Boolean? = null,
|
||||
val incrementalJsKlib: Boolean? = null,
|
||||
val incrementalJsIr: Boolean? = null,
|
||||
val compileNoWarn: Boolean = true,
|
||||
val incrementalJsIr: Boolean? = null
|
||||
)
|
||||
|
||||
data class NativeOptions(
|
||||
@@ -141,14 +137,6 @@ data class BuildOptions(
|
||||
jsOptions.incrementalJs?.let { arguments.add("-Pkotlin.incremental.js=$it") }
|
||||
jsOptions.incrementalJsKlib?.let { arguments.add("-Pkotlin.incremental.js.klib=$it") }
|
||||
jsOptions.incrementalJsIr?.let { arguments.add("-Pkotlin.incremental.js.ir=$it") }
|
||||
jsOptions.useIrBackend?.let { arguments.add("-Pkotlin.js.useIrBackend=$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")
|
||||
}
|
||||
|
||||
if (androidVersion != null) {
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.util
|
||||
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
||||
|
||||
fun jsCompilerType(compilerType: KotlinJsCompilerType) =
|
||||
"\n${KotlinJsCompilerType.jsCompilerProperty}=$compilerType"
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
kotlin.code.style=official
|
||||
kotlin.js.generate.executable.default=false
|
||||
kotlin.code.style=official
|
||||
+1
-5
@@ -25,8 +25,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
-4
@@ -32,8 +32,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
+1
-5
@@ -40,8 +40,4 @@ publishing {
|
||||
repositories {
|
||||
maven { setUrl("file://${projectDir.absolutePath.replace('\\', '/')}/repo") }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -53,8 +53,4 @@ publishing {
|
||||
repositories {
|
||||
maven { url "file://${projectDir.absolutePath.replace('\\', '/')}/repo" }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
kotlin.code.style=official
|
||||
kotlin.js.generate.executable.default=false
|
||||
kotlin.mpp.enableCInteropCommonization=true
|
||||
kotlin.mpp.enableIntransitiveMetadataConfiguration=true
|
||||
|
||||
+1
-2
@@ -1,2 +1 @@
|
||||
kotlin.code.style=official
|
||||
kotlin.js.generate.executable.default=false
|
||||
kotlin.code.style=official
|
||||
-1
@@ -1 +0,0 @@
|
||||
kotlin.js.compiler=legacy
|
||||
+4
-4
@@ -11,6 +11,10 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js()
|
||||
}
|
||||
|
||||
if (project.findProperty("mppProjectDependency") == "true") {
|
||||
|
||||
dependencies {
|
||||
@@ -27,8 +31,4 @@ if (project.findProperty("mppProjectDependency") == "true") {
|
||||
api "com.example:mpp-lib:1.0"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
+1
-5
@@ -39,8 +39,4 @@ publishing {
|
||||
repositories {
|
||||
maven { setUrl("${rootProject.buildDir}/repo") }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -57,8 +57,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -86,8 +86,4 @@ kotlin {
|
||||
dependsOn(linuxAndJsTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -93,8 +93,4 @@ publishing {
|
||||
repositories {
|
||||
maven("<localRepo>")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -105,8 +105,4 @@ publishing {
|
||||
repositories {
|
||||
maven("<localRepo>")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -54,8 +54,4 @@ publishing {
|
||||
repositories {
|
||||
maven("<localRepo>")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -40,8 +40,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -26,8 +26,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -35,8 +35,4 @@ publishing {
|
||||
repositories {
|
||||
maven("<localRepo>")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -37,8 +37,4 @@ publishing {
|
||||
from(components["kotlin"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+2
-12
@@ -20,22 +20,12 @@ dependencies {
|
||||
testImplementation "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||
}
|
||||
|
||||
def jsUseIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true
|
||||
|
||||
tasks.named("compileKotlinJs", Kotlin2JsCompile) {
|
||||
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
|
||||
if (jsUseIrBackend) {
|
||||
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
} else {
|
||||
it.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
}
|
||||
|
||||
tasks.named("compileTestKotlinJs", Kotlin2JsCompile) {
|
||||
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js"
|
||||
if (jsUseIrBackend) {
|
||||
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
} else {
|
||||
it.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
}
|
||||
|
||||
+1
-4
@@ -33,7 +33,4 @@ tasks.named("browserTest") {
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack> {
|
||||
dependsOn("foo")
|
||||
}
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+4
@@ -1,3 +1,7 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.js"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js()
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
plugins {
|
||||
kotlin("js")
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
version = "1.0"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
@Suppress("DEPRECATION")
|
||||
js(BOTH) {
|
||||
nodejs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
kotlin.js.compiler.nowarn=true
|
||||
-1
@@ -1 +0,0 @@
|
||||
fun foo() = 5
|
||||
-1
@@ -1 +0,0 @@
|
||||
fun bar() = foo()
|
||||
-7
@@ -71,13 +71,6 @@ rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJ
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>("compileKotlinJs") {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
tasks.named<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>("compileTestKotlinJs") {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink>().configureEach {
|
||||
kotlinOptions {
|
||||
moduleKind = "es"
|
||||
|
||||
+5
-12
@@ -1,4 +1,4 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.BOTH as BOTH_TYPE
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR as IR_TYPE
|
||||
|
||||
plugins {
|
||||
kotlin("js")
|
||||
@@ -10,18 +10,11 @@ dependencies {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
kotlin {
|
||||
js("both")
|
||||
js(BOTH)
|
||||
js(BOTH_TYPE) {
|
||||
js("ir")
|
||||
js(IR)
|
||||
js(IR_TYPE) {
|
||||
useCommonJs()
|
||||
browser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>("compileKotlinJsLegacy") {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
tasks.named<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>("compileTestKotlinJsLegacy") {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-8
@@ -13,11 +13,4 @@ kotlin {
|
||||
browser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>("compileKotlinJs") {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
tasks.named<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>("compileTestKotlinJs") {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.BOTH as BOTH_TYPE
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
kotlin {
|
||||
js(BOTH)
|
||||
js(BOTH_TYPE) {
|
||||
useCommonJs()
|
||||
browser {
|
||||
}
|
||||
}
|
||||
js {
|
||||
|
||||
}
|
||||
}
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
rootProject.name = "kotlin-js-browser"
|
||||
|
||||
include("base")
|
||||
include("lib")
|
||||
include("app")
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.BOTH as BOTH_TYPE
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
+1
-4
@@ -27,7 +27,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -35,7 +35,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -24,8 +24,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-8
@@ -19,11 +19,4 @@ kotlin {
|
||||
nodejs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("compileKotlinJs", org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
tasks.named("compileTestKotlinJs", org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
-4
@@ -57,7 +57,3 @@ publishing {
|
||||
maven("$buildDir/repo")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
-1
@@ -1,3 +1,2 @@
|
||||
kotlin.tests.individualTaskReports=true
|
||||
#because of dependency (kotlinx-html) which is not klib yet
|
||||
kotlin.js.compiler=legacy
|
||||
|
||||
+1
-5
@@ -64,8 +64,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -19,8 +19,4 @@ kotlin {
|
||||
}
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -17,8 +17,4 @@ kotlin {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -25,8 +25,4 @@ kotlin {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-8
@@ -19,9 +19,7 @@ def outDir = "${buildDir}/kotlin2js/main/"
|
||||
compileKotlin2Js.kotlinOptions.moduleKind = "amd"
|
||||
compileKotlin2Js.kotlinOptions.outputFile = outDir + "app.js"
|
||||
|
||||
if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) {
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
}
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
@@ -60,9 +58,4 @@ build.doLast {
|
||||
into "${buildDir}/kotlin2js/main/"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
runRhino.dependsOn build
|
||||
+2
-4
@@ -20,7 +20,5 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
}
|
||||
|
||||
if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) {
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
}
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
+2
-5
@@ -31,17 +31,14 @@ def outDir = "${buildDir}/kotlin2js/main/"
|
||||
|
||||
compileKotlin2Js.kotlinOptions.outputFile = outDir + "test-library.js"
|
||||
|
||||
def isIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean()
|
||||
if (isIrBackend) {
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir"]
|
||||
}
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir"]
|
||||
|
||||
jar {
|
||||
from sourceSets.main.allSource
|
||||
include "**/*.kt"
|
||||
|
||||
from outDir
|
||||
include (isIrBackend ? "**/*" : "**/*.js")
|
||||
include ("**/*")
|
||||
|
||||
manifest {
|
||||
attributes(
|
||||
|
||||
+1
-3
@@ -25,9 +25,7 @@ compileKotlin2Js.kotlinOptions.outputFile = "${projectDir}/web/js/app.js"
|
||||
compileKotlin2Js.kotlinOptions.suppressWarnings = true
|
||||
compileKotlin2Js.kotlinOptions.verbose = true
|
||||
|
||||
if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) {
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
}
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
|
||||
build.doLast {
|
||||
configurations.compile.each { File file ->
|
||||
|
||||
+5
-20
@@ -12,7 +12,7 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
allprojects {
|
||||
subprojects {
|
||||
apply(plugin = "org.jetbrains.kotlin.js")
|
||||
|
||||
repositories {
|
||||
@@ -21,29 +21,21 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
val useIrBackend = (findProperty("kotlin.js.useIrBackend") as? String?)?.toBoolean() ?: false
|
||||
|
||||
val backend = if (useIrBackend) {
|
||||
KotlinJsCompilerType.IR
|
||||
} else {
|
||||
KotlinJsCompilerType.LEGACY
|
||||
kotlin {
|
||||
js()
|
||||
}
|
||||
|
||||
project("lib") {
|
||||
kotlin {
|
||||
js(backend) {
|
||||
js {
|
||||
browser()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<KotlinJsCompile>() {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
|
||||
project("app") {
|
||||
kotlin {
|
||||
js(backend) {
|
||||
js {
|
||||
browser()
|
||||
binaries.executable()
|
||||
}
|
||||
@@ -51,11 +43,4 @@ project("app") {
|
||||
implementation(project(":lib"))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<KotlinJsCompile>() {
|
||||
kotlinOptions {
|
||||
sourceMap = true
|
||||
freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-9
@@ -30,12 +30,6 @@ artifacts {
|
||||
|
||||
compileTestKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js"
|
||||
|
||||
if (project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true) {
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/"
|
||||
} else {
|
||||
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/"
|
||||
-1
@@ -1 +0,0 @@
|
||||
kotlin.js.compiler=legacy
|
||||
+1
-5
@@ -42,8 +42,4 @@ publishing {
|
||||
repositories {
|
||||
maven { setUrl("${rootProject.buildDir}/repo") }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -39,8 +39,4 @@ publishing {
|
||||
repositories {
|
||||
maven { setUrl("${rootProject.buildDir}/repo") }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -1,3 +1 @@
|
||||
kotlin.code.style=official
|
||||
kotlin.js.generate.executable.default=false
|
||||
kotlin.js.compiler=ir
|
||||
kotlin.code.style=official
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
kotlin.code.style=official
|
||||
kotlin.js.generate.executable.default=false
|
||||
|
||||
# Test is about compatibility, only version 1 was available in previous versions
|
||||
kotlin.mpp.androidSourceSetLayoutVersion=1
|
||||
+1
-5
@@ -79,8 +79,4 @@ task printCompilerPluginOptions {
|
||||
println sourceSet.name + '=cp=>' + cp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
-4
@@ -97,8 +97,4 @@ publishing {
|
||||
url = uri("$buildDir/repo")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js("nodeJs") {
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
nodeJsMainApi "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
||||
}
|
||||
|
||||
compileKotlinNodeJs.kotlinOptions.outputFile = "${buildDir}/examplelib.js"
|
||||
compileKotlinNodeJs.kotlinOptions.sourceMap = true
|
||||
|
||||
nodeJsJar {
|
||||
from buildDir
|
||||
include "**/*.js"
|
||||
include "**/*.js.map"
|
||||
}
|
||||
|
||||
nodeJsJar.dependsOn(compileKotlinNodeJs)
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
package examplelib
|
||||
|
||||
fun foo() = "foo"
|
||||
|
||||
fun bar() = "bar"
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.multiplatform")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
js("browser") {
|
||||
browser()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def browserMainImplConfigName =
|
||||
kotlin.getTargets().getByName("browser").getCompilations().getByName("main").getImplementationConfigurationName()
|
||||
|
||||
add(browserMainImplConfigName, project(":libraryProject"))
|
||||
add(browserMainImplConfigName, "org.jetbrains.kotlin:kotlin-stdlib-js")
|
||||
add(browserMainImplConfigName, "org.mozilla:rhino:1.7.7.1")
|
||||
}
|
||||
|
||||
tasks.named('compileKotlinBrowser') {
|
||||
kotlinOptions {
|
||||
sourceMap = true
|
||||
outputFile = "${buildDir}/web/exampleapp.js"
|
||||
suppressWarnings = true
|
||||
verbose = true
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJsDce).configureEach {
|
||||
keep("exampleapp.exampleapp.status")
|
||||
destinationDirectory = project.layout.buildDirectory.dir("kotlin-js-min")
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
tasks.register("runRhino", JavaExec) {
|
||||
dependsOn(tasks.named('processDceBrowserKotlinJs'))
|
||||
classpath = kotlin.targets.browser.compilations.main.runtimeDependencyFiles
|
||||
workingDir = "${buildDir}"
|
||||
mainClass = 'org.mozilla.javascript.tools.shell.Main'
|
||||
args = ["-opt", "-1",
|
||||
"-f", "kotlin-js-min/kotlin.js",
|
||||
"-f", "kotlin-js-min/examplelib.js",
|
||||
"-f", "kotlin-js-min/exampleapp.js",
|
||||
"-f", "../check.js"]
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
(function() {
|
||||
var status = exampleapp.exampleapp.status;
|
||||
if (status !== "foo") {
|
||||
throw new Error("Unexpected status: " + status);
|
||||
}
|
||||
})();
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package exampleapp
|
||||
|
||||
import examplelib.*
|
||||
|
||||
var status = "failure"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
status = foo()
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
include 'mainProject', 'libraryProject'
|
||||
+1
-5
@@ -23,8 +23,4 @@ kotlin {
|
||||
|
||||
js("server")
|
||||
js("client")
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
kotlin.js.compiler=ir
|
||||
+1
-5
@@ -91,8 +91,4 @@ tasks.register("resolveRuntimeDependencies", DefaultTask) {
|
||||
def configName = kotlin.targets.jvm6.compilations.main.runtimeDependencyConfigurationName
|
||||
configurations[configName].resolve()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -64,8 +64,4 @@ afterEvaluate {
|
||||
tasks["assemble"].dependsOn(compileKotlinTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -115,8 +115,4 @@ afterEvaluate {
|
||||
assemble.dependsOn compileKotlinTask
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -36,8 +36,4 @@ kotlin.sourceSets {
|
||||
|
||||
kotlin.target {
|
||||
nodejs()
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
}
|
||||
-4
@@ -16,7 +16,3 @@ kotlin {
|
||||
nodejs()
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
-4
@@ -24,7 +24,3 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtensi
|
||||
public fun getAndroidNativeTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getAppleMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getAppleTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public synthetic fun getBOTH ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public fun getCommonMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getCommonTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getCompilerTypeFromProperties ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
@@ -51,7 +51,7 @@ public abstract class org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtensi
|
||||
public fun getJsTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getJvmMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getJvmTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getLEGACY ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public synthetic fun getLEGACY ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||
public fun getLinuxMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getLinuxTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
public fun getMacosMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||
|
||||
+3
-3
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle.Stage.AfterFinaliseDsl
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.hierarchy.KotlinHierarchyDslImpl
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import javax.inject.Inject
|
||||
@@ -33,13 +32,14 @@ abstract class KotlinMultiplatformExtension
|
||||
|
||||
final override val targets: NamedDomainObjectCollection<KotlinTarget> = project.container(KotlinTarget::class.java)
|
||||
|
||||
@Deprecated("Because only IR compiler is left, no more necessary to know about compiler type in properties")
|
||||
override val compilerTypeFromProperties: KotlinJsCompilerType? = null
|
||||
|
||||
internal suspend fun awaitTargets(): NamedDomainObjectCollection<KotlinTarget> {
|
||||
AfterFinaliseDsl.await()
|
||||
return targets
|
||||
}
|
||||
|
||||
override val compilerTypeFromProperties: KotlinJsCompilerType? = project.kotlinPropertiesProvider.jsCompiler
|
||||
|
||||
private val presetExtension = project.objects.newInstance(
|
||||
DefaultTargetsFromPresetExtension::class.java,
|
||||
{ this },
|
||||
|
||||
+11
-92
@@ -16,20 +16,16 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||
import org.jetbrains.kotlin.gradle.internal.KOTLIN_BUILD_TOOLS_API_IMPL
|
||||
import org.jetbrains.kotlin.gradle.internal.KOTLIN_MODULE_GROUP
|
||||
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.KotlinJsSingleTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinPm20ProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
|
||||
import org.jetbrains.kotlin.gradle.targets.js.calculateJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon
|
||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||
import org.jetbrains.kotlin.gradle.utils.castIsolatedKotlinPluginClassLoaderAware
|
||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.statistics.metrics.StringMetrics
|
||||
import javax.inject.Inject
|
||||
@@ -232,10 +228,11 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
||||
KotlinJsCompilerTypeHolder {
|
||||
lateinit var irPreset: KotlinJsIrSingleTargetPreset
|
||||
|
||||
lateinit var legacyPreset: KotlinJsSingleTargetPreset
|
||||
|
||||
private val targetSetObservers = mutableListOf<(KotlinJsTargetDsl?) -> Unit>()
|
||||
|
||||
@Deprecated("Because only IR compiler is left, no more necessary to know about compiler type in properties")
|
||||
override val compilerTypeFromProperties: KotlinJsCompilerType? = null
|
||||
|
||||
// target is public property
|
||||
// Users can write kotlin.target and it should work
|
||||
// So call of target should init default configuration
|
||||
@@ -250,49 +247,6 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
||||
targetSetObservers.add(observer)
|
||||
}
|
||||
|
||||
companion object {
|
||||
internal fun reportJsCompilerMode(compilerType: KotlinJsCompilerType) {
|
||||
when (compilerType) {
|
||||
KotlinJsCompilerType.LEGACY -> KotlinBuildStatsService.getInstance()?.report(StringMetrics.JS_COMPILER_MODE, "legacy")
|
||||
KotlinJsCompilerType.IR -> KotlinBuildStatsService.getInstance()?.report(StringMetrics.JS_COMPILER_MODE, "ir")
|
||||
KotlinJsCompilerType.BOTH -> KotlinBuildStatsService.getInstance()?.report(StringMetrics.JS_COMPILER_MODE, "both")
|
||||
}
|
||||
}
|
||||
|
||||
internal fun warnAboutDeprecatedCompiler(project: Project, compilerType: KotlinJsCompilerType) {
|
||||
if (PropertiesProvider(project).jsCompilerNoWarn) return
|
||||
val logger = project.logger
|
||||
when (compilerType) {
|
||||
KotlinJsCompilerType.LEGACY -> logger.warn(LEGACY_DEPRECATED)
|
||||
KotlinJsCompilerType.IR -> {}
|
||||
KotlinJsCompilerType.BOTH -> logger.warn(BOTH_DEPRECATED)
|
||||
}
|
||||
}
|
||||
|
||||
private val LEGACY_DEPRECATED =
|
||||
"""
|
||||
|
|
||||
|==========
|
||||
|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).
|
||||
|==========
|
||||
|
|
||||
""".trimMargin()
|
||||
|
||||
private val BOTH_DEPRECATED =
|
||||
"""
|
||||
|
|
||||
|==========
|
||||
|This project currently uses Both mode, which requires the Kotlin/JS Legacy compiler backend.
|
||||
|This backend 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).
|
||||
|==========
|
||||
|
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
@Deprecated("Use js() instead", ReplaceWith("js()"))
|
||||
@Suppress("DEPRECATION")
|
||||
override val target: KotlinJsTargetDsl
|
||||
@@ -303,50 +257,15 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
||||
return _target!!
|
||||
}
|
||||
|
||||
override val compilerTypeFromProperties: KotlinJsCompilerType? = project.kotlinPropertiesProvider.jsCompiler
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun jsInternal(
|
||||
compiler: KotlinJsCompilerType? = null,
|
||||
body: KotlinJsTargetDsl.() -> Unit
|
||||
body: KotlinJsTargetDsl.() -> Unit,
|
||||
): KotlinJsTargetDsl {
|
||||
if (_target != null) {
|
||||
val previousCompilerType = _target!!.calculateJsCompilerType()
|
||||
check(compiler == null || previousCompilerType == compiler) {
|
||||
"You already registered Kotlin/JS target with another compiler: ${previousCompilerType.lowerName}"
|
||||
}
|
||||
}
|
||||
|
||||
if (_target == null) {
|
||||
val compilerOrFromProperties = compiler ?: compilerTypeFromProperties
|
||||
val compilerOrDefault = compilerOrFromProperties ?: defaultJsCompilerType
|
||||
reportJsCompilerMode(compilerOrDefault)
|
||||
warnAboutDeprecatedCompiler(project, compilerOrDefault)
|
||||
val target: KotlinJsTargetDsl = when (compilerOrDefault) {
|
||||
KotlinJsCompilerType.LEGACY -> legacyPreset
|
||||
.also {
|
||||
it.irPreset = null
|
||||
}
|
||||
.createTarget("js")
|
||||
|
||||
KotlinJsCompilerType.IR -> irPreset
|
||||
.also {
|
||||
it.mixedMode = false
|
||||
}
|
||||
.createTarget("js")
|
||||
|
||||
KotlinJsCompilerType.BOTH -> legacyPreset
|
||||
.also {
|
||||
irPreset.mixedMode = true
|
||||
it.irPreset = irPreset
|
||||
}
|
||||
.createTarget(
|
||||
lowerCamelCaseName(
|
||||
"js",
|
||||
LEGACY.lowerName
|
||||
)
|
||||
)
|
||||
}
|
||||
val compilerOrDefault = compiler ?: defaultJsCompilerType
|
||||
val target: KotlinJsTargetDsl = irPreset
|
||||
.createTarget("js")
|
||||
|
||||
this._target = target
|
||||
|
||||
@@ -360,19 +279,19 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
||||
|
||||
fun js(
|
||||
compiler: KotlinJsCompilerType = defaultJsCompilerType,
|
||||
body: KotlinJsTargetDsl.() -> Unit = { }
|
||||
body: KotlinJsTargetDsl.() -> Unit = { },
|
||||
): KotlinJsTargetDsl = jsInternal(compiler, body)
|
||||
|
||||
fun js(
|
||||
compiler: String,
|
||||
body: KotlinJsTargetDsl.() -> Unit = { }
|
||||
body: KotlinJsTargetDsl.() -> Unit = { },
|
||||
): KotlinJsTargetDsl = js(
|
||||
KotlinJsCompilerType.byArgument(compiler),
|
||||
body
|
||||
)
|
||||
|
||||
fun js(
|
||||
body: KotlinJsTargetDsl.() -> Unit = { }
|
||||
body: KotlinJsTargetDsl.() -> Unit = { },
|
||||
) = jsInternal(body = body)
|
||||
|
||||
fun js() = js { }
|
||||
@@ -411,7 +330,7 @@ abstract class KotlinCommonProjectExtension(project: Project) : KotlinSingleJava
|
||||
internal set
|
||||
|
||||
open fun target(
|
||||
body: KotlinWithJavaTarget<KotlinMultiplatformCommonOptions, KotlinMultiplatformCommonCompilerOptions>.() -> Unit
|
||||
body: KotlinWithJavaTarget<KotlinMultiplatformCommonOptions, KotlinMultiplatformCommonCompilerOptions>.() -> Unit,
|
||||
) = target.run(body)
|
||||
}
|
||||
|
||||
|
||||
+2
-68
@@ -6,12 +6,8 @@
|
||||
package org.jetbrains.kotlin.gradle.dsl
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension.Companion.reportJsCompilerMode
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension.Companion.warnAboutDeprecatedCompiler
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.calculateJsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
|
||||
@KotlinGradlePluginDsl
|
||||
interface KotlinTargetContainerWithJsPresetFunctions :
|
||||
@@ -84,74 +80,12 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal(
|
||||
compiler: KotlinJsCompilerType? = null,
|
||||
configure: KotlinJsTargetDsl.() -> Unit
|
||||
): KotlinJsTargetDsl {
|
||||
val existingTarget = getExistingTarget(name, compiler)
|
||||
|
||||
val kotlinJsCompilerType = (compiler
|
||||
?: existingTarget?.calculateJsCompilerType())
|
||||
|
||||
val compilerOrDefault = kotlinJsCompilerType
|
||||
?: defaultJsCompilerType
|
||||
|
||||
val targetName = getTargetName(name, compilerOrDefault)
|
||||
|
||||
if (existingTarget != null) {
|
||||
val previousCompilerType = existingTarget.calculateJsCompilerType()
|
||||
check(compiler == null || previousCompilerType == compiler) {
|
||||
"You already registered Kotlin/JS target '$targetName' with another compiler: ${previousCompilerType.lowerName}"
|
||||
}
|
||||
}
|
||||
|
||||
reportJsCompilerMode(compilerOrDefault)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return configureOrCreate(
|
||||
targetName,
|
||||
name,
|
||||
presets.getByName(
|
||||
lowerCamelCaseName(
|
||||
"js",
|
||||
if (compilerOrDefault == KotlinJsCompilerType.LEGACY) null else compilerOrDefault.lowerName
|
||||
)
|
||||
"js"
|
||||
) as KotlinTargetPreset<KotlinJsTargetDsl>,
|
||||
configure
|
||||
).also { target ->
|
||||
warnAboutDeprecatedCompiler(target.project, compilerOrDefault)
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find existing target with exact name
|
||||
// and with append suffix Legacy in case when compiler for found target is BOTH,
|
||||
// and removed suffix Legacy in case when current compiler is BOTH
|
||||
private fun KotlinTargetContainerWithJsPresetFunctions.getExistingTarget(
|
||||
name: String,
|
||||
compiler: KotlinJsCompilerType?
|
||||
): KotlinJsTargetDsl? {
|
||||
|
||||
fun getPreviousTarget(
|
||||
targetName: String,
|
||||
currentBoth: Boolean
|
||||
): KotlinJsTargetDsl? {
|
||||
val singleTarget = targets.findByName(
|
||||
targetName
|
||||
) as KotlinJsTargetDsl?
|
||||
|
||||
return singleTarget?.let {
|
||||
val previousCompiler = it.calculateJsCompilerType()
|
||||
if (compiler == KotlinJsCompilerType.BOTH && currentBoth || previousCompiler == KotlinJsCompilerType.BOTH && !currentBoth) {
|
||||
it
|
||||
} else null
|
||||
}
|
||||
}
|
||||
|
||||
val targetNameCandidate = getTargetName(name, compiler)
|
||||
|
||||
return targets.findByName(targetNameCandidate) as KotlinJsTargetDsl?
|
||||
?: getPreviousTarget(targetNameCandidate.removeJsCompilerSuffix(KotlinJsCompilerType.LEGACY), true)
|
||||
?: getPreviousTarget(lowerCamelCaseName(targetNameCandidate, KotlinJsCompilerType.LEGACY.lowerName), false)
|
||||
}
|
||||
|
||||
private fun getTargetName(name: String, compiler: KotlinJsCompilerType?): String {
|
||||
return lowerCamelCaseName(
|
||||
name,
|
||||
if (compiler == KotlinJsCompilerType.BOTH) KotlinJsCompilerType.LEGACY.lowerName else null
|
||||
)
|
||||
}
|
||||
|
||||
-5
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.GradleKpmModule
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinPm20ProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.sourceSetDependencyConfigurationByScope
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrCompilation
|
||||
import org.jetbrains.kotlin.gradle.targets.js.npm.SemVer
|
||||
|
||||
@@ -79,10 +78,6 @@ private fun KotlinTarget.addKotlinDomApiDependency(
|
||||
dependencies: DependencyHandler,
|
||||
coreLibrariesVersion: Provider<String>
|
||||
) {
|
||||
if (this is KotlinJsTarget) {
|
||||
irTarget?.addKotlinDomApiDependency(configurations, dependencies, coreLibrariesVersion)
|
||||
}
|
||||
|
||||
compilations.configureEach { compilation ->
|
||||
if (compilation.platformType != KotlinPlatformType.js) return@configureEach
|
||||
if (compilation !is KotlinJsIrCompilation) return@configureEach
|
||||
|
||||
+1
@@ -350,6 +350,7 @@ abstract class AbstractKotlinJsPluginWrapper : KotlinBasePluginWrapper() {
|
||||
override val projectExtensionClass: KClass<out KotlinJsProjectExtension>
|
||||
get() = KotlinJsProjectExtension::class
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun whenBuildEvaluated(project: Project) = project.runProjectConfigurationHealthCheck {
|
||||
val isJsTargetUninitialized = (project.kotlinExtension as KotlinJsProjectExtension)
|
||||
._target == null
|
||||
|
||||
-5
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.plugin.internal.artifactTypeAttribute
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinWasmTargetAttribute
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||
@@ -432,10 +431,6 @@ fun Configuration.usesPlatformOf(target: KotlinTarget): Configuration {
|
||||
|
||||
val publishJsCompilerAttribute = PropertiesProvider(target.project).publishJsCompilerAttribute
|
||||
|
||||
if (publishJsCompilerAttribute && target is KotlinJsTarget) {
|
||||
attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.legacy)
|
||||
}
|
||||
|
||||
if (publishJsCompilerAttribute && target is KotlinJsIrTarget) {
|
||||
if (target.platformType == KotlinPlatformType.js) {
|
||||
attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir)
|
||||
|
||||
-18
@@ -242,9 +242,6 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val wasmStabilityNoWarn: Boolean
|
||||
get() = booleanProperty("kotlin.wasm.stability.nowarn") ?: false
|
||||
|
||||
val jsCompilerNoWarn: Boolean
|
||||
get() = booleanProperty("$jsCompilerProperty.nowarn") ?: false
|
||||
|
||||
val ignoreDisabledNativeTargets: Boolean?
|
||||
get() = booleanProperty(KOTLIN_NATIVE_IGNORE_DISABLED_TARGETS)
|
||||
|
||||
@@ -447,27 +444,12 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val errorJsGenerateExternals: Boolean?
|
||||
get() = booleanProperty("kotlin.js.generate.externals")
|
||||
|
||||
/**
|
||||
* Use Kotlin/JS backend compiler type
|
||||
*/
|
||||
val jsCompiler: KotlinJsCompilerType?
|
||||
get() = this.property(jsCompilerProperty)?.let { KotlinJsCompilerType.byArgumentOrNull(it) }
|
||||
|
||||
/**
|
||||
* Use Kotlin/JS backend compiler publishing attribute
|
||||
*/
|
||||
val publishJsCompilerAttribute: Boolean
|
||||
get() = this.booleanProperty("$jsCompilerProperty.publish.attribute") ?: true
|
||||
|
||||
/**
|
||||
* Use Kotlin/JS backend compiler type
|
||||
*/
|
||||
val jsGenerateExecutableDefault: Boolean
|
||||
get() = (booleanProperty("kotlin.js.generate.executable.default") ?: true).also {
|
||||
KotlinBuildStatsService.getInstance()
|
||||
?.report(StringMetrics.JS_GENERATE_EXECUTABLE_DEFAULT, it.toString())
|
||||
}
|
||||
|
||||
val stdlibDefaultDependency: Boolean
|
||||
get() = booleanProperty(KOTLIN_STDLIB_DEFAULT_DEPENDENCY) ?: true
|
||||
|
||||
|
||||
+1
-7
@@ -130,13 +130,7 @@ class KotlinMultiplatformPlugin : Plugin<Project> {
|
||||
fun setupDefaultPresets(project: Project) {
|
||||
with(project.multiplatformExtension.presets) {
|
||||
add(KotlinJvmTargetPreset(project))
|
||||
add(KotlinJsTargetPreset(project).apply { irPreset = null })
|
||||
add(KotlinJsIrTargetPreset(project).apply { mixedMode = false })
|
||||
add(
|
||||
KotlinJsTargetPreset(project).apply {
|
||||
irPreset = KotlinJsIrTargetPreset(project).apply { mixedMode = true }
|
||||
}
|
||||
)
|
||||
add(KotlinJsIrTargetPreset(project))
|
||||
add(KotlinWasmTargetPreset(project))
|
||||
add(project.objects.newInstance(KotlinAndroidTargetPreset::class.java, project))
|
||||
add(KotlinJvmWithJavaTargetPreset(project))
|
||||
|
||||
-31
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationC
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.javaSourceSets
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||
import org.jetbrains.kotlin.gradle.utils.*
|
||||
|
||||
@@ -51,20 +50,6 @@ internal object NativeKotlinCompilationDependencyConfigurationsFactory :
|
||||
}
|
||||
}
|
||||
|
||||
internal object JsKotlinCompilationDependencyConfigurationsFactory :
|
||||
KotlinCompilationImplFactory.KotlinCompilationDependencyConfigurationsFactory {
|
||||
|
||||
override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationConfigurationsContainer {
|
||||
val defaultNaming = ConfigurationNaming.Default(target, compilationName)
|
||||
return KotlinCompilationDependencyConfigurationsContainer(
|
||||
target, compilationName, withRuntime = true,
|
||||
naming = ConfigurationNaming.Js(target, compilationName),
|
||||
compileClasspathConfigurationName = defaultNaming.name(compileClasspath),
|
||||
runtimeClasspathConfigurationName = defaultNaming.name(runtimeClasspath)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
internal class JvmWithJavaCompilationDependencyConfigurationsFactory(private val target: KotlinWithJavaTarget<*, *>) :
|
||||
KotlinCompilationImplFactory.KotlinCompilationDependencyConfigurationsFactory {
|
||||
override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationConfigurationsContainer {
|
||||
@@ -92,22 +77,6 @@ private fun interface ConfigurationNaming {
|
||||
target.disambiguationClassifier, compilationName.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME }, *parts
|
||||
)
|
||||
}
|
||||
|
||||
class Js(
|
||||
private val target: KotlinTarget,
|
||||
private val compilationName: String
|
||||
) : ConfigurationNaming {
|
||||
override fun name(vararg parts: String): String = lowerCamelCaseName(
|
||||
target.disambiguationClassifierInPlatform, compilationName.takeIf { it != KotlinCompilation.MAIN_COMPILATION_NAME }, *parts
|
||||
)
|
||||
|
||||
private val KotlinTarget.disambiguationClassifierInPlatform: String?
|
||||
get() = when (this) {
|
||||
is KotlinJsTarget -> disambiguationClassifierInPlatform
|
||||
is KotlinJsIrTarget -> disambiguationClassifierInPlatform
|
||||
else -> error("Unexpected target type of $this")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const val compilation = "compilation"
|
||||
|
||||
+1
-27
@@ -14,8 +14,6 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationSourceSetsContainer
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.android.kotlinAndroidSourceSetLayout
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||
|
||||
internal class DefaultKotlinCompilationSourceSetsContainerFactory(
|
||||
@@ -50,28 +48,4 @@ internal class AndroidCompilationSourceSetsContainerFactory(
|
||||
?: lowerCamelCaseName(target.disambiguationClassifier, compilationName)
|
||||
return KotlinCompilationSourceSetsContainer(target.project.kotlinExtension.sourceSets.maybeCreate(sourceSetName))
|
||||
}
|
||||
}
|
||||
|
||||
internal object JsCompilationSourceSetsContainerFactory : KotlinCompilationImplFactory.KotlinCompilationSourceSetsContainerFactory {
|
||||
override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationSourceSetsContainer {
|
||||
val defaultSourceSetName = lowerCamelCaseName(
|
||||
if (target is KotlinJsTarget && target.irTarget != null) target.disambiguationClassifierInPlatform
|
||||
else target.disambiguationClassifier,
|
||||
compilationName
|
||||
)
|
||||
|
||||
return KotlinCompilationSourceSetsContainer(target.project.kotlinExtension.sourceSets.maybeCreate(defaultSourceSetName))
|
||||
}
|
||||
}
|
||||
|
||||
internal object JsIrCompilationSourceSetsContainerFactory : KotlinCompilationImplFactory.KotlinCompilationSourceSetsContainerFactory {
|
||||
override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationSourceSetsContainer {
|
||||
val defaultSourceSetName = lowerCamelCaseName(
|
||||
if (target is KotlinJsIrTarget && target.mixedMode) target.disambiguationClassifierInPlatform
|
||||
else target.disambiguationClassifier,
|
||||
compilationName
|
||||
)
|
||||
|
||||
return KotlinCompilationSourceSetsContainer(target.project.kotlinExtension.sourceSets.maybeCreate(defaultSourceSetName))
|
||||
}
|
||||
}
|
||||
}
|
||||
-64
@@ -7,17 +7,10 @@ package org.jetbrains.kotlin.gradle.plugin.sources
|
||||
|
||||
import org.gradle.api.NamedDomainObjectFactory
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.attributes.Category
|
||||
import org.gradle.api.attributes.Usage
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||
import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled
|
||||
import org.jetbrains.kotlin.gradle.utils.getOrCreate
|
||||
import java.io.File
|
||||
@@ -108,67 +101,10 @@ internal class DefaultKotlinSourceSetFactory(
|
||||
if (project.isKotlinGranularMetadataEnabled) {
|
||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA))
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
setJsCompilerIfNecessary(sourceSet, this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// KT-47163
|
||||
// It is necessary to set jsCompilerAttribute to configurations which associated with ONLY js source sets
|
||||
// Otherwise configuration cannot be resolved because ambiguity between IR and Legacy variants inside one module
|
||||
private val notOnlyJsSourceSets = mutableSetOf<KotlinSourceSet>()
|
||||
|
||||
private val jsOnlySourceSetsAttributes = mutableMapOf<KotlinSourceSet, KotlinJsCompilerAttribute>()
|
||||
|
||||
private fun setJsCompilerIfNecessary(sourceSet: KotlinSourceSet, configuration: Configuration) {
|
||||
if (sourceSet in notOnlyJsSourceSets) return
|
||||
|
||||
if (sourceSet in jsOnlySourceSetsAttributes) {
|
||||
configuration.attributes.attribute(
|
||||
KotlinJsCompilerAttribute.jsCompilerAttribute,
|
||||
jsOnlySourceSetsAttributes.getValue(sourceSet)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
project.kotlinExtension.targets
|
||||
.filter { it !is KotlinJsIrTarget && it !is KotlinJsTarget }
|
||||
.forEach { target ->
|
||||
target.compilations.forEach { compilation ->
|
||||
notOnlyJsSourceSets.addAll(compilation.allKotlinSourceSets)
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceSet in notOnlyJsSourceSets) return
|
||||
|
||||
fun chooseCompilerAttribute(target: KotlinTarget): KotlinJsCompilerAttribute {
|
||||
if (target is KotlinJsIrTarget) {
|
||||
return KotlinJsCompilerAttribute.ir
|
||||
}
|
||||
|
||||
target as KotlinJsTarget
|
||||
return if (target.irTarget != null) KotlinJsCompilerAttribute.ir else KotlinJsCompilerAttribute.legacy
|
||||
}
|
||||
|
||||
project.kotlinExtension.targets
|
||||
.filter { it is KotlinJsTarget || (it is KotlinJsIrTarget && it.platformType == KotlinPlatformType.js) }
|
||||
.forEach { target ->
|
||||
target.compilations
|
||||
.filterIsInstance<KotlinJsCompilation>()
|
||||
.forEach { compilation ->
|
||||
if (sourceSet in compilation.allKotlinSourceSets) {
|
||||
val compilerAttribute = chooseCompilerAttribute(target)
|
||||
jsOnlySourceSetsAttributes[sourceSet] = compilerAttribute
|
||||
configuration.attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, compilerAttribute)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun doCreateSourceSet(name: String): DefaultKotlinSourceSet =
|
||||
project.objects.newInstance(DefaultKotlinSourceSet::class.java, project, name)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user