Skip to content

Commit 4985418

Browse files
rework compose compiler tests for k2 (#5325)
migrate compose compiler tests to work with k2 ## Testing N/A ## Release Notes N/A
1 parent da82a7f commit 4985418

File tree

37 files changed

+261
-533
lines changed

37 files changed

+261
-533
lines changed

compose/integrations/composable-test-cases/README.MD

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
## Run:
22

3-
`./gradlew build -Pcompose.kotlinCompilerPluginVersion=1.4.2-rc03 -Pkotlin.version=1.8.10`
3+
`./gradlew build -Pkotlin_version=2.1.21`
44
to build and run the tests,
55

66
or
7-
`./gradlew allTests -Pcompose.kotlinCompilerPluginVersion=1.4.2-rc03 -Pkotlin.version=1.8.10`
7+
`./gradlew allTests -Pkotlin_version=2.1.21`
88
to only run the tests.
99

1010
It will build and run the tests for all available targets (depends on a host machine).
11-
See [TargetsConfiguration](./buildSrc/src/main/kotlin/TargetsConfiguration.kt) to update the targets.
12-
1311

1412
## Test cases
1513

Lines changed: 65 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,87 @@
1-
import internal.InternalComposeSupportPlugin
2-
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
1+
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
32
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
3+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
44

5-
group "com.example"
6-
version "1.0-SNAPSHOT"
5+
//group "com.example"
6+
//version "1.0-SNAPSHOT"
7+
8+
fun Project.disableYarnLockMismatchReport() {
9+
plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
10+
the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().apply {
11+
yarnLockMismatchReport = org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport.NONE
12+
}
13+
}
14+
}
715

816
allprojects {
917
repositories {
1018
google()
1119
mavenCentral()
1220
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
1321
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev/") // to test with kotlin dev builds
14-
// mavenLocal()
22+
23+
maven("https://packages.jetbrains.team/maven/p/kt/dev")
24+
maven("https://redirector.kotlinlang.org/maven/dev")
25+
// mavenLocal()
1526
}
1627

17-
// Apply here for all subprojects instead of applying in each build.gradle.kts separately.
18-
// It applies the compiler plugin
19-
this.apply<InternalComposeSupportPlugin>()
28+
disableYarnLockMismatchReport()
29+
}
2030

21-
afterEvaluate {
22-
val pluginOptionPrefix = "plugin:androidx.compose.compiler.plugins.kotlin:"
23-
val project = this
24-
val kotlinVersion = project.properties["kotlin.version"] as? String
31+
plugins {
32+
kotlin("multiplatform").version(libs.versions.kotlin).apply(false)
33+
alias(libs.plugins.compose.compiler).apply(false)
34+
}
2535

26-
project.tasks.withType(KotlinCompile::class.java).configureEach {
27-
kotlinOptions.apply {
28-
freeCompilerArgs +=
29-
listOf(
30-
"-P",
31-
"${pluginOptionPrefix}suppressKotlinVersionCompatibilityCheck=$kotlinVersion"
32-
)
36+
subprojects {
37+
apply(plugin = "org.jetbrains.kotlin.multiplatform")
3338

34-
}
39+
configure<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension> {
40+
jvm("desktop")
41+
applyDefaultHierarchyTemplate()
42+
js(IR) {
43+
// browser()
44+
nodejs() // Commented to save a bit of CI time. Testing in a browser should be enough.
3545
}
36-
37-
tasks.withType<KotlinJsCompile>().configureEach {
38-
kotlinOptions.freeCompilerArgs += listOf(
39-
"-Xklib-enable-signature-clash-checks=false",
40-
)
46+
@OptIn(ExperimentalWasmDsl::class)
47+
wasmJs {
48+
d8 {}
4149
}
4250

43-
tasks.withType<KotlinCompile<*>>().configureEach {
44-
kotlinOptions.freeCompilerArgs += "-Xpartial-linkage=disable"
45-
}
46-
}
47-
disableYarnLockMismatchReport()
48-
}
51+
iosArm64()
52+
iosSimulatorArm64()
53+
iosX64()
54+
macosX64()
55+
macosArm64()
56+
// We use linux agents on CI. So it doesn't run the tests, but it builds the klib anyway which is time consuming.
57+
// if (project.isMingwX64Enabled) mingwX64()
58+
linuxX64()
4959

50-
plugins {
51-
kotlin("multiplatform") apply false
52-
}
60+
sourceSets {
61+
val commonMain by getting {
62+
val projectName = project.name
63+
dependencies {
64+
if (projectName != "common") {
65+
implementation(project(":common"))
66+
}
5367

54-
fun Project.disableYarnLockMismatchReport() {
55-
plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> {
56-
the<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension>().apply {
57-
yarnLockMismatchReport = org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport.NONE
68+
if (projectName.endsWith("-main")) {
69+
implementation(project(":" + projectName.replace("-main", "-lib")))
70+
}
71+
}
72+
}
5873
}
74+
75+
targets
76+
.filter { it.name != "desktop" } // Exclude JVM target
77+
.forEach { target ->
78+
target.compilations.all {
79+
compileTaskProvider.configure{
80+
compilerOptions {
81+
freeCompilerArgs.add("-Xpartial-linkage=disable")
82+
}
83+
}
84+
}
85+
}
5986
}
6087
}

compose/integrations/composable-test-cases/buildSrc/build.gradle.kts

Lines changed: 0 additions & 29 deletions
This file was deleted.

compose/integrations/composable-test-cases/buildSrc/gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

compose/integrations/composable-test-cases/buildSrc/settings.gradle.kts

Lines changed: 0 additions & 16 deletions
This file was deleted.

compose/integrations/composable-test-cases/buildSrc/src/main/kotlin/TargetsConfiguration.kt

Lines changed: 0 additions & 66 deletions
This file was deleted.

compose/integrations/composable-test-cases/buildSrc/src/main/kotlin/internal/ComposeCompilerArtifactProvider.kt

Lines changed: 0 additions & 70 deletions
This file was deleted.

compose/integrations/composable-test-cases/buildSrc/src/main/kotlin/internal/InternalComposeSupportPlugin.kt

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)