[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 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 getCompilerTypeFromProperties ()Lorg/jetbrains/kotlin/gradle/plugin/KotlinJsCompilerType;
|
||||||
public abstract fun getDefaultJsCompilerType ()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 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 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 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 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 {
|
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
|
val KotlinJsCompilerType.lowerName
|
||||||
get() = name.toLowerCase(Locale.ENGLISH)
|
get() = name.toLowerCase(Locale.ENGLISH)
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
@Deprecated("This method is planned to be removed")
|
||||||
fun String.removeJsCompilerSuffix(compilerType: KotlinJsCompilerType): String {
|
fun String.removeJsCompilerSuffix(compilerType: KotlinJsCompilerType): String {
|
||||||
val truncatedString = removeSuffix(compilerType.lowerName)
|
val truncatedString = removeSuffix(compilerType.lowerName)
|
||||||
if (this != truncatedString) {
|
if (this != truncatedString) {
|
||||||
|
|||||||
+4
-3
@@ -8,20 +8,21 @@
|
|||||||
package org.jetbrains.kotlin.gradle.plugin
|
package org.jetbrains.kotlin.gradle.plugin
|
||||||
|
|
||||||
interface KotlinJsCompilerTypeHolder {
|
interface KotlinJsCompilerTypeHolder {
|
||||||
|
@Deprecated("Because only IR compiler is left, no more necessary to know about compiler type in properties")
|
||||||
val compilerTypeFromProperties: KotlinJsCompilerType?
|
val compilerTypeFromProperties: KotlinJsCompilerType?
|
||||||
|
|
||||||
val defaultJsCompilerType: KotlinJsCompilerType
|
val defaultJsCompilerType: KotlinJsCompilerType
|
||||||
get() = compilerTypeFromProperties ?: KotlinJsCompilerType.IR
|
get() = KotlinJsCompilerType.IR
|
||||||
|
|
||||||
// Necessary to get rid of KotlinJsCompilerType import in build script
|
// 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
|
val LEGACY: KotlinJsCompilerType
|
||||||
get() = KotlinJsCompilerType.LEGACY
|
get() = KotlinJsCompilerType.LEGACY
|
||||||
|
|
||||||
val IR: KotlinJsCompilerType
|
val IR: KotlinJsCompilerType
|
||||||
get() = KotlinJsCompilerType.IR
|
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
|
val BOTH: KotlinJsCompilerType
|
||||||
get() = KotlinJsCompilerType.BOTH
|
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.cli.common.CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM
|
||||||
import org.jetbrains.kotlin.gradle.model.ModelContainer
|
import org.jetbrains.kotlin.gradle.model.ModelContainer
|
||||||
import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction
|
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.report.BuildReportType
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.jetbrains.kotlin.gradle.util.*
|
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
|
// 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 withDaemon: Boolean = false,
|
||||||
val daemonOptionSupported: Boolean = true,
|
val daemonOptionSupported: Boolean = true,
|
||||||
val incremental: Boolean? = null,
|
val incremental: Boolean? = null,
|
||||||
val incrementalJs: Boolean? = null,
|
val incrementalJs: Boolean? = null,
|
||||||
val incrementalJsKlib: Boolean? = null,
|
val incrementalJsKlib: Boolean? = null,
|
||||||
val jsIrBackend: Boolean? = null,
|
|
||||||
val androidHome: File? = null,
|
val androidHome: File? = null,
|
||||||
val javaHome: File? = null,
|
val javaHome: File? = null,
|
||||||
val gradleUserHome: File? = null,
|
val gradleUserHome: File? = null,
|
||||||
@@ -269,7 +267,6 @@ abstract class BaseGradleIT {
|
|||||||
val withBuildCache: Boolean = false,
|
val withBuildCache: Boolean = false,
|
||||||
val kaptOptions: KaptOptions? = null,
|
val kaptOptions: KaptOptions? = null,
|
||||||
val parallelTasksInProject: Boolean = false,
|
val parallelTasksInProject: Boolean = false,
|
||||||
val jsCompilerType: KotlinJsCompilerType? = null,
|
|
||||||
val configurationCache: Boolean = false,
|
val configurationCache: Boolean = false,
|
||||||
val configurationCacheProblems: ConfigurationCacheProblems = ConfigurationCacheProblems.FAIL,
|
val configurationCacheProblems: ConfigurationCacheProblems = ConfigurationCacheProblems.FAIL,
|
||||||
val warningMode: WarningMode = WarningMode.Fail,
|
val warningMode: WarningMode = WarningMode.Fail,
|
||||||
@@ -881,9 +878,6 @@ abstract class BaseGradleIT {
|
|||||||
}
|
}
|
||||||
options.incrementalJs?.let { add("-Pkotlin.incremental.js=$it") }
|
options.incrementalJs?.let { add("-Pkotlin.incremental.js=$it") }
|
||||||
options.incrementalJsKlib?.let { add("-Pkotlin.incremental.js.klib=$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.usePreciseJavaTracking?.let { add("-Pkotlin.incremental.usePreciseJavaTracking=$it") }
|
||||||
options.useClasspathSnapshot?.let { add("-P${COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM.property}=$it") }
|
options.useClasspathSnapshot?.let { add("-P${COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM.property}=$it") }
|
||||||
options.androidGradlePluginVersion?.let { add("-Pandroid_tools_version=$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")
|
if (options.parallelTasksInProject) add("--parallel") else add("--no-parallel")
|
||||||
|
|
||||||
options.jsCompilerType?.let {
|
|
||||||
add("-Pkotlin.js.compiler=$it")
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.dryRun) {
|
if (options.dryRun) {
|
||||||
add("--dry-run")
|
add("--dry-run")
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -21,6 +21,12 @@ class ExecutionStrategyJsIT : ExecutionStrategyIT() {
|
|||||||
) +
|
) +
|
||||||
"""
|
"""
|
||||||
|
|
|
|
||||||
|
|kotlin {
|
||||||
|
| js {
|
||||||
|
|
|
||||||
|
| }
|
||||||
|
|}
|
||||||
|
|
|
||||||
|afterEvaluate {
|
|afterEvaluate {
|
||||||
| tasks.named('compileKotlinJs') {
|
| tasks.named('compileKotlinJs') {
|
||||||
| kotlinOptions.outputFile = "${'$'}{project.projectDir}/web/js/"
|
| 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.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.internals.MULTIPLATFORM_PROJECT_METADATA_JSON_FILE_NAME
|
import org.jetbrains.kotlin.gradle.internals.MULTIPLATFORM_PROJECT_METADATA_JSON_FILE_NAME
|
||||||
import org.jetbrains.kotlin.gradle.internals.parseKotlinSourceSetMetadataFromJson
|
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.KotlinProjectStructureMetadata
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.ModuleDependencyIdentifier
|
import org.jetbrains.kotlin.gradle.plugin.mpp.ModuleDependencyIdentifier
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.SourceSetMetadataLayout
|
import org.jetbrains.kotlin.gradle.plugin.mpp.SourceSetMetadataLayout
|
||||||
@@ -287,12 +286,11 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
|||||||
|
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@DisplayName("Works with published JS library")
|
@DisplayName("Works with published JS library")
|
||||||
fun testHmppWithPublishedJsBothDependency(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
fun testHmppWithPublishedJsIrDependency(gradleVersion: GradleVersion, @TempDir tempDir: Path) {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
publishThirdPartyLib(
|
publishThirdPartyLib(
|
||||||
projectName = "hierarchical-mpp-with-js-published-modules/third-party-lib",
|
projectName = "hierarchical-mpp-with-js-published-modules/third-party-lib",
|
||||||
withGranularMetadata = true,
|
withGranularMetadata = true,
|
||||||
jsCompilerType = KotlinJsCompilerType.BOTH,
|
|
||||||
gradleVersion = gradleVersion,
|
gradleVersion = gradleVersion,
|
||||||
localRepoDir = tempDir
|
localRepoDir = tempDir
|
||||||
)
|
)
|
||||||
@@ -302,7 +300,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
|||||||
"hierarchical-mpp-with-js-published-modules/my-lib-foo",
|
"hierarchical-mpp-with-js-published-modules/my-lib-foo",
|
||||||
gradleVersion,
|
gradleVersion,
|
||||||
localRepoDir = tempDir,
|
localRepoDir = tempDir,
|
||||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = KotlinJsCompilerType.IR))
|
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions())
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
build("publish", "assemble")
|
build("publish", "assemble")
|
||||||
@@ -316,7 +314,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
|||||||
nativeProject(
|
nativeProject(
|
||||||
projectName = "hierarchical-mpp-with-js-project-dependency",
|
projectName = "hierarchical-mpp-with-js-project-dependency",
|
||||||
gradleVersion = gradleVersion,
|
gradleVersion = gradleVersion,
|
||||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = KotlinJsCompilerType.IR))
|
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions())
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
build("assemble")
|
build("assemble")
|
||||||
@@ -385,7 +383,6 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
|||||||
private fun publishThirdPartyLib(
|
private fun publishThirdPartyLib(
|
||||||
projectName: String = "third-party-lib".withPrefix,
|
projectName: String = "third-party-lib".withPrefix,
|
||||||
withGranularMetadata: Boolean,
|
withGranularMetadata: Boolean,
|
||||||
jsCompilerType: KotlinJsCompilerType = KotlinJsCompilerType.IR,
|
|
||||||
gradleVersion: GradleVersion,
|
gradleVersion: GradleVersion,
|
||||||
localRepoDir: Path,
|
localRepoDir: Path,
|
||||||
beforePublishing: TestProject.() -> Unit = { }
|
beforePublishing: TestProject.() -> Unit = { }
|
||||||
@@ -394,7 +391,7 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
|||||||
projectName = projectName,
|
projectName = projectName,
|
||||||
gradleVersion = gradleVersion,
|
gradleVersion = gradleVersion,
|
||||||
localRepoDir = localRepoDir,
|
localRepoDir = localRepoDir,
|
||||||
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions(jsCompilerType = jsCompilerType))
|
buildOptions = defaultBuildOptions.copy(jsOptions = BuildOptions.JsOptions())
|
||||||
).apply {
|
).apply {
|
||||||
beforePublishing()
|
beforePublishing()
|
||||||
|
|
||||||
|
|||||||
+6
-14
@@ -6,15 +6,13 @@
|
|||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
|
|
||||||
abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean) : KGPBaseTest() {
|
@JsGradlePluginTests
|
||||||
|
abstract class JsIrConfigurationCacheIT : KGPBaseTest() {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||||
useIrBackend = irBackend,
|
|
||||||
jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
final override val defaultBuildOptions =
|
final override val defaultBuildOptions =
|
||||||
@@ -47,7 +45,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
|||||||
":app:packageJson",
|
":app:packageJson",
|
||||||
":app:publicPackageJson",
|
":app:publicPackageJson",
|
||||||
":app:compileKotlinJs",
|
":app:compileKotlinJs",
|
||||||
if (irBackend) ":app:compileProductionExecutableKotlinJs" else ":app:processDceKotlinJs",
|
":app:compileProductionExecutableKotlinJs",
|
||||||
":app:browserProductionWebpack",
|
":app:browserProductionWebpack",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -68,7 +66,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
|||||||
assertTasksUpToDate(
|
assertTasksUpToDate(
|
||||||
":app:packageJson",
|
":app:packageJson",
|
||||||
":app:publicPackageJson",
|
":app:publicPackageJson",
|
||||||
if (irBackend) ":app:compileProductionExecutableKotlinJs" else ":app:processDceKotlinJs",
|
":app:compileProductionExecutableKotlinJs",
|
||||||
":app:browserProductionWebpack",
|
":app:browserProductionWebpack",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -88,7 +86,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
|||||||
":rootPackageJson",
|
":rootPackageJson",
|
||||||
":compileKotlinJs",
|
":compileKotlinJs",
|
||||||
":nodeTest",
|
":nodeTest",
|
||||||
) + if (irBackend) listOf(":compileProductionExecutableKotlinJs") else emptyList()
|
) + listOf(":compileProductionExecutableKotlinJs")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +108,7 @@ abstract class AbstractJsConfigurationCacheIT(protected val irBackend: Boolean)
|
|||||||
":rootPackageJson",
|
":rootPackageJson",
|
||||||
":compileKotlinJs",
|
":compileKotlinJs",
|
||||||
":nodeTest",
|
":nodeTest",
|
||||||
) + if (irBackend) listOf(":compileProductionExecutableKotlinJs") else emptyList()
|
) + listOf(":compileProductionExecutableKotlinJs")
|
||||||
assertTasksUpToDate(*upToDateTasks.toTypedArray())
|
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
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import org.junit.jupiter.api.condition.OS
|
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])
|
@OsCondition(supportedOn = [OS.LINUX, OS.MAC, OS.WINDOWS], enabledOnCI = [OS.LINUX, OS.MAC, OS.WINDOWS])
|
||||||
@NativeGradlePluginTests
|
@NativeGradlePluginTests
|
||||||
class JsSetupConfigurationCacheIT : KGPBaseTest() {
|
class JsSetupConfigurationCacheIT : KGPBaseTest() {
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
|
||||||
useIrBackend = true,
|
|
||||||
jsCompilerType = KotlinJsCompilerType.IR
|
|
||||||
)
|
|
||||||
|
|
||||||
override val defaultBuildOptions =
|
override val defaultBuildOptions =
|
||||||
super.defaultBuildOptions.copy(
|
super.defaultBuildOptions.copy(
|
||||||
jsOptions = defaultJsOptions,
|
|
||||||
configurationCache = true,
|
configurationCache = true,
|
||||||
configurationCacheProblems = BaseGradleIT.ConfigurationCacheProblems.FAIL
|
configurationCacheProblems = BaseGradleIT.ConfigurationCacheProblems.FAIL
|
||||||
)
|
)
|
||||||
|
|||||||
+82
-319
@@ -10,7 +10,6 @@ import com.google.gson.JsonNull
|
|||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import org.gradle.testkit.runner.BuildResult
|
import org.gradle.testkit.runner.BuildResult
|
||||||
import org.gradle.util.GradleVersion
|
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.dsl.Distribution
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KLIB_TYPE
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KLIB_TYPE
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject
|
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.tasks.USING_JS_IR_BACKEND_MESSAGE
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions.Gradle.G_7_6
|
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.DisplayName
|
||||||
import org.junit.jupiter.api.condition.DisabledIf
|
import org.junit.jupiter.api.condition.DisabledIf
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
@@ -33,7 +30,7 @@ import kotlin.streams.toList
|
|||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
@JsGradlePluginTests
|
@JsGradlePluginTests
|
||||||
class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
class Kotlin2JsIrGradlePluginIT : KGPBaseTest() {
|
||||||
|
|
||||||
@DisplayName("TS type declarations are generated")
|
@DisplayName("TS type declarations are generated")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@@ -245,7 +242,7 @@ class Kotlin2JsIrGradlePluginIT : AbstractKotlin2JsGradlePluginIT(true) {
|
|||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
setOf(
|
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(),
|
projectPath.resolve("build/js/packages/kotlin-js-browser-app/kotlin/foo/foo.txt").toFile(),
|
||||||
),
|
),
|
||||||
modified.toSet()
|
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() {
|
protected fun BuildResult.checkIrCompilationMessage() {
|
||||||
if (irBackend) {
|
assertOutputContains(USING_JS_IR_BACKEND_MESSAGE)
|
||||||
assertOutputContains(USING_JS_IR_BACKEND_MESSAGE)
|
|
||||||
} else {
|
|
||||||
assertOutputDoesNotContain(USING_JS_IR_BACKEND_MESSAGE)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DisplayName("js customized output is included into jar")
|
@DisplayName("js customized output is included into jar")
|
||||||
@@ -854,11 +715,8 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
":compileKotlin2Js",
|
":compileKotlin2Js",
|
||||||
":compileTestKotlin2Js"
|
":compileTestKotlin2Js"
|
||||||
)
|
)
|
||||||
if (irBackend) {
|
assertFileInProjectExists("build/kotlin2js/main/default/manifest")
|
||||||
assertFileInProjectExists("build/kotlin2js/main/default/manifest")
|
|
||||||
} else {
|
|
||||||
assertFileInProjectExists("build/kotlin2js/main/module.js")
|
|
||||||
}
|
|
||||||
assertFileInProjectExists("build/kotlin2js/test/module-tests.js")
|
assertFileInProjectExists("build/kotlin2js/test/module-tests.js")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -878,44 +736,42 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
@GradleTest
|
@GradleTest
|
||||||
fun testKotlinJsSourceMap(gradleVersion: GradleVersion) {
|
fun testKotlinJsSourceMap(gradleVersion: GradleVersion) {
|
||||||
project("kotlin2JsProjectWithSourceMap", gradleVersion) {
|
project("kotlin2JsProjectWithSourceMap", gradleVersion) {
|
||||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
build("compileDevelopmentExecutableKotlinJs") {
|
||||||
if (irBackend) {
|
val appSourceMap = subProject("app").projectPath
|
||||||
val appSourceMap = subProject("app").projectPath
|
.resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-app.js.map")
|
||||||
.resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-app.js.map")
|
assertFileContains(
|
||||||
assertFileContains(
|
appSourceMap,
|
||||||
appSourceMap,
|
"\"../../../../../../src/main/kotlin/main.kt\"",
|
||||||
"\"../../../../../../src/main/kotlin/main.kt\"",
|
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||||
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
|
"\"sourcesContent\":[null",
|
||||||
"\"sourcesContent\":[null",
|
)
|
||||||
)
|
|
||||||
|
|
||||||
// The default should be generating simple names.
|
// The default should be generating simple names.
|
||||||
assertFileContains(appSourceMap, "somewhereOverTheRainbow")
|
assertFileContains(appSourceMap, "somewhereOverTheRainbow")
|
||||||
assertFileDoesNotContain(appSourceMap, "\"names\":[]")
|
assertFileDoesNotContain(appSourceMap, "\"names\":[]")
|
||||||
assertFileDoesNotContain(appSourceMap, "app.C.somewhereOverTheRainbow")
|
assertFileDoesNotContain(appSourceMap, "app.C.somewhereOverTheRainbow")
|
||||||
|
|
||||||
val libSourceMap = subProject("app").projectPath
|
val libSourceMap = subProject("app").projectPath
|
||||||
.resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-lib.js.map")
|
.resolve("build/compileSync/js/main/developmentExecutable/kotlin/$projectName-lib.js.map")
|
||||||
assertFileContains(
|
assertFileContains(
|
||||||
libSourceMap,
|
libSourceMap,
|
||||||
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
|
"\"../../../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||||
"\"sourcesContent\":[null",
|
"\"sourcesContent\":[null",
|
||||||
)
|
)
|
||||||
|
|
||||||
// The default should be generating simple names.
|
// The default should be generating simple names.
|
||||||
assertFileDoesNotContain(libSourceMap, "\"names\":[]")
|
assertFileDoesNotContain(libSourceMap, "\"names\":[]")
|
||||||
|
|
||||||
val libSourceMap2 = projectPath
|
val libSourceMap2 = projectPath
|
||||||
.resolve("build/js/packages/$projectName-app/kotlin/$projectName-lib.js.map")
|
.resolve("build/js/packages/$projectName-app/kotlin/$projectName-lib.js.map")
|
||||||
assertFileContains(
|
assertFileContains(
|
||||||
libSourceMap2,
|
libSourceMap2,
|
||||||
"\"../../../../../lib/src/main/kotlin/foo.kt\"",
|
"\"../../../../../lib/src/main/kotlin/foo.kt\"",
|
||||||
"\"sourcesContent\":[null",
|
"\"sourcesContent\":[null",
|
||||||
)
|
)
|
||||||
|
|
||||||
// The default should be generating simple names.
|
// The default should be generating simple names.
|
||||||
assertFileDoesNotContain(libSourceMap2, "\"names\":[]")
|
assertFileDoesNotContain(libSourceMap2, "\"names\":[]")
|
||||||
}
|
|
||||||
assertFileContains(
|
assertFileContains(
|
||||||
projectPath
|
projectPath
|
||||||
.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map"),
|
.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")
|
@DisplayName("path in source maps are remapped for custom outputFile")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testKotlinJsSourceMapCustomOutputFile(gradleVersion: GradleVersion) {
|
fun testKotlinJsSourceMapCustomOutputFile(gradleVersion: GradleVersion) {
|
||||||
project("kotlin2JsProjectWithSourceMap", gradleVersion) {
|
project("kotlin2JsProjectWithSourceMap", gradleVersion) {
|
||||||
val taskSelector = if (irBackend)
|
val taskSelector = "named<KotlinJsIrLink>(\"compileDevelopmentExecutableKotlinJs\")"
|
||||||
"named<KotlinJsIrLink>(\"compileDevelopmentExecutableKotlinJs\")"
|
|
||||||
else
|
|
||||||
"withType<KotlinJsCompile>"
|
|
||||||
buildGradleKts.appendText(
|
buildGradleKts.appendText(
|
||||||
"""
|
"""
|
||||||
|project("app") {
|
|project("app") {
|
||||||
@@ -981,17 +798,12 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
|
|
|
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
)
|
)
|
||||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
build("compileDevelopmentExecutableKotlinJs") {
|
||||||
val mapFilePath = subProject("app").projectPath
|
val mapFilePath = subProject("app").projectPath
|
||||||
.resolve("build/kotlin2js/app.js.map")
|
.resolve("build/kotlin2js/app.js.map")
|
||||||
assertFileContains(mapFilePath, "\"../../src/main/kotlin/main.kt\"")
|
assertFileContains(mapFilePath, "\"../../src/main/kotlin/main.kt\"")
|
||||||
if (irBackend) {
|
// The IR BE generates correct paths for dependencies
|
||||||
// The IR BE generates correct paths for dependencies
|
assertFileContains(mapFilePath, "\"../../../lib/src/main/kotlin/foo.kt\"")
|
||||||
assertFileContains(mapFilePath, "\"../../../lib/src/main/kotlin/foo.kt\"")
|
|
||||||
} else {
|
|
||||||
// The legacy BE doesn't.
|
|
||||||
assertFileContains(mapFilePath, "\"../../../../../lib/src/main/kotlin/foo.kt\"")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1010,7 +822,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
|
|
|
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
)
|
)
|
||||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
build("compileDevelopmentExecutableKotlinJs") {
|
||||||
val jsFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js")
|
val jsFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js")
|
||||||
assertFileExists(jsFilePath)
|
assertFileExists(jsFilePath)
|
||||||
assertFileNotExists(Path("$jsFilePath.map"))
|
assertFileNotExists(Path("$jsFilePath.map"))
|
||||||
@@ -1040,7 +852,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
|
|
|
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
)
|
)
|
||||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
build("compileDevelopmentExecutableKotlinJs") {
|
||||||
val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map")
|
val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map")
|
||||||
assertFileContains(
|
assertFileContains(
|
||||||
mapFilePath,
|
mapFilePath,
|
||||||
@@ -1073,7 +885,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
|
|
|
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
)
|
)
|
||||||
build(if (irBackend) "compileDevelopmentExecutableKotlinJs" else "compileKotlinJs") {
|
build("compileDevelopmentExecutableKotlinJs") {
|
||||||
val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map")
|
val mapFilePath = projectPath.resolve("build/js/packages/$projectName-app/kotlin/$projectName-app.js.map")
|
||||||
assertFileDoesNotContain(
|
assertFileDoesNotContain(
|
||||||
mapFilePath,
|
mapFilePath,
|
||||||
@@ -1089,24 +901,19 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
|
|
||||||
@DisplayName("smoke test of org.jetbrains.kotlin.js plugin")
|
@DisplayName("smoke test of org.jetbrains.kotlin.js plugin")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
@DisabledIf(
|
|
||||||
"org.jetbrains.kotlin.gradle.AbstractKotlin2JsGradlePluginIT#getIrBackend",
|
|
||||||
disabledReason = "kotlinx.html doesn't support IR"
|
|
||||||
)
|
|
||||||
fun testNewKotlinJsPlugin(gradleVersion: GradleVersion) {
|
fun testNewKotlinJsPlugin(gradleVersion: GradleVersion) {
|
||||||
project("kotlin-js-plugin-project", gradleVersion) {
|
project("kotlin-js-plugin-project", gradleVersion) {
|
||||||
build("publish", "processDceKotlinJs", "test", "processDceBenchmarkKotlinJs") {
|
build("publish", "assemble", "test", "compileBenchmarkKotlinJs") {
|
||||||
assertTasksExecuted(
|
assertTasksExecuted(
|
||||||
":compileKotlinJs", ":compileTestKotlinJs", ":compileBenchmarkKotlinJs",
|
":compileKotlinJs", ":compileTestKotlinJs", ":compileBenchmarkKotlinJs"
|
||||||
":processDceKotlinJs", ":processDceBenchmarkKotlinJs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val moduleDir = projectPath.resolve("build/repo/com/example/kotlin-js-plugin/1.0/")
|
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 ->
|
ZipFile(publishedJar.toFile()).use { zip ->
|
||||||
val entries = zip.entries().asSequence().map { it.name }
|
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")
|
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"))
|
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")
|
assertTestResults(projectPath.resolve("tests.xml"), "nodeTest")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1182,7 +978,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
build("jsJar") {
|
build("jsJar") {
|
||||||
val archive = projectPath
|
val archive = projectPath
|
||||||
.resolve("build/libs")
|
.resolve("build/libs")
|
||||||
.allFilesWithExtension(if (irBackend) KLIB_TYPE else "jar")
|
.allFilesWithExtension(KLIB_TYPE)
|
||||||
.single()
|
.single()
|
||||||
|
|
||||||
ZipFile(archive.toFile()).use { zipFile ->
|
ZipFile(archive.toFile()).use { zipFile ->
|
||||||
@@ -1253,7 +1049,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
build("jsJar") {
|
build("jsJar") {
|
||||||
val archive = Files.list(projectPath.resolve("build").resolve("libs")).use { files ->
|
val archive = Files.list(projectPath.resolve("build").resolve("libs")).use { files ->
|
||||||
files
|
files
|
||||||
.filter { it.extension == if (irBackend) KLIB_TYPE else "jar" }
|
.filter { it.extension == KLIB_TYPE }
|
||||||
.toList()
|
.toList()
|
||||||
.single()
|
.single()
|
||||||
}
|
}
|
||||||
@@ -1278,59 +1074,31 @@ abstract class AbstractKotlin2JsGradlePluginIT(protected val irBackend: Boolean)
|
|||||||
project("kotlin-js-browser-project", gradleVersion) {
|
project("kotlin-js-browser-project", gradleVersion) {
|
||||||
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
buildGradleKts.modify(::transformBuildScriptWithPluginsDsl)
|
||||||
|
|
||||||
if (irBackend) {
|
build("compileProductionExecutableKotlinJs") {
|
||||||
gradleProperties.appendText(jsCompilerType(KotlinJsCompilerType.IR))
|
assertTasksExecuted(":app:compileProductionExecutableKotlinJs")
|
||||||
}
|
assert(task(":kotlinNpmInstall") == null) {
|
||||||
|
printBuildOutput()
|
||||||
if (irBackend) {
|
"NPM install should not be run"
|
||||||
build("compileProductionExecutableKotlinJs") {
|
|
||||||
assertTasksExecuted(":app:compileProductionExecutableKotlinJs")
|
|
||||||
assert(task(":kotlinNpmInstall") == null) {
|
|
||||||
printBuildOutput()
|
|
||||||
"NPM install should not be run"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
build("assemble") {
|
build("assemble") {
|
||||||
assertTasksExecuted(":app:browserProductionWebpack")
|
assertTasksExecuted(":app:browserProductionWebpack")
|
||||||
|
|
||||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base-js-ir")
|
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base")
|
||||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-base-js-legacy")
|
|
||||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-lib")
|
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-lib")
|
||||||
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-app")
|
assertDirectoryInProjectExists("build/js/packages/kotlin-js-browser-app")
|
||||||
|
|
||||||
if (irBackend) {
|
assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/app.js")
|
||||||
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")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build("clean", "browserDistribution") {
|
build("clean", "browserDistribution") {
|
||||||
assertTasksExecuted(
|
assertTasksExecuted(
|
||||||
":app:processResources",
|
":app:processResources",
|
||||||
if (irBackend) ":app:browserProductionExecutableDistributeResources" else ":app:browserDistributeResources"
|
":app:browserProductionExecutableDistributeResources"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (irBackend) {
|
assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/index.html")
|
||||||
assertFileInProjectExists("app/build/${Distribution.DIST}/js/productionExecutable/index.html")
|
|
||||||
} else {
|
|
||||||
assertFileInProjectExists("app/build/distributions/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")
|
@DisplayName("NodeJs test with custom fork options")
|
||||||
@GradleTest
|
@GradleTest
|
||||||
fun testNodeJsForkOptions(gradleVersion: GradleVersion) {
|
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")
|
@DisplayName("nodejs up-to-date check works")
|
||||||
@GradleTest
|
@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
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.Disabled
|
import org.junit.jupiter.api.Disabled
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
@@ -38,7 +37,6 @@ class Kotlin2FirJsIrBeIncrementalCompilationIT : Kotlin2JsIrBeIncrementalCompila
|
|||||||
open class Kotlin2JsIrBeIncrementalCompilationIT : KGPBaseTest() {
|
open class Kotlin2JsIrBeIncrementalCompilationIT : KGPBaseTest() {
|
||||||
override val defaultBuildOptions = BuildOptions(
|
override val defaultBuildOptions = BuildOptions(
|
||||||
jsOptions = BuildOptions.JsOptions(
|
jsOptions = BuildOptions.JsOptions(
|
||||||
jsCompilerType = KotlinJsCompilerType.IR,
|
|
||||||
incrementalJsKlib = true,
|
incrementalJsKlib = true,
|
||||||
incrementalJsIr = true
|
incrementalJsIr = true
|
||||||
),
|
),
|
||||||
|
|||||||
-3
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
|
|
||||||
@@ -14,8 +13,6 @@ import org.junit.jupiter.api.DisplayName
|
|||||||
class KotlinJsDomApiDependencyIT : KGPBaseTest() {
|
class KotlinJsDomApiDependencyIT : KGPBaseTest() {
|
||||||
|
|
||||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||||
useIrBackend = true,
|
|
||||||
jsCompilerType = KotlinJsCompilerType.IR
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override val defaultBuildOptions =
|
override val defaultBuildOptions =
|
||||||
|
|||||||
-10
@@ -8,13 +8,10 @@ package org.jetbrains.kotlin.gradle
|
|||||||
import org.gradle.api.logging.LogLevel
|
import org.gradle.api.logging.LogLevel
|
||||||
import org.gradle.testkit.runner.BuildResult
|
import org.gradle.testkit.runner.BuildResult
|
||||||
import org.gradle.util.GradleVersion
|
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_INCREMENTAL_COMPILATION_MESSAGE
|
||||||
import org.jetbrains.kotlin.gradle.tasks.USING_JS_IR_BACKEND_MESSAGE
|
import org.jetbrains.kotlin.gradle.tasks.USING_JS_IR_BACKEND_MESSAGE
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
import kotlin.io.path.*
|
|
||||||
import kotlin.test.*
|
|
||||||
|
|
||||||
@JsGradlePluginTests
|
@JsGradlePluginTests
|
||||||
open class KotlinJsIr10IncrementalGradlePluginIT : AbstractKotlinJsIncrementalGradlePluginIT(
|
open class KotlinJsIr10IncrementalGradlePluginIT : AbstractKotlinJsIncrementalGradlePluginIT(
|
||||||
@@ -29,19 +26,12 @@ class KotlinJsFirIncrementalGradlePluginIT : KotlinJsIr10IncrementalGradlePlugin
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsGradlePluginTests
|
|
||||||
open class KotlinJsLegacy10IncrementalGradlePluginIT : AbstractKotlinJsIncrementalGradlePluginIT(
|
|
||||||
irBackend = false
|
|
||||||
)
|
|
||||||
|
|
||||||
@JsGradlePluginTests
|
@JsGradlePluginTests
|
||||||
abstract class AbstractKotlinJsIncrementalGradlePluginIT(
|
abstract class AbstractKotlinJsIncrementalGradlePluginIT(
|
||||||
protected val irBackend: Boolean
|
protected val irBackend: Boolean
|
||||||
) : KGPBaseTest() {
|
) : KGPBaseTest() {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
private val defaultJsOptions = BuildOptions.JsOptions(
|
private val defaultJsOptions = BuildOptions.JsOptions(
|
||||||
useIrBackend = irBackend,
|
|
||||||
jsCompilerType = if (irBackend) KotlinJsCompilerType.IR else KotlinJsCompilerType.LEGACY
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override val defaultBuildOptions =
|
override val defaultBuildOptions =
|
||||||
|
|||||||
-3
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.gradle
|
|||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import org.gradle.util.GradleVersion
|
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.targets.js.dsl.Distribution.Companion.DIST
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.DisplayName
|
import org.junit.jupiter.api.DisplayName
|
||||||
@@ -21,8 +20,6 @@ abstract class KotlinJsIrLibraryGradlePluginITBase : KGPBaseTest() {
|
|||||||
|
|
||||||
override val defaultBuildOptions = super.defaultBuildOptions.copy(
|
override val defaultBuildOptions = super.defaultBuildOptions.copy(
|
||||||
jsOptions = BuildOptions.JsOptions(
|
jsOptions = BuildOptions.JsOptions(
|
||||||
useIrBackend = true,
|
|
||||||
jsCompilerType = KotlinJsCompilerType.IR
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+3
@@ -86,6 +86,9 @@ class KotlinSpecificDependenciesIT : KGPBaseTest() {
|
|||||||
gradleProperties.appendText(
|
gradleProperties.appendText(
|
||||||
"\nkotlin.stdlib.default.dependency=false"
|
"\nkotlin.stdlib.default.dependency=false"
|
||||||
)
|
)
|
||||||
|
gradleProperties.appendText(
|
||||||
|
"\nkotlin.js.stdlib.dom.api.included=false"
|
||||||
|
)
|
||||||
checkTaskCompileClasspath(
|
checkTaskCompileClasspath(
|
||||||
"compileKotlinJs",
|
"compileKotlinJs",
|
||||||
listOf(),
|
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.MPPNativeTargets
|
||||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProject
|
import org.jetbrains.kotlin.gradle.native.transformNativeTestProject
|
||||||
import org.jetbrains.kotlin.gradle.native.transformNativeTestProjectWithPluginDsl
|
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.ProjectLocalConfigurations
|
||||||
import org.jetbrains.kotlin.gradle.plugin.diagnostics.KotlinToolingDiagnostics
|
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.mpp.KotlinMultiplatformPlugin
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.UnsatisfiedSourceSetVisibilityException
|
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
|
@Test
|
||||||
fun testLibAndAppJsIr() = doTestLibAndAppJsBothCompilers(
|
fun testLibAndAppJsIr() = doTestLibAndAppJsBothCompilers(
|
||||||
"sample-lib",
|
"sample-lib",
|
||||||
"sample-app",
|
"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
|
@Test
|
||||||
fun testLibAndAppWithGradleKotlinDslJsIr() = doTestLibAndAppJsBothCompilers(
|
fun testLibAndAppWithGradleKotlinDslJsIr() = doTestLibAndAppJsBothCompilers(
|
||||||
"sample-lib-gradle-kotlin-dsl",
|
"sample-lib-gradle-kotlin-dsl",
|
||||||
"sample-app-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(
|
private fun doTestLibAndAppJsBothCompilers(
|
||||||
libProjectName: String,
|
libProjectName: String,
|
||||||
appProjectName: String,
|
appProjectName: String,
|
||||||
jsCompilerType: KotlinJsCompilerType,
|
|
||||||
) {
|
) {
|
||||||
val libProject = transformProjectWithPluginsDsl(libProjectName, directoryPrefix = "both-js-lib-and-app")
|
val libProject = transformProjectWithPluginsDsl(libProjectName, directoryPrefix = "both-js-lib-and-app")
|
||||||
val appProject = transformProjectWithPluginsDsl(appProjectName, directoryPrefix = "both-js-lib-and-app")
|
val appProject = transformProjectWithPluginsDsl(appProjectName, directoryPrefix = "both-js-lib-and-app")
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
val compileTasksNames =
|
val compileTasksNames = listOf(":compileKotlinNodeJs")
|
||||||
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" }
|
|
||||||
|
|
||||||
with(libProject) {
|
with(libProject) {
|
||||||
gradleProperties().appendText(
|
gradleProperties().appendText(
|
||||||
@@ -333,7 +286,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
)
|
)
|
||||||
build(
|
build(
|
||||||
"publish",
|
"publish",
|
||||||
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
|
options = defaultBuildOptions()
|
||||||
) {
|
) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertTasksNotExecuted(":compileCommonMainKotlinMetadata")
|
assertTasksNotExecuted(":compileCommonMainKotlinMetadata")
|
||||||
@@ -342,7 +295,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
val groupDir = projectDir.resolve("repo/com/example")
|
val groupDir = projectDir.resolve("repo/com/example")
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@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 jsJarName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension"
|
||||||
val metadataJarName = "sample-lib/1.0/sample-lib-1.0.jar"
|
val metadataJarName = "sample-lib/1.0/sample-lib-1.0.jar"
|
||||||
|
|
||||||
@@ -365,21 +318,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
groupDir.resolve(jsJarName).exists()
|
||||||
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 -> {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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
|
// we use `maven { setUrl(...) }` because this syntax actually works both for Groovy and Kotlin DSLs in Gradle
|
||||||
gradleBuildScript().appendText("\nrepositories { maven { setUrl(\"$libLocalRepoUri\") } }")
|
gradleBuildScript().appendText("\nrepositories { maven { setUrl(\"$libLocalRepoUri\") } }")
|
||||||
|
|
||||||
fun CompiledProject.checkAppBuild(compilerType: KotlinJsCompilerType) {
|
fun CompiledProject.checkAppBuild() {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
val compileTaskNames = if (jsCompilerType == compilerType) {
|
|
||||||
compileTasksNames.toTypedArray()
|
|
||||||
} else {
|
|
||||||
arrayOf(":compileKotlinNodeJs")
|
|
||||||
}
|
|
||||||
assertTasksExecuted(*compileTaskNames)
|
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
assertTasksExecuted(compileTasksNames)
|
||||||
if (jsCompilerType == KotlinJsCompilerType.LEGACY) {
|
|
||||||
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
|
|
||||||
Assert.assertTrue(contains("console.info"))
|
|
||||||
Assert.assertTrue(contains("function nodeJsMain("))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build(
|
build(
|
||||||
"assemble",
|
"assemble",
|
||||||
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
|
options = defaultBuildOptions()
|
||||||
) {
|
) {
|
||||||
checkAppBuild(jsCompilerType)
|
checkAppBuild()
|
||||||
}
|
|
||||||
|
|
||||||
@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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now run again with a project dependency instead of a module one:
|
// Now run again with a project dependency instead of a module one:
|
||||||
@@ -453,9 +363,9 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
"clean",
|
"clean",
|
||||||
"assemble",
|
"assemble",
|
||||||
"--rerun-tasks",
|
"--rerun-tasks",
|
||||||
options = defaultBuildOptions().copy(jsCompilerType = jsCompilerType)
|
options = defaultBuildOptions()
|
||||||
) {
|
) {
|
||||||
checkAppBuild(jsCompilerType)
|
checkAppBuild()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1021,7 +931,7 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
libProject.build(
|
libProject.build(
|
||||||
"publish",
|
"publish",
|
||||||
options = buildOptions.copy(jsCompilerType = KotlinJsCompilerType.BOTH)
|
options = buildOptions
|
||||||
) {
|
) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
@@ -1063,25 +973,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
""".trimIndent()
|
""".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
|
@Test
|
||||||
fun testDefaultSourceSetsDsl() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
fun testDefaultSourceSetsDsl() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
|
|||||||
-9
@@ -6,8 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.gradle
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.util.GradleVersion
|
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.jetbrains.kotlin.gradle.util.*
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
@@ -41,13 +39,6 @@ class VariantAwareDependenciesMppIT : BaseGradleIT() {
|
|||||||
testResolveAllConfigurations(subproject = innerProject.projectName) {
|
testResolveAllConfigurations(subproject = innerProject.projectName) {
|
||||||
assertContains(">> :${innerProject.projectName}:runtimeClasspath --> sample-lib-nodejs-1.0.klib")
|
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
|
package org.jetbrains.kotlin.gradle
|
||||||
|
|
||||||
import org.gradle.util.GradleVersion
|
import org.gradle.util.GradleVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
|
||||||
import org.jetbrains.kotlin.gradle.testbase.*
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
import org.junit.jupiter.api.DisplayName
|
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.cli.common.CompilerSystemProperties.COMPILE_INCREMENTAL_WITH_ARTIFACT_TRANSFORM
|
||||||
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
import org.jetbrains.kotlin.gradle.BaseGradleIT
|
||||||
import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
|
import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
|
|
||||||
import org.jetbrains.kotlin.gradle.report.BuildReportType
|
import org.jetbrains.kotlin.gradle.report.BuildReportType
|
||||||
import org.junit.jupiter.api.condition.OS
|
import org.junit.jupiter.api.condition.OS
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -57,12 +56,9 @@ data class BuildOptions(
|
|||||||
)
|
)
|
||||||
|
|
||||||
data class JsOptions(
|
data class JsOptions(
|
||||||
val useIrBackend: Boolean? = null,
|
|
||||||
val jsCompilerType: KotlinJsCompilerType? = null,
|
|
||||||
val incrementalJs: Boolean? = null,
|
val incrementalJs: Boolean? = null,
|
||||||
val incrementalJsKlib: Boolean? = null,
|
val incrementalJsKlib: Boolean? = null,
|
||||||
val incrementalJsIr: Boolean? = null,
|
val incrementalJsIr: Boolean? = null
|
||||||
val compileNoWarn: Boolean = true,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data class NativeOptions(
|
data class NativeOptions(
|
||||||
@@ -141,14 +137,6 @@ data class BuildOptions(
|
|||||||
jsOptions.incrementalJs?.let { arguments.add("-Pkotlin.incremental.js=$it") }
|
jsOptions.incrementalJs?.let { arguments.add("-Pkotlin.incremental.js=$it") }
|
||||||
jsOptions.incrementalJsKlib?.let { arguments.add("-Pkotlin.incremental.js.klib=$it") }
|
jsOptions.incrementalJsKlib?.let { arguments.add("-Pkotlin.incremental.js.klib=$it") }
|
||||||
jsOptions.incrementalJsIr?.let { arguments.add("-Pkotlin.incremental.js.ir=$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) {
|
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
@@ -1,2 +1 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin.js.generate.executable.default=false
|
|
||||||
-4
@@ -26,7 +26,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -33,7 +33,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
-4
@@ -41,7 +41,3 @@ publishing {
|
|||||||
maven { setUrl("file://${projectDir.absolutePath.replace('\\', '/')}/repo") }
|
maven { setUrl("file://${projectDir.absolutePath.replace('\\', '/')}/repo") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -54,7 +54,3 @@ publishing {
|
|||||||
maven { url "file://${projectDir.absolutePath.replace('\\', '/')}/repo" }
|
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.code.style=official
|
||||||
kotlin.js.generate.executable.default=false
|
|
||||||
kotlin.mpp.enableCInteropCommonization=true
|
kotlin.mpp.enableCInteropCommonization=true
|
||||||
kotlin.mpp.enableIntransitiveMetadataConfiguration=true
|
kotlin.mpp.enableIntransitiveMetadataConfiguration=true
|
||||||
|
|||||||
-1
@@ -1,2 +1 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin.js.generate.executable.default=false
|
|
||||||
|
|||||||
-1
@@ -1 +0,0 @@
|
|||||||
kotlin.js.compiler=legacy
|
|
||||||
+4
-4
@@ -11,6 +11,10 @@ dependencies {
|
|||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-js"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
js()
|
||||||
|
}
|
||||||
|
|
||||||
if (project.findProperty("mppProjectDependency") == "true") {
|
if (project.findProperty("mppProjectDependency") == "true") {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -28,7 +32,3 @@ if (project.findProperty("mppProjectDependency") == "true") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
-4
@@ -40,7 +40,3 @@ publishing {
|
|||||||
maven { setUrl("${rootProject.buildDir}/repo") }
|
maven { setUrl("${rootProject.buildDir}/repo") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -58,7 +58,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -87,7 +87,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -94,7 +94,3 @@ publishing {
|
|||||||
maven("<localRepo>")
|
maven("<localRepo>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -106,7 +106,3 @@ publishing {
|
|||||||
maven("<localRepo>")
|
maven("<localRepo>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -55,7 +55,3 @@ publishing {
|
|||||||
maven("<localRepo>")
|
maven("<localRepo>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -41,7 +41,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -27,7 +27,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -36,7 +36,3 @@ publishing {
|
|||||||
maven("<localRepo>")
|
maven("<localRepo>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -38,7 +38,3 @@ publishing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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"
|
testImplementation "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
def jsUseIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() == true
|
|
||||||
|
|
||||||
tasks.named("compileKotlinJs", Kotlin2JsCompile) {
|
tasks.named("compileKotlinJs", Kotlin2JsCompile) {
|
||||||
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
|
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js"
|
||||||
if (jsUseIrBackend) {
|
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
||||||
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
|
||||||
} else {
|
|
||||||
it.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("compileTestKotlinJs", Kotlin2JsCompile) {
|
tasks.named("compileTestKotlinJs", Kotlin2JsCompile) {
|
||||||
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js"
|
it.kotlinOptions.outputFile = "${buildDir}/kotlin2js/test/module-tests.js"
|
||||||
if (jsUseIrBackend) {
|
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||||
it.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
|
||||||
} else {
|
|
||||||
it.kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -34,6 +34,3 @@ tasks.named("browserTest") {
|
|||||||
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack> {
|
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack> {
|
||||||
dependsOn("foo")
|
dependsOn("foo")
|
||||||
}
|
}
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
+4
@@ -1,3 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "org.jetbrains.kotlin.js"
|
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 {
|
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink>().configureEach {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
moduleKind = "es"
|
moduleKind = "es"
|
||||||
|
|||||||
+4
-11
@@ -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 {
|
plugins {
|
||||||
kotlin("js")
|
kotlin("js")
|
||||||
@@ -10,18 +10,11 @@ dependencies {
|
|||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
kotlin {
|
kotlin {
|
||||||
js("both")
|
js("ir")
|
||||||
js(BOTH)
|
js(IR)
|
||||||
js(BOTH_TYPE) {
|
js(IR_TYPE) {
|
||||||
useCommonJs()
|
useCommonJs()
|
||||||
browser {
|
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"
|
|
||||||
}
|
|
||||||
|
|||||||
-7
@@ -14,10 +14,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
plugins {
|
||||||
kotlin("multiplatform")
|
kotlin("multiplatform")
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -28,6 +28,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-3
@@ -36,6 +36,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -25,7 +25,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-7
@@ -20,10 +20,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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")
|
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
|
kotlin.tests.individualTaskReports=true
|
||||||
#because of dependency (kotlinx-html) which is not klib yet
|
#because of dependency (kotlinx-html) which is not klib yet
|
||||||
kotlin.js.compiler=legacy
|
|
||||||
|
|||||||
-4
@@ -65,7 +65,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -20,7 +20,3 @@ kotlin {
|
|||||||
binaries.executable()
|
binaries.executable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -18,7 +18,3 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -26,7 +26,3 @@ 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.moduleKind = "amd"
|
||||||
compileKotlin2Js.kotlinOptions.outputFile = outDir + "app.js"
|
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 {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
@@ -60,9 +58,4 @@ build.doLast {
|
|||||||
into "${buildDir}/kotlin2js/main/"
|
into "${buildDir}/kotlin2js/main/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|
||||||
runRhino.dependsOn build
|
runRhino.dependsOn build
|
||||||
+2
-4
@@ -20,7 +20,5 @@ dependencies {
|
|||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
|
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"]
|
||||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
|
||||||
}
|
|
||||||
+2
-5
@@ -31,17 +31,14 @@ def outDir = "${buildDir}/kotlin2js/main/"
|
|||||||
|
|
||||||
compileKotlin2Js.kotlinOptions.outputFile = outDir + "test-library.js"
|
compileKotlin2Js.kotlinOptions.outputFile = outDir + "test-library.js"
|
||||||
|
|
||||||
def isIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean()
|
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir"]
|
||||||
if (isIrBackend) {
|
|
||||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir"]
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
from sourceSets.main.allSource
|
from sourceSets.main.allSource
|
||||||
include "**/*.kt"
|
include "**/*.kt"
|
||||||
|
|
||||||
from outDir
|
from outDir
|
||||||
include (isIrBackend ? "**/*" : "**/*.js")
|
include ("**/*")
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes(
|
attributes(
|
||||||
|
|||||||
+1
-3
@@ -25,9 +25,7 @@ compileKotlin2Js.kotlinOptions.outputFile = "${projectDir}/web/js/app.js"
|
|||||||
compileKotlin2Js.kotlinOptions.suppressWarnings = true
|
compileKotlin2Js.kotlinOptions.suppressWarnings = true
|
||||||
compileKotlin2Js.kotlinOptions.verbose = 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 {
|
build.doLast {
|
||||||
configurations.compile.each { File file ->
|
configurations.compile.each { File file ->
|
||||||
|
|||||||
+5
-20
@@ -12,7 +12,7 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
subprojects {
|
||||||
apply(plugin = "org.jetbrains.kotlin.js")
|
apply(plugin = "org.jetbrains.kotlin.js")
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -21,29 +21,21 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val useIrBackend = (findProperty("kotlin.js.useIrBackend") as? String?)?.toBoolean() ?: false
|
kotlin {
|
||||||
|
js()
|
||||||
val backend = if (useIrBackend) {
|
|
||||||
KotlinJsCompilerType.IR
|
|
||||||
} else {
|
|
||||||
KotlinJsCompilerType.LEGACY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project("lib") {
|
project("lib") {
|
||||||
kotlin {
|
kotlin {
|
||||||
js(backend) {
|
js {
|
||||||
browser()
|
browser()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinJsCompile>() {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project("app") {
|
project("app") {
|
||||||
kotlin {
|
kotlin {
|
||||||
js(backend) {
|
js {
|
||||||
browser()
|
browser()
|
||||||
binaries.executable()
|
binaries.executable()
|
||||||
}
|
}
|
||||||
@@ -51,11 +43,4 @@ project("app") {
|
|||||||
implementation(project(":lib"))
|
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"
|
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"]
|
||||||
compileKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-klib-dir", "-Xir-only"]
|
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
||||||
compileTestKotlin2Js.kotlinOptions.freeCompilerArgs += ["-Xir-produce-js"]
|
compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/"
|
||||||
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"
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
kotlin.js.compiler=legacy
|
|
||||||
-4
@@ -43,7 +43,3 @@ publishing {
|
|||||||
maven { setUrl("${rootProject.buildDir}/repo") }
|
maven { setUrl("${rootProject.buildDir}/repo") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -40,7 +40,3 @@ publishing {
|
|||||||
maven { setUrl("${rootProject.buildDir}/repo") }
|
maven { setUrl("${rootProject.buildDir}/repo") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-2
@@ -1,3 +1 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin.js.generate.executable.default=false
|
|
||||||
kotlin.js.compiler=ir
|
|
||||||
|
|||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin.js.generate.executable.default=false
|
|
||||||
|
|
||||||
# Test is about compatibility, only version 1 was available in previous versions
|
# Test is about compatibility, only version 1 was available in previous versions
|
||||||
kotlin.mpp.androidSourceSetLayoutVersion=1
|
kotlin.mpp.androidSourceSetLayoutVersion=1
|
||||||
-4
@@ -80,7 +80,3 @@ task printCompilerPluginOptions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -98,7 +98,3 @@ publishing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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'
|
|
||||||
-4
@@ -24,7 +24,3 @@ kotlin {
|
|||||||
js("server")
|
js("server")
|
||||||
js("client")
|
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
|
|
||||||
-4
@@ -92,7 +92,3 @@ tasks.register("resolveRuntimeDependencies", DefaultTask) {
|
|||||||
configurations[configName].resolve()
|
configurations[configName].resolve()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -65,7 +65,3 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -116,7 +116,3 @@ afterEvaluate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile) {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -37,7 +37,3 @@ kotlin.sourceSets {
|
|||||||
kotlin.target {
|
kotlin.target {
|
||||||
nodejs()
|
nodejs()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile> {
|
|
||||||
kotlinOptions.freeCompilerArgs += "-Xforce-deprecated-legacy-compiler-usage"
|
|
||||||
}
|
|
||||||
|
|||||||
-4
@@ -16,7 +16,3 @@ kotlin {
|
|||||||
nodejs()
|
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 getAndroidNativeTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||||
public fun getAppleMain (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 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 getCommonMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||||
public fun getCommonTest (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;
|
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 getJsTest (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||||
public fun getJvmMain (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 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 getLinuxMain (Lorg/gradle/api/NamedDomainObjectContainer;)Lorg/gradle/api/NamedDomainObjectProvider;
|
||||||
public fun getLinuxTest (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;
|
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.InternalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginLifecycle.Stage.AfterFinaliseDsl
|
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.hierarchy.KotlinHierarchyDslImpl
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -33,13 +32,14 @@ abstract class KotlinMultiplatformExtension
|
|||||||
|
|
||||||
final override val targets: NamedDomainObjectCollection<KotlinTarget> = project.container(KotlinTarget::class.java)
|
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> {
|
internal suspend fun awaitTargets(): NamedDomainObjectCollection<KotlinTarget> {
|
||||||
AfterFinaliseDsl.await()
|
AfterFinaliseDsl.await()
|
||||||
return targets
|
return targets
|
||||||
}
|
}
|
||||||
|
|
||||||
override val compilerTypeFromProperties: KotlinJsCompilerType? = project.kotlinPropertiesProvider.jsCompiler
|
|
||||||
|
|
||||||
private val presetExtension = project.objects.newInstance(
|
private val presetExtension = project.objects.newInstance(
|
||||||
DefaultTargetsFromPresetExtension::class.java,
|
DefaultTargetsFromPresetExtension::class.java,
|
||||||
{ this },
|
{ 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_BUILD_TOOLS_API_IMPL
|
||||||
import org.jetbrains.kotlin.gradle.internal.KOTLIN_MODULE_GROUP
|
import org.jetbrains.kotlin.gradle.internal.KOTLIN_MODULE_GROUP
|
||||||
import org.jetbrains.kotlin.gradle.plugin.*
|
import org.jetbrains.kotlin.gradle.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.kotlinPropertiesProvider
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsSingleTargetPreset
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinPm20ProjectExtension
|
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.KotlinPm20ProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatsService
|
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.dsl.KotlinJsTargetDsl
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
||||||
import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon
|
import org.jetbrains.kotlin.gradle.tasks.CompileUsingKotlinDaemon
|
||||||
import org.jetbrains.kotlin.gradle.tasks.withType
|
import org.jetbrains.kotlin.gradle.tasks.withType
|
||||||
import org.jetbrains.kotlin.gradle.utils.castIsolatedKotlinPluginClassLoaderAware
|
import org.jetbrains.kotlin.gradle.utils.castIsolatedKotlinPluginClassLoaderAware
|
||||||
import org.jetbrains.kotlin.gradle.utils.configureExperimentalTryK2
|
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.konan.target.CompilerOutputKind
|
||||||
import org.jetbrains.kotlin.statistics.metrics.StringMetrics
|
import org.jetbrains.kotlin.statistics.metrics.StringMetrics
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
@@ -232,10 +228,11 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
|||||||
KotlinJsCompilerTypeHolder {
|
KotlinJsCompilerTypeHolder {
|
||||||
lateinit var irPreset: KotlinJsIrSingleTargetPreset
|
lateinit var irPreset: KotlinJsIrSingleTargetPreset
|
||||||
|
|
||||||
lateinit var legacyPreset: KotlinJsSingleTargetPreset
|
|
||||||
|
|
||||||
private val targetSetObservers = mutableListOf<(KotlinJsTargetDsl?) -> Unit>()
|
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
|
// target is public property
|
||||||
// Users can write kotlin.target and it should work
|
// Users can write kotlin.target and it should work
|
||||||
// So call of target should init default configuration
|
// So call of target should init default configuration
|
||||||
@@ -250,49 +247,6 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
|||||||
targetSetObservers.add(observer)
|
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()"))
|
@Deprecated("Use js() instead", ReplaceWith("js()"))
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
override val target: KotlinJsTargetDsl
|
override val target: KotlinJsTargetDsl
|
||||||
@@ -303,50 +257,15 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
|||||||
return _target!!
|
return _target!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override val compilerTypeFromProperties: KotlinJsCompilerType? = project.kotlinPropertiesProvider.jsCompiler
|
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
private fun jsInternal(
|
private fun jsInternal(
|
||||||
compiler: KotlinJsCompilerType? = null,
|
compiler: KotlinJsCompilerType? = null,
|
||||||
body: KotlinJsTargetDsl.() -> Unit
|
body: KotlinJsTargetDsl.() -> Unit,
|
||||||
): KotlinJsTargetDsl {
|
): 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) {
|
if (_target == null) {
|
||||||
val compilerOrFromProperties = compiler ?: compilerTypeFromProperties
|
val compilerOrDefault = compiler ?: defaultJsCompilerType
|
||||||
val compilerOrDefault = compilerOrFromProperties ?: defaultJsCompilerType
|
val target: KotlinJsTargetDsl = irPreset
|
||||||
reportJsCompilerMode(compilerOrDefault)
|
.createTarget("js")
|
||||||
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
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
this._target = target
|
this._target = target
|
||||||
|
|
||||||
@@ -360,19 +279,19 @@ abstract class KotlinJsProjectExtension(project: Project) :
|
|||||||
|
|
||||||
fun js(
|
fun js(
|
||||||
compiler: KotlinJsCompilerType = defaultJsCompilerType,
|
compiler: KotlinJsCompilerType = defaultJsCompilerType,
|
||||||
body: KotlinJsTargetDsl.() -> Unit = { }
|
body: KotlinJsTargetDsl.() -> Unit = { },
|
||||||
): KotlinJsTargetDsl = jsInternal(compiler, body)
|
): KotlinJsTargetDsl = jsInternal(compiler, body)
|
||||||
|
|
||||||
fun js(
|
fun js(
|
||||||
compiler: String,
|
compiler: String,
|
||||||
body: KotlinJsTargetDsl.() -> Unit = { }
|
body: KotlinJsTargetDsl.() -> Unit = { },
|
||||||
): KotlinJsTargetDsl = js(
|
): KotlinJsTargetDsl = js(
|
||||||
KotlinJsCompilerType.byArgument(compiler),
|
KotlinJsCompilerType.byArgument(compiler),
|
||||||
body
|
body
|
||||||
)
|
)
|
||||||
|
|
||||||
fun js(
|
fun js(
|
||||||
body: KotlinJsTargetDsl.() -> Unit = { }
|
body: KotlinJsTargetDsl.() -> Unit = { },
|
||||||
) = jsInternal(body = body)
|
) = jsInternal(body = body)
|
||||||
|
|
||||||
fun js() = js { }
|
fun js() = js { }
|
||||||
@@ -411,7 +330,7 @@ abstract class KotlinCommonProjectExtension(project: Project) : KotlinSingleJava
|
|||||||
internal set
|
internal set
|
||||||
|
|
||||||
open fun target(
|
open fun target(
|
||||||
body: KotlinWithJavaTarget<KotlinMultiplatformCommonOptions, KotlinMultiplatformCommonCompilerOptions>.() -> Unit
|
body: KotlinWithJavaTarget<KotlinMultiplatformCommonOptions, KotlinMultiplatformCommonCompilerOptions>.() -> Unit,
|
||||||
) = target.run(body)
|
) = target.run(body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-68
@@ -6,12 +6,8 @@
|
|||||||
package org.jetbrains.kotlin.gradle.dsl
|
package org.jetbrains.kotlin.gradle.dsl
|
||||||
|
|
||||||
import org.gradle.api.Action
|
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.plugin.*
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.calculateJsCompilerType
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
|
||||||
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
|
||||||
|
|
||||||
@KotlinGradlePluginDsl
|
@KotlinGradlePluginDsl
|
||||||
interface KotlinTargetContainerWithJsPresetFunctions :
|
interface KotlinTargetContainerWithJsPresetFunctions :
|
||||||
@@ -84,74 +80,12 @@ private fun KotlinTargetContainerWithJsPresetFunctions.jsInternal(
|
|||||||
compiler: KotlinJsCompilerType? = null,
|
compiler: KotlinJsCompilerType? = null,
|
||||||
configure: KotlinJsTargetDsl.() -> Unit
|
configure: KotlinJsTargetDsl.() -> Unit
|
||||||
): KotlinJsTargetDsl {
|
): 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")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return configureOrCreate(
|
return configureOrCreate(
|
||||||
targetName,
|
name,
|
||||||
presets.getByName(
|
presets.getByName(
|
||||||
lowerCamelCaseName(
|
"js"
|
||||||
"js",
|
|
||||||
if (compilerOrDefault == KotlinJsCompilerType.LEGACY) null else compilerOrDefault.lowerName
|
|
||||||
)
|
|
||||||
) as KotlinTargetPreset<KotlinJsTargetDsl>,
|
) as KotlinTargetPreset<KotlinJsTargetDsl>,
|
||||||
configure
|
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.mpp.pm20.KotlinPm20ProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope
|
import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.sourceSetDependencyConfigurationByScope
|
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.ir.KotlinJsIrCompilation
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.npm.SemVer
|
import org.jetbrains.kotlin.gradle.targets.js.npm.SemVer
|
||||||
|
|
||||||
@@ -79,10 +78,6 @@ private fun KotlinTarget.addKotlinDomApiDependency(
|
|||||||
dependencies: DependencyHandler,
|
dependencies: DependencyHandler,
|
||||||
coreLibrariesVersion: Provider<String>
|
coreLibrariesVersion: Provider<String>
|
||||||
) {
|
) {
|
||||||
if (this is KotlinJsTarget) {
|
|
||||||
irTarget?.addKotlinDomApiDependency(configurations, dependencies, coreLibrariesVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
compilations.configureEach { compilation ->
|
compilations.configureEach { compilation ->
|
||||||
if (compilation.platformType != KotlinPlatformType.js) return@configureEach
|
if (compilation.platformType != KotlinPlatformType.js) return@configureEach
|
||||||
if (compilation !is KotlinJsIrCompilation) return@configureEach
|
if (compilation !is KotlinJsIrCompilation) return@configureEach
|
||||||
|
|||||||
+1
@@ -350,6 +350,7 @@ abstract class AbstractKotlinJsPluginWrapper : KotlinBasePluginWrapper() {
|
|||||||
override val projectExtensionClass: KClass<out KotlinJsProjectExtension>
|
override val projectExtensionClass: KClass<out KotlinJsProjectExtension>
|
||||||
get() = KotlinJsProjectExtension::class
|
get() = KotlinJsProjectExtension::class
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
override fun whenBuildEvaluated(project: Project) = project.runProjectConfigurationHealthCheck {
|
override fun whenBuildEvaluated(project: Project) = project.runProjectConfigurationHealthCheck {
|
||||||
val isJsTargetUninitialized = (project.kotlinExtension as KotlinJsProjectExtension)
|
val isJsTargetUninitialized = (project.kotlinExtension as KotlinJsProjectExtension)
|
||||||
._target == null
|
._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.internal.artifactTypeAttribute
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.KotlinJsCompilerAttribute
|
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.KotlinWasmTargetAttribute
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
|
||||||
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||||
@@ -432,10 +431,6 @@ fun Configuration.usesPlatformOf(target: KotlinTarget): Configuration {
|
|||||||
|
|
||||||
val publishJsCompilerAttribute = PropertiesProvider(target.project).publishJsCompilerAttribute
|
val publishJsCompilerAttribute = PropertiesProvider(target.project).publishJsCompilerAttribute
|
||||||
|
|
||||||
if (publishJsCompilerAttribute && target is KotlinJsTarget) {
|
|
||||||
attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.legacy)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (publishJsCompilerAttribute && target is KotlinJsIrTarget) {
|
if (publishJsCompilerAttribute && target is KotlinJsIrTarget) {
|
||||||
if (target.platformType == KotlinPlatformType.js) {
|
if (target.platformType == KotlinPlatformType.js) {
|
||||||
attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir)
|
attributes.attribute(KotlinJsCompilerAttribute.jsCompilerAttribute, KotlinJsCompilerAttribute.ir)
|
||||||
|
|||||||
-18
@@ -242,9 +242,6 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
val wasmStabilityNoWarn: Boolean
|
val wasmStabilityNoWarn: Boolean
|
||||||
get() = booleanProperty("kotlin.wasm.stability.nowarn") ?: false
|
get() = booleanProperty("kotlin.wasm.stability.nowarn") ?: false
|
||||||
|
|
||||||
val jsCompilerNoWarn: Boolean
|
|
||||||
get() = booleanProperty("$jsCompilerProperty.nowarn") ?: false
|
|
||||||
|
|
||||||
val ignoreDisabledNativeTargets: Boolean?
|
val ignoreDisabledNativeTargets: Boolean?
|
||||||
get() = booleanProperty(KOTLIN_NATIVE_IGNORE_DISABLED_TARGETS)
|
get() = booleanProperty(KOTLIN_NATIVE_IGNORE_DISABLED_TARGETS)
|
||||||
|
|
||||||
@@ -447,27 +444,12 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
val errorJsGenerateExternals: Boolean?
|
val errorJsGenerateExternals: Boolean?
|
||||||
get() = booleanProperty("kotlin.js.generate.externals")
|
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
|
* Use Kotlin/JS backend compiler publishing attribute
|
||||||
*/
|
*/
|
||||||
val publishJsCompilerAttribute: Boolean
|
val publishJsCompilerAttribute: Boolean
|
||||||
get() = this.booleanProperty("$jsCompilerProperty.publish.attribute") ?: true
|
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
|
val stdlibDefaultDependency: Boolean
|
||||||
get() = booleanProperty(KOTLIN_STDLIB_DEFAULT_DEPENDENCY) ?: true
|
get() = booleanProperty(KOTLIN_STDLIB_DEFAULT_DEPENDENCY) ?: true
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -130,13 +130,7 @@ class KotlinMultiplatformPlugin : Plugin<Project> {
|
|||||||
fun setupDefaultPresets(project: Project) {
|
fun setupDefaultPresets(project: Project) {
|
||||||
with(project.multiplatformExtension.presets) {
|
with(project.multiplatformExtension.presets) {
|
||||||
add(KotlinJvmTargetPreset(project))
|
add(KotlinJvmTargetPreset(project))
|
||||||
add(KotlinJsTargetPreset(project).apply { irPreset = null })
|
add(KotlinJsIrTargetPreset(project))
|
||||||
add(KotlinJsIrTargetPreset(project).apply { mixedMode = false })
|
|
||||||
add(
|
|
||||||
KotlinJsTargetPreset(project).apply {
|
|
||||||
irPreset = KotlinJsIrTargetPreset(project).apply { mixedMode = true }
|
|
||||||
}
|
|
||||||
)
|
|
||||||
add(KotlinWasmTargetPreset(project))
|
add(KotlinWasmTargetPreset(project))
|
||||||
add(project.objects.newInstance(KotlinAndroidTargetPreset::class.java, project))
|
add(project.objects.newInstance(KotlinAndroidTargetPreset::class.java, project))
|
||||||
add(KotlinJvmWithJavaTargetPreset(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.javaSourceSets
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.copyAttributes
|
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.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.targets.js.ir.KotlinJsIrTarget
|
||||||
import org.jetbrains.kotlin.gradle.utils.*
|
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<*, *>) :
|
internal class JvmWithJavaCompilationDependencyConfigurationsFactory(private val target: KotlinWithJavaTarget<*, *>) :
|
||||||
KotlinCompilationImplFactory.KotlinCompilationDependencyConfigurationsFactory {
|
KotlinCompilationImplFactory.KotlinCompilationDependencyConfigurationsFactory {
|
||||||
override fun create(target: KotlinTarget, compilationName: String): KotlinCompilationConfigurationsContainer {
|
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
|
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"
|
private const val compilation = "compilation"
|
||||||
|
|||||||
-26
@@ -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.KotlinMetadataTarget
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationSourceSetsContainer
|
import org.jetbrains.kotlin.gradle.plugin.mpp.compilationImpl.KotlinCompilationSourceSetsContainer
|
||||||
import org.jetbrains.kotlin.gradle.plugin.sources.android.kotlinAndroidSourceSetLayout
|
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
|
import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName
|
||||||
|
|
||||||
internal class DefaultKotlinCompilationSourceSetsContainerFactory(
|
internal class DefaultKotlinCompilationSourceSetsContainerFactory(
|
||||||
@@ -51,27 +49,3 @@ internal class AndroidCompilationSourceSetsContainerFactory(
|
|||||||
return KotlinCompilationSourceSetsContainer(target.project.kotlinExtension.sourceSets.maybeCreate(sourceSetName))
|
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.NamedDomainObjectFactory
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.Configuration
|
|
||||||
import org.gradle.api.attributes.Category
|
import org.gradle.api.attributes.Category
|
||||||
import org.gradle.api.attributes.Usage
|
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.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinUsages
|
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.targets.metadata.isKotlinGranularMetadataEnabled
|
||||||
import org.jetbrains.kotlin.gradle.utils.getOrCreate
|
import org.jetbrains.kotlin.gradle.utils.getOrCreate
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -108,67 +101,10 @@ internal class DefaultKotlinSourceSetFactory(
|
|||||||
if (project.isKotlinGranularMetadataEnabled) {
|
if (project.isKotlinGranularMetadataEnabled) {
|
||||||
attributes.attribute(Usage.USAGE_ATTRIBUTE, project.usageByName(KotlinUsages.KOTLIN_METADATA))
|
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 =
|
override fun doCreateSourceSet(name: String): DefaultKotlinSourceSet =
|
||||||
project.objects.newInstance(DefaultKotlinSourceSet::class.java, project, name)
|
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