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

[feature/#306] Apply Kotlin 2.0 #309

Merged
merged 9 commits into from
May 30, 2024
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# Created by https://www.toptal.com/developers/gitignore/api/androidstudio,android
# Edit at https://www.toptal.com/developers/gitignore?templates=androidstudio,android

### Kotlin ###
# generated .kotlin
.kotlin/

### Android ###
# Built application files
*.apk
Expand Down
1 change: 1 addition & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies {
implementation(libs.android.gradlePlugin)
implementation(libs.kotlin.gradlePlugin)
implementation(libs.verify.detektPlugin)
compileOnly(libs.compose.compiler.gradle.plugin)
}

gradlePlugin {
Expand Down
21 changes: 12 additions & 9 deletions build-logic/src/main/kotlin/com/droidknights/app/ComposeAndroid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ package com.droidknights.app

import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension

internal fun Project.configureComposeAndroid() {
with(plugins) {
apply("org.jetbrains.kotlin.plugin.compose")
}

val libs = extensions.libs
androidExtension.apply {
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion =
libs.findVersion("androidxComposeCompiler").get().toString()
}

dependencies {
val bom = libs.findLibrary("androidx-compose-bom").get()
add("implementation", platform(bom))
add("androidTestImplementation", platform(bom))

add("implementation", libs.findLibrary("androidx.compose.material3").get())
add("implementation", libs.findLibrary("androidx.compose.ui").get())
add("implementation", libs.findLibrary("androidx.compose.ui.tooling.preview").get())
Expand All @@ -29,4 +27,9 @@ internal fun Project.configureComposeAndroid() {
add("debugImplementation", libs.findLibrary("androidx.compose.ui.testManifest").get())
}
}

extensions.getByType<ComposeCompilerGradlePluginExtension>().apply {
enableStrongSkippingMode.set(true)
Copy link
Member

Choose a reason for hiding this comment

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

1.7 부터 기본이었던것 같지만 아직 1.6이니

includeSourceInformation.set(true)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
@file:Suppress("UnstableApiUsage")

package com.droidknights.app

import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/**
Expand Down Expand Up @@ -52,14 +51,16 @@ internal fun Project.configureKotlinAndroid() {

internal fun Project.configureKotlin() {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
// Treat all Kotlin warnings as errors (disabled by default)
// Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
val warningsAsErrors: String? by project
allWarningsAsErrors = warningsAsErrors.toBoolean()
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn",
allWarningsAsErrors.set(warningsAsErrors.toBoolean())
freeCompilerArgs.set(
freeCompilerArgs.get() + listOf(
"-opt-in=kotlin.RequiresOptIn",
)
)
}
}
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins {
alias(libs.plugins.hilt) apply false
alias(libs.plugins.verify.detekt) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.compose.compiler) apply false
}

apply {
Expand Down
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ composeShimmer = "1.3.0"

## Kotlin Symbol Processing
# https://github.com/google/ksp/
ksp = "1.9.24-1.0.20"
ksp = "2.0.0-1.0.21"

## Hilt
# https://github.com/google/dagger/releases
Expand All @@ -55,9 +55,9 @@ retrofit = "2.11.0"

## Kotlin
# https://github.com/JetBrains/kotlin
kotlin = "1.9.24"
kotlin = "2.0.0"
# https://github.com/Kotlin/kotlinx.serialization
kotlinxSerializationJson = "1.6.3"
kotlinxSerializationJson = "1.7.0-RC"
# https://github.com/Kotlin/kotlinx-datetime/releases
kotlinxDatetime = "0.6.0"
# https://github.com/Kotlin/kotlinx.collections.immutable
Expand Down Expand Up @@ -110,6 +110,7 @@ androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "u
androidx-compose-ui-testManifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-compose-navigation = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxComposeNavigation" }
androidx-compose-navigation-test = { group = "androidx.navigation", name = "navigation-testing", version.ref = "androidxComposeNavigation" }
compose-compiler-gradle-plugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" }

hilt-core = { group = "com.google.dagger", name = "hilt-core", version.ref = "hilt" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }
Expand Down Expand Up @@ -174,3 +175,4 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
verify-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
Loading