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

feat: Kotlin 2.0.0 #811

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c18b1de
Update libs.versions.toml
SimonMarquis Nov 16, 2023
3846bed
💂 Update dependencies baseline
SimonMarquis Feb 15, 2024
3cc2d83
Update 2.0.0-Beta2
SimonMarquis Jan 2, 2024
c3a6cfe
Update 2.0.0-Beta3
SimonMarquis Jan 24, 2024
3bca9a3
🧪 Remove default values on Overridable Composable functions
SimonMarquis Jan 24, 2024
303e9de
🧪 Type inference cannot resolve nullable @Composable lambda
SimonMarquis Jan 25, 2024
fa6eba1
Update 2.0.0-Beta4
SimonMarquis Feb 15, 2024
4ba3db4
Revert "🧪 Type inference cannot resolve nullable @Composable lambda"
SimonMarquis Feb 15, 2024
75319a8
Revert "🧪 Remove default values on Overridable Composable functions"
SimonMarquis Feb 15, 2024
2a606ce
Remove unnecessary cast
SimonMarquis Feb 15, 2024
c01b31b
Merge branch 'main' into kotlin-2.0.0
SimonMarquis Feb 24, 2024
b5af3f3
Testing useKSP2 useK2Uast
SimonMarquis Feb 24, 2024
38463b0
Fix suppressed warning
SimonMarquis Feb 24, 2024
0aaa085
KSP 2.0.0-Beta4-1.0.19
SimonMarquis Mar 9, 2024
44e842f
Merge branch 'main' into kotlin-2.0.0
SimonMarquis Mar 9, 2024
5a87d57
Kotlin 2.0.0-Beta5 & Lint 8.5.0-alpha02
SimonMarquis Mar 23, 2024
3f174d2
Merge branch 'main' into kotlin-2.0.0
SimonMarquis Mar 23, 2024
5174ded
Update libs.versions.toml
SimonMarquis Mar 26, 2024
6f5720b
Merge branch 'main' into kotlin-2.0.0
SimonMarquis Apr 8, 2024
532a6ff
KSP `2.0.0-Beta5-1.0.20`
SimonMarquis Apr 8, 2024
1cfac9d
2.0.0-RC1
SimonMarquis Apr 16, 2024
09e7ca4
2.0.0-RC1
SimonMarquis Apr 16, 2024
34b63f3
Merge branch 'main' into kotlin-2.0.0
SimonMarquis Apr 16, 2024
345aabd
Suppress ComposeUnstableReceiver lint false positives
SimonMarquis Apr 16, 2024
1cb97b1
lint 8.5.0-alpha06
SimonMarquis Apr 27, 2024
856a7cd
Merge branch 'main' into kotlin-2.0.0
SimonMarquis Apr 27, 2024
0aada8a
Kotlin 2.0.0-RC1
SimonMarquis Apr 30, 2024
ab1cc76
dependencyGuardBaseline
SimonMarquis Apr 30, 2024
52eb9e1
Kotlin 2.0.0-RC3 and AGP 8.6.0-alpha01
SimonMarquis May 14, 2024
b18af7b
Merge branch 'main' into kotlin-2.0.0
SimonMarquis May 14, 2024
5eb537c
Update releaseRuntimeClasspath.txt
SimonMarquis May 14, 2024
04b1aaa
Merge remote-tracking branch 'origin/main' into kotlin-2.0.0
SimonMarquis May 22, 2024
4a137b8
Kotlin 2.0.0
SimonMarquis May 22, 2024
8457d7f
spotless
SimonMarquis May 22, 2024
853375e
Replace KotlinCompile tasks configuration with Kotlin extension
SimonMarquis May 22, 2024
7c131c0
Cleanup
SimonMarquis May 22, 2024
8139f0a
Merge branch 'main' into kotlin-2.0.0
kazaky May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/dependabot.yaml
Expand Up @@ -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:*"
Expand Down
12 changes: 6 additions & 6 deletions build-logic/build.gradle.kts
Expand Up @@ -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 {
Expand All @@ -31,12 +31,11 @@ java {
targetCompatibility = JavaVersion.VERSION_11
}

tasks.withType<KotlinCompile>().configureEach {
compilerOptions.allWarningsAsErrors = true
kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
}

kotlin {
compilerOptions {
allWarningsAsErrors = true
jvmTarget = JvmTarget.JVM_11
}
explicitApi()
}

Expand All @@ -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)
Expand Down
Expand Up @@ -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")
Expand Down Expand Up @@ -83,25 +83,24 @@ internal fun Project.getVersionsCatalog(): VersionCatalog = runCatching {
}.getOrThrow()

internal inline fun <reified T : KotlinTopLevelExtension> Project.configureKotlin(
allWarningsAsErrors: Boolean = true,
crossinline configure: T.() -> Unit = {},
) {
configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
configure<T> {
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<KotlinCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
// kotlinOptions.jvmTarget = JavaVersion.VERSION_11.toString()
this.allWarningsAsErrors.set(allWarningsAsErrors)
explicitApiMode.set(ExplicitApiMode.Strict)
}
}
}

internal fun <T> Project.getOrCreateExtra(
Expand Down
Expand Up @@ -30,13 +30,11 @@ internal class SparkAndroidComposePlugin : Plugin<Project> {
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 {
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Expand Up @@ -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")
Expand Down
Expand Up @@ -112,7 +112,7 @@ private fun rememberColorTokens(colors: SparkColors): List<List<KProperty1<Spark
*/
private fun KProperty1<SparkColors, Color>.asColorProperty(): KProperty1<SparkColors, Color> =
object : KProperty1<SparkColors, Color> 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
Expand Down
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down
9 changes: 0 additions & 9 deletions settings.gradle.kts
Expand Up @@ -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")
}
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions spark-icons/dependencies/releaseRuntimeClasspath.txt
Expand Up @@ -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
Expand Down
Expand Up @@ -68,7 +68,7 @@ internal class PreviewScreenshotTests {
}
}
}
if (failure != null) throw failure as Throwable
if (failure != null) throw failure
}
}

Expand Down
10 changes: 5 additions & 5 deletions spark/dependencies/releaseRuntimeClasspath.txt
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions spark/src/main/kotlin/com/adevinta/spark/tokens/Color.kt
Expand Up @@ -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
Expand Down Expand Up @@ -1220,37 +1221,43 @@ 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)

/**
* 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)

Expand All @@ -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)

Expand Down