Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Kotlin and Compose #1720

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ bytebuddy = "1.15.10"
compose = "1.7.5"
coroutines = "1.9.0"
javaTarget = "11"
kotlin = "2.0.21"
ksp = "2.0.21-1.0.28"
kotlin = "2.1.0"
ksp = "2.1.0-1.0.29"
layoutlib = "15.0.6"
moshi = "1.15.1"

Expand Down Expand Up @@ -36,7 +36,7 @@ guava = { module = "com.google.guava:guava", version = "33.3.1-jre" }

kotlin-bom = { module = "org.jetbrains.kotlin:kotlin-bom", version.ref = "kotlin" }
kotlinpoet-ksp = { module = "com.squareup:kotlinpoet-ksp", version = "2.0.0" }
kotlin-compile-testing-ksp = { module = "com.github.tschuchortdev:kotlin-compile-testing-ksp", version = "1.6.0" }
kotlin-compile-testing-ksp = { module = "dev.zacsweers.kctfork:ksp", version = "0.7.0" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ended up moving to a fork from zacsweers since it is more regularly updated to newer kotlin versions.

The previous version was compiling against 1.9 which broke the 2.1 upgrade

kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ package app.cash.paparazzi.preview.processor
import com.google.common.truth.Truth.assertThat
import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.SourceFile
import com.tschuchort.compiletesting.configureKsp
import com.tschuchort.compiletesting.kspAllWarningsAsErrors
import com.tschuchort.compiletesting.kspArgs
import com.tschuchort.compiletesting.kspIncremental
import com.tschuchort.compiletesting.kspIncrementalLog
import com.tschuchort.compiletesting.kspLoggingLevels
import com.tschuchort.compiletesting.kspProcessorOptions
import com.tschuchort.compiletesting.kspSourcesDir
import com.tschuchort.compiletesting.kspWithCompilation
import com.tschuchort.compiletesting.symbolProcessorProviders
import com.tschuchort.compiletesting.useKsp2
import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -197,18 +204,20 @@ class PreviewProcessorProviderTest {
}

private fun prepareCompilation(vararg sourceFiles: SourceFile): KotlinCompilation =
KotlinCompilation()
.apply {
workingDir = File(temporaryFolder.root, "debug")
inheritClassPath = true
sources = sourceFiles.asList() + COMPOSE_SOURCES + PAPARAZZI_ANNOTATION_SOURCE
verbose = false

kspAllWarningsAsErrors = true
kspArgs["app.cash.paparazzi.preview.namespace"] = TEST_NAMESPACE
KotlinCompilation().apply {
workingDir = File(temporaryFolder.root, "debug")
inheritClassPath = true
sources = sourceFiles.asList() + COMPOSE_SOURCES + PAPARAZZI_ANNOTATION_SOURCE + PAPARAZZI_PREVIEW_DATA_SOURCE
verbose = true
kotlincArguments = listOf("-Xjvm-default=all")

configureKsp(useKsp2 = true) {
allWarningsAsErrors = true
kspProcessorOptions = mutableMapOf("app.cash.paparazzi.preview.namespace" to TEST_NAMESPACE)
kspIncremental = true
symbolProcessorProviders = listOf(PreviewProcessorProvider())
symbolProcessorProviders += PreviewProcessorProvider()
}
}

private companion object {
private const val TEST_NAMESPACE = "test"
Expand Down Expand Up @@ -289,5 +298,19 @@ class PreviewProcessorProviderTest {
annotation class Paparazzi
""".trimIndent()
)

private val PAPARAZZI_PREVIEW_DATA_SOURCE = SourceFile.kotlin(
"PaparazziPreviewData.kt",
"""
package app.cash.paparazzi.annotations

import androidx.compose.runtime.Composable

data class PaparazziPreviewData(
val snapshotName: String,
val composable: @Composable () -> Unit
)
""".trimIndent()
)
Comment on lines +302 to +314
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how codegen tests were passing when the generated code would fail to compile without this class.

Good news is now it works as expected 🎉

}
}
Loading