Setup Compose compiler runtime tests Enables runtime tests to run with latest Compose compiler version and snapshot runtime.
diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 186d0a0..42fc23c 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml
@@ -253,6 +253,18 @@ <sha256 value="00421ed4ed83f8b1ef2a22434a6c7102bb08e16b2cc4acfda503da9ddc213e91" origin="Generated by Gradle"/> </artifact> </component> + <component group="androidx.compose.runtime" name="runtime-test-utils" version="1.7.0-SNAPSHOT"> + <artifact name="runtime-test-utils-1.7.0-SNAPSHOT.jar"> + <md5 value="b49204b3c5e0b9db038e126467975dae" origin="Generated by Gradle"/> + <sha256 value="1d16976ceeb68559eff258b9aa613d7d6026b4e261a87b03c7eab89c64eef381" origin="Generated by Gradle"/> + </artifact> + </component> + <component group="androidx.compose.runtime" name="runtime-test-utils-desktop" version="1.7.0-SNAPSHOT"> + <artifact name="runtime-test-utils-desktop-1.7.0-SNAPSHOT.jar"> + <md5 value="7a5e0b8a2eb6176e39db1f276665985b" origin="Generated by Gradle"/> + <sha256 value="b3af6dee150eee9f15d23f5bb4ab393fe6921504a930b3d3fee6c7b3e1f02819" origin="Generated by Gradle"/> + </artifact> + </component> <component group="androidx.compose.ui" name="ui-util-desktop" version="1.7.0-SNAPSHOT"> <artifact name="ui-util-desktop-1.7.0-SNAPSHOT.jar"> <md5 value="de4b87c5d6c765931df25d4668ce2a22" origin="Generated by Gradle"/> @@ -4179,6 +4191,12 @@ <sha256 value="a4c74d94d64ce1abe53760fe0389dd941f6fc558d0dab35e47c085a11ec80f28" origin="Generated by Gradle"/> </artifact> </component> + <component group="org.jetbrains.kotlin" name="kotlin-test-junit" version="1.8.22"> + <artifact name="kotlin-test-junit-1.8.22.jar"> + <md5 value="0d49b5a601a611e4f40dfae2e72c37d7" origin="Generated by Gradle"/> + <sha256 value="a1e337cffee01219c5d42783ea78844e95e68d346a9c586bfbb7eb767810f7ea" origin="Generated by Gradle"/> + </artifact> + </component> <component group="org.jetbrains.kotlin" name="kotlin-tooling-core" version="1.8.20-dev-4242"> <artifact name="kotlin-tooling-core-1.8.20-dev-4242.jar"> <md5 value="3762be9ba7cdfc5e9e63dee28bab3515" origin="Generated by Gradle"/> @@ -4441,6 +4459,12 @@ <sha256 value="3145fd68ad71ec6100924f74f1b6d52d22250dc2771a56b4f164c2a22fb50cac" origin="Generated by Gradle"/> </artifact> </component> + <component group="org.jetbrains.kotlinx" name="kotlinx-coroutines-test-jvm" version="1.7.3"> + <artifact name="kotlinx-coroutines-test-jvm-1.7.3.jar"> + <md5 value="b874ff6ea64c2f728a3721bcdd400267" origin="Generated by Gradle"/> + <sha256 value="d19742a65dbdabc9ffdcb9f84a15c776e511a14da602d54ea4e078d6f7227a26" origin="Generated by Gradle"/> + </artifact> + </component> <component group="org.jetbrains.kotlinx" name="kotlinx-datetime-jvm" version="0.3.1"> <artifact name="kotlinx-datetime-jvm-0.3.1.jar"> <md5 value="7fe856499ef7fcc60f4db75ccc753619" origin="Generated by Gradle"/>
diff --git a/plugins/compose/compiler-hosted/integration-tests/build.gradle.kts b/plugins/compose/compiler-hosted/integration-tests/build.gradle.kts index 4926c8f..35fff39 100644 --- a/plugins/compose/compiler-hosted/integration-tests/build.gradle.kts +++ b/plugins/compose/compiler-hosted/integration-tests/build.gradle.kts
@@ -1,29 +1,19 @@ -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi -import org.jetbrains.kotlin.gradle.dsl.KotlinVersion - plugins { kotlin("multiplatform") } -val ComposeSnapshotId = "11751492" -val ComposeVersion = "1.7.0-SNAPSHOT" repositories { - maven("https://androidx.dev/snapshots/builds/$ComposeSnapshotId/artifacts/repository") + androidxSnapshotRepo() google() } optInToObsoleteDescriptorBasedAPI() kotlin { - jvmToolchain(17) + jvmToolchain(11) jvm() - @OptIn(ExperimentalKotlinGradlePluginApi::class) - compilerOptions { - languageVersion.set(KotlinVersion.KOTLIN_1_9) - } - sourceSets { commonTest.dependencies { implementation(project(":kotlin-stdlib-common")) @@ -62,9 +52,9 @@ implementation(project(":plugins:compose-compiler-plugin:compiler-hosted:integration-tests:protobuf-test-classes")) // external deps - implementation("androidx.compose.runtime:runtime:$ComposeVersion") - implementation("androidx.compose.foundation:foundation:$ComposeVersion") - implementation("androidx.compose.ui:ui:$ComposeVersion") + implementation(composeRuntime()) + implementation(composeFoundation()) + implementation(composeUi()) implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3.4") implementation("com.google.dagger:dagger:2.40.1") }
diff --git a/plugins/compose/compiler-hosted/runtime-tests/build.gradle b/plugins/compose/compiler-hosted/runtime-tests/build.gradle deleted file mode 100644 index 095b280..0000000 --- a/plugins/compose/compiler-hosted/runtime-tests/build.gradle +++ /dev/null
@@ -1,87 +0,0 @@ -/* - * Copyright 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import androidx.build.Publish -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -plugins { - id("AndroidXPlugin") -} - -androidXMultiplatform { - desktop() - - sourceSets { - commonMain { - } - - commonTest { - dependencies { - implementation(libs.kotlinStdlibCommon) - implementation(projectOrArtifact(":compose:runtime:runtime")) - implementation(projectOrArtifact(":compose:runtime:runtime-test-utils")) - implementation kotlin("test-junit") - implementation(libs.kotlinCoroutinesTest) - implementation(libs.kotlinReflect) - } - } - - desktopMain { - dependsOn(commonMain) - dependencies { - } - } - - desktopTest { - dependsOn(commonTest) - dependencies { - } - } - } -} - -// Add current version of Compose compiler plugin, as AndroidXCompose plugin pins to releases. -configurations { - composePlugin { - canBeConsumed = false - } -} - -dependencies { - composePlugin(project(":compose:compiler:compiler")) -} - -def composePluginFiles = configurations.getByName("composePlugin") - .incoming - .artifactView {} - .files - -tasks.withType(KotlinCompile).configureEach { - pluginClasspath.from(composePluginFiles) - kotlinOptions { - freeCompilerArgs += [ - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:nonSkippingGroupOptimization=true" - ] - } -} - -androidx { - name = "Compose compiler executable tests" - publish = Publish.NONE - inceptionYear = "2024" - description = "Contains executable Compose compiler tests that use Compose runtime." -}
diff --git a/plugins/compose/compiler-hosted/runtime-tests/build.gradle.kts b/plugins/compose/compiler-hosted/runtime-tests/build.gradle.kts new file mode 100644 index 0000000..f814d6b --- /dev/null +++ b/plugins/compose/compiler-hosted/runtime-tests/build.gradle.kts
@@ -0,0 +1,50 @@ +plugins { + kotlin("multiplatform") +} + +repositories { + androidxSnapshotRepo() + google() +} + +optInToObsoleteDescriptorBasedAPI() + + +dependencies { + // run compilation with the current compiler to ensure that Compose plugin is binary compatible + kotlinCompilerClasspath(project(":kotlin-compiler-embeddable")) + + kotlinCompilerPluginClasspath(project(":plugins:compose-compiler-plugin:compiler")) +} + +kotlin { + jvm() + + jvmToolchain(11) + + sourceSets { + commonTest.dependencies { + implementation(project(":kotlin-stdlib-common")) + implementation(kotlinTest("junit")) + } + + val jvmTest by getting { + dependsOn(commonTest.get()) + + dependencies { + // junit + implementation(libs.junit4) + implementation(project.dependencies.platform(libs.junit.bom)) + implementation(libs.junit.jupiter.api) + runtimeOnly(libs.junit.jupiter.engine) + + // kotlin deps + implementation(project(":kotlin-stdlib")) + + // external deps + implementation(composeRuntime()) + implementation(composeRuntimeTestUtils()) + } + } + } +} \ No newline at end of file
diff --git a/plugins/compose/compiler-hosted/runtime-tests/src/desktopTest/kotlin/androidx/compose/compiler/test/JvmCompositionTests.kt b/plugins/compose/compiler-hosted/runtime-tests/src/jvmTest/kotlin/androidx/compose/compiler/test/JvmCompositionTests.kt similarity index 100% rename from plugins/compose/compiler-hosted/runtime-tests/src/desktopTest/kotlin/androidx/compose/compiler/test/JvmCompositionTests.kt rename to plugins/compose/compiler-hosted/runtime-tests/src/jvmTest/kotlin/androidx/compose/compiler/test/JvmCompositionTests.kt
diff --git a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/ComposeDependencies.kt b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/ComposeDependencies.kt new file mode 100644 index 0000000..3313bd4 --- /dev/null +++ b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/ComposeDependencies.kt
@@ -0,0 +1,23 @@ +import org.gradle.api.Project +import org.gradle.api.artifacts.dsl.RepositoryHandler +import org.gradle.api.artifacts.repositories.MavenArtifactRepository +import java.net.URI + +/* + * Copyright 2010-2024 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. + */ + +private const val composeSnapshotId = "11751492" +private const val composeVersion = "1.7.0-SNAPSHOT" + +fun RepositoryHandler.androidxSnapshotRepo() { + maven { + url = URI("https://androidx.dev/snapshots/builds/$composeSnapshotId/artifacts/repository") + } +} + +fun Project.composeRuntime() = "androidx.compose.runtime:runtime:${composeVersion}" +fun Project.composeRuntimeTestUtils() = "androidx.compose.runtime:runtime-test-utils:${composeVersion}" +fun Project.composeUi() = "androidx.compose.ui:ui:${composeVersion}" +fun Project.composeFoundation() = "androidx.compose.foundation:foundation:${composeVersion}" \ No newline at end of file
diff --git a/settings.gradle b/settings.gradle index 0a294bb..5181c6f 100644 --- a/settings.gradle +++ b/settings.gradle
@@ -425,7 +425,8 @@ ":plugins:compose-compiler-plugin:compiler:integration-tests", ":plugins:compose-compiler-plugin:compiler-hosted", ":plugins:compose-compiler-plugin:compiler-hosted:integration-tests", - ":plugins:compose-compiler-plugin:compiler-hosted:integration-tests:protobuf-test-classes" + ":plugins:compose-compiler-plugin:compiler-hosted:integration-tests:protobuf-test-classes", + ":plugins:compose-compiler-plugin:compiler-hosted:runtime-tests" } // Swift Export modules @@ -874,6 +875,7 @@ project(':plugins:compose-compiler-plugin:compiler-hosted:integration-tests').projectDir = file("$rootDir/plugins/compose/compiler-hosted/integration-tests") project(':plugins:compose-compiler-plugin:compiler-hosted:integration-tests:protobuf-test-classes').projectDir = file("$rootDir/plugins/compose/compiler-hosted/integration-tests/protobuf-test-classes") + project(':plugins:compose-compiler-plugin:compiler-hosted:runtime-tests').projectDir = file("$rootDir/plugins/compose/compiler-hosted/runtime-tests") } project(':kotlin-scripting-ide-services-unshaded').projectDir = "$rootDir/plugins/scripting/scripting-ide-services" as File