diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index 2848fe20a..0a13302c7 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -15,12 +15,11 @@ updates: registries: "*" labels: [ ] groups: - kotlin-ksp-compose: + kotlin-ksp: patterns: - "org.jetbrains.kotlin:*" - "org.jetbrains.kotlin.jvm" - "com.google.devtools.ksp" - - "androidx.compose.compiler:compiler" android-build-tools: patterns: - "com.android.tools.build:*" diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index e608510bb..0f566fe43 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -19,7 +19,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import kotlin.reflect.KProperty plugins { @@ -31,12 +31,11 @@ java { targetCompatibility = JavaVersion.VERSION_11 } -tasks.withType().configureEach { - compilerOptions.allWarningsAsErrors = true - kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString() -} - kotlin { + compilerOptions { + allWarningsAsErrors = true + jvmTarget = JvmTarget.JVM_11 + } explicitApi() } @@ -50,6 +49,7 @@ dependencies { compileOnly(libs.gradlePlugins.android) compileOnly(libs.gradlePlugins.kotlin) compileOnly(libs.gradlePlugins.ksp) + compileOnly(libs.gradlePlugins.compose) compileOnly(libs.gradlePlugins.dependencyGuard) compileOnly(libs.gradlePlugins.dokka) compileOnly(libs.gradlePlugins.spotless) diff --git a/build-logic/src/main/kotlin/com/adevinta/spark/ProjectExtensions.kt b/build-logic/src/main/kotlin/com/adevinta/spark/ProjectExtensions.kt index 32982afd3..6e3a772cf 100644 --- a/build-logic/src/main/kotlin/com/adevinta/spark/ProjectExtensions.kt +++ b/build-logic/src/main/kotlin/com/adevinta/spark/ProjectExtensions.kt @@ -30,14 +30,14 @@ import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalog import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.kotlin.dsl.assign import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.getByType -import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.dsl.ExplicitApiMode import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile internal val Project.isAndroidApplication: Boolean get() = pluginManager.hasPlugin("com.android.application") internal val Project.isAndroidLibrary: Boolean get() = pluginManager.hasPlugin("com.android.library") @@ -83,7 +83,6 @@ internal fun Project.getVersionsCatalog(): VersionCatalog = runCatching { }.getOrThrow() internal inline fun Project.configureKotlin( - allWarningsAsErrors: Boolean = true, crossinline configure: T.() -> Unit = {}, ) { configure { @@ -91,17 +90,17 @@ internal inline fun Project.configureKotli targetCompatibility = JavaVersion.VERSION_11 } configure { + when (this) { + is KotlinAndroidProjectExtension -> compilerOptions + is KotlinJvmProjectExtension -> compilerOptions + else -> TODO("Unsupported project extension $this ${T::class}") + }.apply { + jvmTarget = JvmTarget.JVM_11 + allWarningsAsErrors = true + } explicitApi() configure() } - tasks.withType().configureEach { - compilerOptions { - jvmTarget.set(JvmTarget.JVM_11) - // kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString() - this.allWarningsAsErrors.set(allWarningsAsErrors) - explicitApiMode.set(ExplicitApiMode.Strict) - } - } } internal fun Project.getOrCreateExtra( diff --git a/build-logic/src/main/kotlin/com/adevinta/spark/SparkAndroidComposePlugin.kt b/build-logic/src/main/kotlin/com/adevinta/spark/SparkAndroidComposePlugin.kt index 142fd9343..3e732a107 100644 --- a/build-logic/src/main/kotlin/com/adevinta/spark/SparkAndroidComposePlugin.kt +++ b/build-logic/src/main/kotlin/com/adevinta/spark/SparkAndroidComposePlugin.kt @@ -30,13 +30,11 @@ internal class SparkAndroidComposePlugin : Plugin { override fun apply(target: Project) { with(target) { apply(plugin = "org.jetbrains.kotlin.android") + apply(plugin = "org.jetbrains.kotlin.plugin.compose") apply(plugin = "com.adevinta.spark.android") android { buildFeatures.compose = true - composeOptions { - kotlinCompilerExtensionVersion = spark().versions.`androidx-compose-compiler`.toString() - } } dependencies { diff --git a/build.gradle.kts b/build.gradle.kts index 22946ee4b..c25ea97d0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,6 +30,7 @@ plugins { alias(libs.plugins.dokka) apply false alias(libs.plugins.dependencyGuard) apply false alias(libs.plugins.spotless) apply false + alias(libs.plugins.compose) apply false id("com.adevinta.spark.root") id("com.adevinta.spark.dokka") diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/examples/samples/tokens/colors/ColorSample.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/examples/samples/tokens/colors/ColorSample.kt index 51bf9f7d6..09e1ca84f 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/examples/samples/tokens/colors/ColorSample.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/examples/samples/tokens/colors/ColorSample.kt @@ -112,7 +112,7 @@ private fun rememberColorTokens(colors: SparkColors): List.asColorProperty(): KProperty1 = object : KProperty1 by this { - @Suppress("KotlinConstantConditions") + @Suppress("USELESS_IS_CHECK") override fun get(receiver: SparkColors): Color = when (val any: Any = this@asColorProperty.get(receiver)) { is Color -> any // in debug builds is Long -> Color(any.toULong()) // in release builds diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4075b5774..a9a78b193 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,6 @@ android-gradlePlugin = "8.4.1" androidx-activity = "1.9.0" androidx-appCompat = "1.6.1" androidx-compose-bom = "2024.05.00" -androidx-compose-compiler = "1.5.14" androidx-lifecycle = "2.7.0" androidx-navigation = "2.7.7" androidx-savedstate = "1.2.1" @@ -16,11 +15,11 @@ datastore = "1.1.1" dependencyGuard = "0.5.0" dokka = "1.9.20" junit = "4.13.2" -kotlin = "1.9.24" +kotlin = "2.0.0" kotlinx-coroutines = "1.8.1" kotlinx-collections-immutable = "0.3.7" kotlinx-serialization-json = "1.6.3" -ksp = "1.9.24-1.0.20" +ksp = "2.0.0-1.0.21" ktlint = "1.2.1" lint = "31.4.1" minCompileSdk = "24" @@ -49,7 +48,6 @@ androidx-activity-compose = { module = "androidx.activity:activity-compose", ver androidx-appCompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appCompat" } androidx-appCompat-resources = { module = "androidx.appcompat:appcompat-resources", version.ref = "androidx-appCompat" } androidx-compose-bom = { module = "androidx.compose:compose-bom", version.ref = "androidx-compose-bom" } -androidx-compose-compiler = { group = "androidx.compose.compiler", name = "compiler", version.ref = "androidx-compose-compiler" } androidx-compose-foundation = { module = "androidx.compose.foundation:foundation" } androidx-compose-foundation-layout = { module = "androidx.compose.foundation:foundation-layout" } androidx-compose-material-iconsExtended = { module = "androidx.compose.material:material-icons-extended" } @@ -88,6 +86,7 @@ dokka-android-documentation-plugin = { module = "org.jetbrains.dokka:android-doc dokka-base = { module = "org.jetbrains.dokka:dokka-base", version.ref = "dokka" } gradlePlugins-android = { module = "com.android.tools.build:gradle", version.ref = "android-gradlePlugin" } +gradlePlugins-compose = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" } gradlePlugins-dependencyGuard = { module = "com.dropbox.dependency-guard:com.dropbox.dependency-guard.gradle.plugin", version.ref = "dependencyGuard" } gradlePlugins-dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" } gradlePlugins-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } @@ -126,6 +125,7 @@ android-kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } android-library = { id = "com.android.library", version.ref = "android-gradlePlugin" } android-lint = { id = "com.android.lint", version.ref = "android-gradlePlugin" } android-test = { id = "com.android.test", version.ref = "android-gradlePlugin" } +compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" } dependencyGuard = { id = "com.dropbox.dependency-guard", version.ref = "dependencyGuard" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } diff --git a/settings.gradle.kts b/settings.gradle.kts index d1cd8c643..5f1db1d7b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -33,15 +33,6 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - - // Pre-release artifacts of compose-compiler - // https://androidx.dev/storage/compose-compiler/repository - maven("https://androidx.dev/storage/compose-compiler/repository/") { - name = "compose-compiler-dev" - content { - includeGroup("androidx.compose.compiler") - } - } } } diff --git a/spark-icons/dependencies/releaseRuntimeClasspath.txt b/spark-icons/dependencies/releaseRuntimeClasspath.txt index af999729f..0e6df24a3 100644 --- a/spark-icons/dependencies/releaseRuntimeClasspath.txt +++ b/spark-icons/dependencies/releaseRuntimeClasspath.txt @@ -50,11 +50,11 @@ androidx.vectordrawable:vectordrawable-animated:1.1.0 androidx.vectordrawable:vectordrawable:1.1.0 androidx.versionedparcelable:versionedparcelable:1.1.1 com.google.guava:listenablefuture:1.0 -org.jetbrains.kotlin:kotlin-bom:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib-common:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib:1.9.24 +org.jetbrains.kotlin:kotlin-bom:2.0.0 +org.jetbrains.kotlin:kotlin-stdlib-common:2.0.0 +org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0 +org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0 +org.jetbrains.kotlin:kotlin-stdlib:2.0.0 org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1 org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.7.1 org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.1 diff --git a/spark-screenshot-testing/src/test/kotlin/com/adevinta/spark/PreviewScreenshotTests.kt b/spark-screenshot-testing/src/test/kotlin/com/adevinta/spark/PreviewScreenshotTests.kt index 2ffac23e0..4dc4c2de6 100644 --- a/spark-screenshot-testing/src/test/kotlin/com/adevinta/spark/PreviewScreenshotTests.kt +++ b/spark-screenshot-testing/src/test/kotlin/com/adevinta/spark/PreviewScreenshotTests.kt @@ -68,7 +68,7 @@ internal class PreviewScreenshotTests { } } } - if (failure != null) throw failure as Throwable + if (failure != null) throw failure } } diff --git a/spark/dependencies/releaseRuntimeClasspath.txt b/spark/dependencies/releaseRuntimeClasspath.txt index 38ccc5af3..877d7f7aa 100644 --- a/spark/dependencies/releaseRuntimeClasspath.txt +++ b/spark/dependencies/releaseRuntimeClasspath.txt @@ -82,11 +82,11 @@ io.coil-kt:coil-base:2.6.0 io.coil-kt:coil-compose-base:2.6.0 io.coil-kt:coil-compose:2.6.0 io.coil-kt:coil:2.6.0 -org.jetbrains.kotlin:kotlin-bom:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib-common:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.24 -org.jetbrains.kotlin:kotlin-stdlib:1.9.24 +org.jetbrains.kotlin:kotlin-bom:2.0.0 +org.jetbrains.kotlin:kotlin-stdlib-common:2.0.0 +org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.0.0 +org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.0 +org.jetbrains.kotlin:kotlin-stdlib:2.0.0 org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:0.3.7 org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.7 org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3 diff --git a/spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt b/spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt index afac33e41..ea2d976ff 100644 --- a/spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt +++ b/spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt @@ -23,6 +23,7 @@ package com.adevinta.spark.tokens +import android.annotation.SuppressLint import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -1220,30 +1221,35 @@ public fun contentColorFor(backgroundColor: Color): Color { /** * Extension property to get a [Color] with dim1(a medium emphasis to text) applied */ +@get:SuppressLint("ComposeUnstableReceiver") // https://github.com/slackhq/compose-lints/issues/326 public val Color.dim1: Color @Composable get() = this.copy(alpha = SparkTheme.colors.dim1) /** * Extension property to get a [Color] with dim2(a medium emphasis to icons) applied */ +@get:SuppressLint("ComposeUnstableReceiver") // https://github.com/slackhq/compose-lints/issues/326 public val Color.dim2: Color @Composable get() = this.copy(alpha = SparkTheme.colors.dim2) /** * Extension property to get a [Color] with dim3(disabled emphasis to all components) applied */ +@get:SuppressLint("ComposeUnstableReceiver") // https://github.com/slackhq/compose-lints/issues/326 public val Color.dim3: Color @Composable get() = this.copy(alpha = SparkTheme.colors.dim3) /** * Extension property to get a [Color] with dim4(low element) applied */ +@get:SuppressLint("ComposeUnstableReceiver") // https://github.com/slackhq/compose-lints/issues/326 public val Color.dim4: Color @Composable get() = this.copy(alpha = SparkTheme.colors.dim4) /** * Extension property to get a [Color] with dim5(pressed/ripple visual but should not be used on Android) applied */ +@get:SuppressLint("ComposeUnstableReceiver") // https://github.com/slackhq/compose-lints/issues/326 public val Color.dim5: Color @Composable get() = this.copy(alpha = SparkTheme.colors.dim5) @@ -1251,6 +1257,7 @@ public val Color.dim5: Color * Extension property to get a [Color] with dim3(disabled element) applied composite over SparkTheme.colors.surface * to prevent the color being transparent */ +@get:SuppressLint("ComposeUnstableReceiver") // https://github.com/slackhq/compose-lints/issues/326 public val Color.disabled: Color @Composable get() = this.dim3.compositeOver(SparkTheme.colors.surface) @@ -1259,6 +1266,7 @@ public val Color.disabled: Color * This is useful when you want to animate fro ma transparent color to a colored one * since using [Color.Transparent] will start with a black background. */ +@get:SuppressLint("ComposeUnstableReceiver") // https://github.com/slackhq/compose-lints/issues/326 public val Color.transparent: Color @Composable get() = this.copy(alpha = 0f)