Skip to content

Commit

Permalink
Bump kotlin from 1.9.23 to 2.0.0 (#549)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gaëtan Muller <[email protected]>
  • Loading branch information
dependabot[bot] and MGaetan89 authored May 21, 2024
1 parent 1b809a2 commit 48614cb
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import ch.srgssr.pillarbox.gradle.internal.AppConfig
import ch.srgssr.pillarbox.gradle.internal.VersionConfig
import ch.srgssr.pillarbox.gradle.internal.configureAndroidLintModule
import ch.srgssr.pillarbox.gradle.internal.configureAndroidModule
import ch.srgssr.pillarbox.gradle.internal.configureComposeModule
import ch.srgssr.pillarbox.gradle.internal.configureKotlinModule
import com.android.build.api.dsl.ApplicationExtension
import org.gradle.api.Plugin
Expand All @@ -23,11 +22,15 @@ class PillarboxAndroidApplicationPlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
pluginManager.apply("com.android.application")
pluginManager.apply("org.jetbrains.kotlin.android")
pluginManager.apply("org.jetbrains.kotlin.plugin.compose")

extensions.configure<ApplicationExtension> {
configureAndroidLintModule(this)
configureAndroidModule(this)
configureComposeModule(this)

buildFeatures {
compose = true
}

defaultConfig {
applicationId = namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package ch.srgssr.pillarbox.gradle

import ch.srgssr.pillarbox.gradle.internal.configureComposeModule
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -16,9 +15,12 @@ import org.gradle.kotlin.dsl.configure
class PillarboxAndroidLibraryComposePlugin : Plugin<Project> {
override fun apply(target: Project) = with(target) {
pluginManager.apply("com.android.library")
pluginManager.apply("org.jetbrains.kotlin.plugin.compose")

extensions.configure<LibraryExtension> {
configureComposeModule(this)
buildFeatures {
compose = true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
package ch.srgssr.pillarbox.gradle.internal

import org.gradle.api.JavaVersion
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

internal object AppConfig {
// When changing this value, don't forget to also update the Detekt config in the root `build.gradle.kts` file
private val javaVersionName = "17"

internal const val minSdk = 21
internal const val targetSdk = 34
internal const val compileSdk = 34
internal const val androidXComposeCompiler = "1.5.13"

// When changing this value, don't forget to also update the Detekt config in the root `build.gradle.kts` file
internal val javaVersion = JavaVersion.VERSION_17
internal val javaVersion = JavaVersion.valueOf("VERSION_$javaVersionName")
internal val jvmTarget = JvmTarget.fromTarget(javaVersionName)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
package ch.srgssr.pillarbox.gradle.internal

import com.android.build.api.dsl.CommonExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

internal fun Project.configureAndroidModule(extension: CommonExtension<*, *, *, *, *, *>) = with(extension) {
Expand Down Expand Up @@ -35,20 +37,10 @@ internal fun Project.configureAndroidModule(extension: CommonExtension<*, *, *,
}
}

internal fun configureComposeModule(extension: CommonExtension<*, *, *, *, *, *>) = with(extension) {
buildFeatures {
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = AppConfig.androidXComposeCompiler
}
}

internal fun Project.configureKotlinModule() {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = AppConfig.javaVersion.majorVersion
compilerOptions {
jvmTarget.set(AppConfig.jvmTarget)
}
}
}
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose.compiler) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.detekt)
alias(libs.plugins.dependency.analysis.gradle.plugin)
Expand Down
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dokka = "1.9.20"
guava = "32.1.3-android"
json = "20240303"
junit = "4.13.2"
kotlin = "1.9.23"
kotlin = "2.0.0"
kotlinx-coroutines = "1.8.1"
kotlinx-kover = "0.8.0"
kotlinx-serialization = "1.6.3"
Expand Down Expand Up @@ -142,6 +142,7 @@ dependency-analysis-gradle-plugin = { id = "com.autonomousapps.dependency-analys
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlinx-kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kotlinx-kover" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ fun PillarboxTheme(
}

MaterialTheme(colorScheme = colorScheme) {
CompositionLocalProvider(LocalPaddings provides paddings) {
CompositionLocalProvider(
LocalPaddings provides paddings,
// TODO Remove this when Compose 1.7 is stable (see https://issuetracker.google.com/issues/336842920)
androidx.lifecycle.compose.LocalLifecycleOwner provides androidx.compose.ui.platform.LocalLifecycleOwner.current,
) {
content()
}
}
Expand Down

0 comments on commit 48614cb

Please sign in to comment.