From 1e1810c9692021f458e4e8113de5a571767e1c03 Mon Sep 17 00:00:00 2001 From: Oleksandr Karpovich Date: Wed, 22 Jan 2025 11:53:39 +0100 Subject: [PATCH] Update the gradle plugin tests after kotlin 2.1.0 (#5210) --- .../integration/KotlinCompatibilityTest.kt | 23 ++---- .../test/tests/integration/ResourcesTest.kt | 2 +- .../jsMpp/build.gradle | 1 + .../jsMpp/settings.gradle | 1 + .../jsMpp/src/commonMain/kotlin/platform.kt | 0 .../jsMpp/src/jsMain/kotlin/platform.kt | 0 .../jsMpp/src/jvmMain/kotlin/platform.kt | 0 .../custom-compiler-args/build.gradle | 50 ------------ .../main-image.expected.png | Bin 137 -> 0 bytes .../custom-compiler-args/settings.gradle | 26 ------ .../src/desktopMain/kotlin/Main.kt | 76 ------------------ .../src/jsMain/kotlin/Main.js.kt | 7 -- 12 files changed, 8 insertions(+), 178 deletions(-) rename gradle-plugins/compose/src/test/test-projects/{beforeKotlin2 => application}/jsMpp/build.gradle (92%) rename gradle-plugins/compose/src/test/test-projects/{beforeKotlin2 => application}/jsMpp/settings.gradle (88%) rename gradle-plugins/compose/src/test/test-projects/{beforeKotlin2 => application}/jsMpp/src/commonMain/kotlin/platform.kt (100%) rename gradle-plugins/compose/src/test/test-projects/{beforeKotlin2 => application}/jsMpp/src/jsMain/kotlin/platform.kt (100%) rename gradle-plugins/compose/src/test/test-projects/{beforeKotlin2 => application}/jsMpp/src/jvmMain/kotlin/platform.kt (100%) delete mode 100644 gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/build.gradle delete mode 100644 gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/main-image.expected.png delete mode 100644 gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/settings.gradle delete mode 100644 gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/src/desktopMain/kotlin/Main.kt delete mode 100644 gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/src/jsMain/kotlin/Main.js.kt diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatibilityTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatibilityTest.kt index 8d2ef522a0f..36ef4d96e7a 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatibilityTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/KotlinCompatibilityTest.kt @@ -12,21 +12,17 @@ import org.jetbrains.compose.test.utils.checks import org.junit.jupiter.api.Test class KotlinCompatibilityTest : GradlePluginTestBase() { - @Test - fun testKotlinMpp_1_9_10() = testMpp("1.9.10") - - @Test - fun testKotlinJsMpp_1_9_24() = testJsMpp("1.9.24") + // Note: we can't test non-jvm targets with Kotlin older than 2.1.0, because of klib abi version bump in 2.1.0 @Test - fun testKotlinMpp_1_9_20() = testMpp("1.9.20") + fun testKotlinMpp_2_1_0() = testMpp("2.1.0") @Test - fun testKotlinJsMpp_1_9_20() = testJsMpp("1.9.20") + fun testKotlinJsMpp_2_1_0() = testJsMpp("2.1.0") private fun testMpp(kotlinVersion: String) = with( testProject( - "beforeKotlin2/mpp", + "application/mpp", testEnvironment = defaultTestEnvironment.copy(kotlinVersion = kotlinVersion) ) ) { @@ -39,7 +35,7 @@ class KotlinCompatibilityTest : GradlePluginTestBase() { private fun testJsMpp(kotlinVersion: String) = with( testProject( - "beforeKotlin2/jsMpp", + "application/jsMpp", testEnvironment = defaultTestEnvironment.copy(kotlinVersion = kotlinVersion) ) ) { @@ -87,15 +83,6 @@ class KotlinCompatibilityTest : GradlePluginTestBase() { ) ).checkCustomComposeCompiler() - @Test - fun testKotlinCheckDisabled() = testProject( - "beforeKotlin2/custom-compiler-args", defaultTestEnvironment.copy( - kotlinVersion = "1.9.21", - composeCompilerPlugin = "dependencies.compiler.forKotlin(\"1.9.20\")", - composeCompilerArgs = "\"suppressKotlinVersionCompatibilityCheck=1.9.21\"" - ) - ).checkCustomComposeCompiler(checkKJS = true) - private fun TestProject.checkCustomComposeCompiler(checkKJS: Boolean = false) { gradle(":runDistributable").checks { val actualMainImage = file("main-image.actual.png") diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt index 3e0e271927c..c3dc325408d 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt @@ -243,7 +243,7 @@ class ResourcesTest : GradlePluginTestBase() { @Test fun testMultiModuleResources() { - val environment = defaultTestEnvironment.copy(kotlinVersion = "2.0.0") + val environment = defaultTestEnvironment with( testProject("misc/kmpResourcePublication", environment) ) { diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/build.gradle b/gradle-plugins/compose/src/test/test-projects/application/jsMpp/build.gradle similarity index 92% rename from gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/build.gradle rename to gradle-plugins/compose/src/test/test-projects/application/jsMpp/build.gradle index 348b3a4b80a..32e45d82f04 100644 --- a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/build.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/jsMpp/build.gradle @@ -1,6 +1,7 @@ plugins { id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.compose" + id "org.jetbrains.kotlin.plugin.compose" } kotlin { diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/jsMpp/settings.gradle similarity index 88% rename from gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/settings.gradle rename to gradle-plugins/compose/src/test/test-projects/application/jsMpp/settings.gradle index f7ad89b242a..a749850576e 100644 --- a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/jsMpp/settings.gradle @@ -1,6 +1,7 @@ pluginManagement { plugins { id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' + id 'org.jetbrains.kotlin.plugin.compose' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' } repositories { diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/src/commonMain/kotlin/platform.kt b/gradle-plugins/compose/src/test/test-projects/application/jsMpp/src/commonMain/kotlin/platform.kt similarity index 100% rename from gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/src/commonMain/kotlin/platform.kt rename to gradle-plugins/compose/src/test/test-projects/application/jsMpp/src/commonMain/kotlin/platform.kt diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/src/jsMain/kotlin/platform.kt b/gradle-plugins/compose/src/test/test-projects/application/jsMpp/src/jsMain/kotlin/platform.kt similarity index 100% rename from gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/src/jsMain/kotlin/platform.kt rename to gradle-plugins/compose/src/test/test-projects/application/jsMpp/src/jsMain/kotlin/platform.kt diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/src/jvmMain/kotlin/platform.kt b/gradle-plugins/compose/src/test/test-projects/application/jsMpp/src/jvmMain/kotlin/platform.kt similarity index 100% rename from gradle-plugins/compose/src/test/test-projects/beforeKotlin2/jsMpp/src/jvmMain/kotlin/platform.kt rename to gradle-plugins/compose/src/test/test-projects/application/jsMpp/src/jvmMain/kotlin/platform.kt diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/build.gradle b/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/build.gradle deleted file mode 100644 index 2949d9367f4..00000000000 --- a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/build.gradle +++ /dev/null @@ -1,50 +0,0 @@ -import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform -import org.jetbrains.compose.desktop.application.dsl.TargetFormat - -plugins { - id "org.jetbrains.kotlin.multiplatform" - id "org.jetbrains.compose" -} - -kotlin { - jvm("desktop") - js(IR) { - browser() - binaries.executable() - } - sourceSets { - desktopMain { - dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib" - implementation compose.desktop.currentOs - } - } - - jsMain { - dependencies { - implementation compose.runtime - implementation compose.web.core - } - } - } -} - -compose { - kotlinCompilerPlugin.set(COMPOSE_COMPILER_PLUGIN_PLACEHOLDER) - kotlinCompilerPluginArgs.add(COMPOSE_COMPILER_PLUGIN_ARGS_PLACEHOLDER) - - desktop { - application { - mainClass = "Main" - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - } - - def projectPath = project.projectDir.absolutePath - if (DefaultNativePlatform.currentOperatingSystem.isWindows()) { - projectPath = projectPath.replace("\\", "\\\\") - } - args(projectPath) - } - } -} diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/main-image.expected.png b/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/main-image.expected.png deleted file mode 100644 index a8ed1ade6ff9f58699996f0e0ed48c257852a225..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4u@pObhHwBu4M$1`kniB>;us=v zx%bRTP6h)WX2+?|F5SKPY;v=VTjT}*o{|<0mlLfXF1vyiUT`n(P5zg$wJIZj>xI0n h7s{??c$?k|k$%OsGI3pCuQSjr22WQ%mvv4FO#t*sEr9?4 diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/settings.gradle b/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/settings.gradle deleted file mode 100644 index 78690551771..00000000000 --- a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/settings.gradle +++ /dev/null @@ -1,26 +0,0 @@ -pluginManagement { - plugins { - id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' - id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' - } - repositories { - mavenLocal() - gradlePluginPortal() - mavenCentral() - google() - maven { - url 'https://maven.pkg.jetbrains.space/public/p/compose/dev' - } - } -} -dependencyResolutionManagement { - repositories { - mavenCentral() - google() - maven { - url 'https://maven.pkg.jetbrains.space/public/p/compose/dev' - } - mavenLocal() - } -} -rootProject.name = "simple" diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/src/desktopMain/kotlin/Main.kt b/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/src/desktopMain/kotlin/Main.kt deleted file mode 100644 index e7d73f0092f..00000000000 --- a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/src/desktopMain/kotlin/Main.kt +++ /dev/null @@ -1,76 +0,0 @@ -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.* -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.GenericShape -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.Shape -import androidx.compose.ui.renderComposeScene -import org.jetbrains.skia.EncodedImageFormat -import java.io.File -import java.util.* - -object Main { - @JvmStatic - @OptIn(ExperimentalComposeUiApi::class) - fun main(args: Array) { - val workingDir = args.getOrNull(0)?.let { File(it) } - workingDir?.mkdirs() - if (workingDir == null || !workingDir.isDirectory) { - error("Working directory must be passes as the first argument. '$workingDir' is not a directory") - } - - val image = renderComposeScene(height = 10, width = 10) { - mainShape() - } - val encodedImage = image.encodeToData(EncodedImageFormat.PNG) ?: error("Could not encode image as png") - workingDir.resolve("main-image.actual.png").writeBytes(encodedImage.bytes) - - val mainMethods = this.javaClass.declaredMethods - .mapTo(TreeSet()) { it.name } - .joinToString("\n") - workingDir.resolve("main-methods.actual.txt").writeText(mainMethods) - } - - @Composable - fun mainShape() { - triangle(Color.Magenta) - } - - @Composable - fun unused() { - transitivelyUnused() - } - - @Composable - fun transitivelyUnused() { - triangle(Color.Gray) - } - - @Composable - fun keptByKeepRule() { - fillShape(Color.Blue, CircleShape) - } -} - -@Composable -fun triangle(color: Color) { - fillShape(color, GenericShape { size, _ -> - moveTo(size.width / 2f, 0f) - lineTo(size.width, size.height) - lineTo(0f, size.height) - }) -} - -@Composable -fun fillShape(color: Color, shape: Shape){ - Column(modifier = Modifier.fillMaxWidth().wrapContentSize(Alignment.Center)) { - Box( - modifier = Modifier.clip(shape).fillMaxSize().background(color) - ) - } -} \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/src/jsMain/kotlin/Main.js.kt b/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/src/jsMain/kotlin/Main.js.kt deleted file mode 100644 index 0dfe5d88d7d..00000000000 --- a/gradle-plugins/compose/src/test/test-projects/beforeKotlin2/custom-compiler-args/src/jsMain/kotlin/Main.js.kt +++ /dev/null @@ -1,7 +0,0 @@ -import org.jetbrains.compose.web.* -import org.jetbrains.compose.web.dom.* -fun main() { - renderComposableInBody { - Div { } - } -}