[Gradle, JS] Fix capilatiozation for gradle attributes
This commit is contained in:
+1
-1
@@ -510,7 +510,7 @@ abstract class AbstractKotlin2JsGradlePluginIT(private val irBackend: Boolean) :
|
||||
gradleSettingsScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
if (!irBackend) {
|
||||
gradleProperties().appendText(jsMode(JsCompilerType.LEGACY))
|
||||
gradleProperties().appendText(jsMode(JsCompilerType.legacy))
|
||||
}
|
||||
|
||||
build("build") {
|
||||
|
||||
+16
-16
@@ -67,42 +67,42 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
fun testLibAndApp() = doTestLibAndApp(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
JsCompilerType.LEGACY
|
||||
JsCompilerType.legacy
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppJsIr() = doTestLibAndApp(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
JsCompilerType.KLIB
|
||||
JsCompilerType.klib
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppJsMixed() = doTestLibAndApp(
|
||||
"sample-lib",
|
||||
"sample-app",
|
||||
JsCompilerType.BOTH
|
||||
JsCompilerType.both
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDsl() = doTestLibAndApp(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
JsCompilerType.LEGACY
|
||||
JsCompilerType.legacy
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDslJsIr() = doTestLibAndApp(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
JsCompilerType.KLIB
|
||||
JsCompilerType.klib
|
||||
)
|
||||
|
||||
@Test
|
||||
fun testLibAndAppWithGradleKotlinDslJsMixed() = doTestLibAndApp(
|
||||
"sample-lib-gradle-kotlin-dsl",
|
||||
"sample-app-gradle-kotlin-dsl",
|
||||
JsCompilerType.BOTH
|
||||
JsCompilerType.both
|
||||
)
|
||||
|
||||
private fun doTestLibAndApp(
|
||||
@@ -127,7 +127,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
|
||||
val groupDir = projectDir.resolve("repo/com/example")
|
||||
val jvmJarName = "sample-lib-jvm6/1.0/sample-lib-jvm6-1.0.jar"
|
||||
val jsExtension = if (jsCompilerType == JsCompilerType.LEGACY) "jar" else "klib"
|
||||
val jsExtension = if (jsCompilerType == JsCompilerType.legacy) "jar" else "klib"
|
||||
val jsJarName = "sample-lib-nodejs/1.0/sample-lib-nodejs-1.0.$jsExtension"
|
||||
val metadataJarName = "sample-lib-metadata/1.0/sample-lib-metadata-1.0.jar"
|
||||
val wasmKlibName = "sample-lib-wasm32/1.0/sample-lib-wasm32-1.0.klib"
|
||||
@@ -157,7 +157,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
Assert.assertTrue("com/example/lib/MainKt.class" in jvmJarEntries)
|
||||
|
||||
when (jsCompilerType) {
|
||||
JsCompilerType.LEGACY -> {
|
||||
JsCompilerType.legacy -> {
|
||||
val jsJar = ZipFile(groupDir.resolve(jsJarName))
|
||||
val compiledJs = jsJar.getInputStream(jsJar.getEntry("sample-lib.js")).reader().readText()
|
||||
Assert.assertTrue("function id(" in compiledJs)
|
||||
@@ -165,7 +165,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
Assert.assertTrue("function expectedFun(" in compiledJs)
|
||||
Assert.assertTrue("function main(" in compiledJs)
|
||||
}
|
||||
JsCompilerType.KLIB -> {
|
||||
JsCompilerType.klib -> {
|
||||
groupDir.resolve(jsJarName).exists()
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
Assert.assertTrue(resolve("com/example/app/AKt.kotlin_metadata").exists())
|
||||
}
|
||||
|
||||
if (jsCompilerType == JsCompilerType.LEGACY) {
|
||||
if (jsCompilerType == JsCompilerType.legacy) {
|
||||
projectDir.resolve(targetClassesDir("nodeJs")).resolve("sample-app.js").readText().run {
|
||||
Assert.assertTrue(contains("console.info"))
|
||||
Assert.assertTrue(contains("function nodeJsMain("))
|
||||
@@ -248,10 +248,10 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
assertTasksExecuted(":resolveRuntimeDependencies") // KT-26301
|
||||
}
|
||||
|
||||
if (jsCompilerType == JsCompilerType.BOTH) {
|
||||
if (jsCompilerType == JsCompilerType.both) {
|
||||
listOf(
|
||||
JsCompilerType.LEGACY,
|
||||
JsCompilerType.KLIB
|
||||
JsCompilerType.legacy,
|
||||
JsCompilerType.klib
|
||||
).forEach {
|
||||
build(
|
||||
"assemble",
|
||||
@@ -284,7 +284,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
if (jsCompilerType != JsCompilerType.LEGACY) return
|
||||
if (jsCompilerType != JsCompilerType.legacy) return
|
||||
|
||||
with(oldStyleAppProject) {
|
||||
setupWorkingDir()
|
||||
@@ -898,7 +898,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
projectDir.resolve("settings.gradle").modify { it.replace("enableFeaturePreview", "// enableFeaturePreview") }
|
||||
build(
|
||||
"publish",
|
||||
options = defaultBuildOptions().copy(jsCompilerType = JsCompilerType.LEGACY)
|
||||
options = defaultBuildOptions().copy(jsCompilerType = JsCompilerType.legacy)
|
||||
) { assertSuccessful() }
|
||||
projectDir.resolve("repo")
|
||||
}
|
||||
@@ -2310,7 +2310,7 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
setupWorkingDir()
|
||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
if (!jsIr) {
|
||||
gradleProperties().appendText(jsMode(JsCompilerType.LEGACY))
|
||||
gradleProperties().appendText(jsMode(JsCompilerType.legacy))
|
||||
}
|
||||
|
||||
val tasks = listOf("jvm", "js", nativeHostTargetName).map { ":compileIntegrationTestKotlin${it.capitalize()}" }
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ class VariantAwareDependenciesIT : BaseGradleIT() {
|
||||
assertContains(">> :${innerProject.projectName}:runtime --> sample-lib-nodejs-1.0.klib")
|
||||
}
|
||||
|
||||
gradleProperties().appendText(jsMode(JsCompilerType.LEGACY))
|
||||
gradleProperties().appendText(jsMode(JsCompilerType.legacy))
|
||||
|
||||
testResolveAllConfigurations(
|
||||
subproject = innerProject.projectName,
|
||||
|
||||
+5
-5
@@ -13,7 +13,7 @@ class WorkersIT : BaseGradleIT() {
|
||||
fun testParallelTasks() {
|
||||
parallelTasksImpl(
|
||||
isParallel = true,
|
||||
jsCompilerType = JsCompilerType.LEGACY
|
||||
jsCompilerType = JsCompilerType.legacy
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class WorkersIT : BaseGradleIT() {
|
||||
fun testParallelTasksJsIr() {
|
||||
parallelTasksImpl(
|
||||
isParallel = true,
|
||||
jsCompilerType = JsCompilerType.KLIB
|
||||
jsCompilerType = JsCompilerType.klib
|
||||
)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class WorkersIT : BaseGradleIT() {
|
||||
fun testNoParallelTasks() {
|
||||
parallelTasksImpl(
|
||||
isParallel = false,
|
||||
jsCompilerType = JsCompilerType.LEGACY
|
||||
jsCompilerType = JsCompilerType.legacy
|
||||
)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class WorkersIT : BaseGradleIT() {
|
||||
fun testNoParallelTasksJsIr() {
|
||||
parallelTasksImpl(
|
||||
isParallel = false,
|
||||
jsCompilerType = JsCompilerType.KLIB
|
||||
jsCompilerType = JsCompilerType.klib
|
||||
)
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class WorkersIT : BaseGradleIT() {
|
||||
kotlinClassesDir(sourceSet = "metadata/main") + "common/A.kotlin_metadata",
|
||||
kotlinClassesDir(sourceSet = "jvm/main") + "common/A.class",
|
||||
kotlinClassesDir(sourceSet = "js/main") +
|
||||
if (jsCompilerType == JsCompilerType.KLIB) "default/manifest" else "new-mpp-parallel.js"
|
||||
if (jsCompilerType == JsCompilerType.klib) "default/manifest" else "new-mpp-parallel.js"
|
||||
)
|
||||
expectedKotlinOutputFiles.forEach { assertFileExists(it) }
|
||||
assertSubstringCount("Loaded GradleKotlinCompilerWork", 1)
|
||||
|
||||
+5
-5
@@ -168,9 +168,9 @@ open class KotlinJsPluginWrapper @Inject constructor(
|
||||
val propertiesProvider = PropertiesProvider(project)
|
||||
|
||||
return when (propertiesProvider.jsCompiler) {
|
||||
JsCompilerType.KLIB -> KotlinJsIrPlugin(kotlinPluginVersion)
|
||||
JsCompilerType.LEGACY -> KotlinJsPlugin(kotlinPluginVersion, false)
|
||||
JsCompilerType.BOTH -> KotlinJsPlugin(kotlinPluginVersion, true)
|
||||
JsCompilerType.klib -> KotlinJsIrPlugin(kotlinPluginVersion)
|
||||
JsCompilerType.legacy -> KotlinJsPlugin(kotlinPluginVersion, false)
|
||||
JsCompilerType.both -> KotlinJsPlugin(kotlinPluginVersion, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,8 +180,8 @@ open class KotlinJsPluginWrapper @Inject constructor(
|
||||
val propertiesProvider = PropertiesProvider(project)
|
||||
|
||||
projectExtensionClass = when (propertiesProvider.jsCompiler) {
|
||||
JsCompilerType.KLIB -> KotlinJsIrProjectExtension::class
|
||||
JsCompilerType.LEGACY, JsCompilerType.BOTH -> KotlinJsProjectExtension::class
|
||||
JsCompilerType.klib -> KotlinJsIrProjectExtension::class
|
||||
JsCompilerType.legacy, JsCompilerType.both -> KotlinJsProjectExtension::class
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
* Use Kotlin/JS backend mode
|
||||
*/
|
||||
val jsCompiler: JsCompilerType
|
||||
get() = property(jsCompilerProperty)?.let { JsCompilerType.byArgument(it) } ?: JsCompilerType.KLIB
|
||||
get() = property(jsCompilerProperty)?.let { JsCompilerType.byArgument(it) } ?: JsCompilerType.klib
|
||||
|
||||
private fun propertyWithDeprecatedVariant(propName: String, deprecatedPropName: String): String? {
|
||||
val deprecatedProperty = property(deprecatedPropName)
|
||||
|
||||
+2
-2
@@ -449,11 +449,11 @@ fun Configuration.usesPlatformOf(target: KotlinTarget): Configuration {
|
||||
attributes.attribute(KotlinPlatformType.attribute, target.platformType)
|
||||
|
||||
if (target is KotlinJsTarget) {
|
||||
attributes.attribute(KotlinJsTarget.jsCompilerAttribute, JsCompilerType.LEGACY)
|
||||
attributes.attribute(KotlinJsTarget.jsCompilerAttribute, JsCompilerType.legacy)
|
||||
}
|
||||
|
||||
if (target is KotlinJsIrTarget) {
|
||||
attributes.attribute(KotlinJsTarget.jsCompilerAttribute, JsCompilerType.KLIB)
|
||||
attributes.attribute(KotlinJsTarget.jsCompilerAttribute, JsCompilerType.klib)
|
||||
}
|
||||
|
||||
// TODO: Provide an universal way to copy attributes from the target.
|
||||
|
||||
+3
-3
@@ -159,9 +159,9 @@ class KotlinMultiplatformPlugin(
|
||||
with(project.multiplatformExtension.presets) {
|
||||
add(KotlinJvmTargetPreset(project, kotlinPluginVersion))
|
||||
when (propertiesProvider.jsCompiler) {
|
||||
JsCompilerType.LEGACY -> add(KotlinJsTargetPreset(project, kotlinPluginVersion, null))
|
||||
JsCompilerType.KLIB -> add(KotlinJsIrTargetPreset(project, kotlinPluginVersion, false))
|
||||
JsCompilerType.BOTH -> add(
|
||||
JsCompilerType.legacy -> add(KotlinJsTargetPreset(project, kotlinPluginVersion, null))
|
||||
JsCompilerType.klib -> add(KotlinJsIrTargetPreset(project, kotlinPluginVersion, false))
|
||||
JsCompilerType.both -> add(
|
||||
KotlinJsTargetPreset(
|
||||
project,
|
||||
kotlinPluginVersion,
|
||||
|
||||
+5
-3
@@ -8,10 +8,12 @@ package org.jetbrains.kotlin.gradle.targets.js
|
||||
import org.gradle.api.Named
|
||||
import java.io.Serializable
|
||||
|
||||
// For Gradle attributes
|
||||
@Suppress("EnumEntryName")
|
||||
enum class JsCompilerType : Named, Serializable {
|
||||
LEGACY,
|
||||
KLIB,
|
||||
BOTH;
|
||||
legacy,
|
||||
klib,
|
||||
both;
|
||||
|
||||
override fun getName(): String =
|
||||
name.toLowerCase()
|
||||
|
||||
Reference in New Issue
Block a user