Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.android.build.api.dsl.ApplicationExtension
import common.BuildTypes
import common.SdkVersions
import common.configureKotlinAndroid
import common.configureAndroidApplication
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
Expand All @@ -23,7 +23,6 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {

with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
apply("simprints.library.hilt")

apply("com.google.firebase.firebase-perf")
Expand All @@ -34,7 +33,7 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
}

extensions.configure<ApplicationExtension> {
configureKotlinAndroid(this)
configureAndroidApplication(this)

defaultConfig {
targetSdk = SdkVersions.TARGET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.android.build.api.dsl.LibraryExtension
import common.BuildTypes
import common.configureAndroidLibrary
import common.configureDebugModeBuildTypes
import common.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
Expand All @@ -13,13 +13,12 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")

apply("simprints.ci.jacoco")
}

extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
configureAndroidLibrary(this)

packaging {
// remove mockk duplicated files
Expand Down
60 changes: 36 additions & 24 deletions build-logic/convention/src/main/kotlin/common/KotlinAndroid.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
package common

import com.android.build.api.dsl.CommonExtension
import com.android.build.api.variant.AndroidComponentsExtension
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/**
* Configure base Kotlin with Android options
*/
internal fun Project.configureKotlinAndroid(commonExtension: CommonExtension<*, *, *, *, *, *>) {
commonExtension.apply {
internal fun Project.configureKotlinCompiler() {
tasks.withType(KotlinCompile::class.java).configureEach {
compilerOptions {
freeCompilerArgs.addAll(
"-Xnew-inference",
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
"-opt-in=kotlin.Experimental",
)
}
}
}

internal fun Project.configureAndroidApplication(extension: ApplicationExtension) {
extension.apply {
compileSdk = SdkVersions.TARGET

defaultConfig {
Expand All @@ -20,23 +31,24 @@ internal fun Project.configureKotlinAndroid(commonExtension: CommonExtension<*,
sourceCompatibility = SdkVersions.JAVA_TARGET
targetCompatibility = SdkVersions.JAVA_TARGET
}
}

configureKotlinCompiler()
}

internal fun Project.configureAndroidLibrary(extension: LibraryExtension) {
extension.apply {
compileSdk = SdkVersions.TARGET

extensions.getByType(AndroidComponentsExtension::class.java).onVariants { variant ->
afterEvaluate {
val variantName = variant.name.replaceFirstChar { it.uppercaseChar() }
val compileTaskName = "compile${variantName}Kotlin"

tasks.named(compileTaskName, KotlinCompilationTask::class.java) {
compilerOptions.freeCompilerArgs.addAll(
"-Xnew-inference",
"-opt-in=kotlin.RequiresOptIn",
// Enable experimental coroutines APIs, including Flow
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
"-opt-in=kotlin.Experimental",
)
}
}
defaultConfig {
minSdk = SdkVersions.MIN
}

compileOptions {
sourceCompatibility = SdkVersions.JAVA_TARGET
targetCompatibility = SdkVersions.JAVA_TARGET
}
}

configureKotlinCompiler()
}
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.test) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.ksp) apply false

Expand Down
13 changes: 6 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[versions]
kotlin_version = "2.2.21"
kotlin_version = "2.3.10"
kotlin_coroutine_version = "1.10.2"
ksp_version = "2.3.5"
kotlin_serialization_version = "1.9.0"
kotlin_serialization_version = "1.10.0"

android_gradlePlugin_version = "8.13.2"
android_gradlePlugin_version = "9.0.0"
androidx_version = "1.7.0"
androidx_core_version = "1.17.0"
androidx_app_compat_version = "1.7.1"
Expand All @@ -27,14 +27,14 @@ androidx_annotation_version = "1.9.1"
androidx_arch_core_version = "2.2.0"
material_version = "1.13.0"

hilt_version = "2.57.2"
hilt_version = "2.59.1"
hilt_androidx_version = "1.3.0"

play_base_services_version = "18.10.0"
play_location_services_version = "21.3.0"
play_integrity_version = "1.6.0"
gsm_plugin_version = "4.4.4"
play_publisher_version = "3.13.0"
play_publisher_version = "4.0.0"
play_barcode_version = "18.3.1"

ml_entity_extraction_version = "16.0.1"
Expand Down Expand Up @@ -81,7 +81,7 @@ uiAutomator_version = "2.3.0"
jacoco_version = "0.8.14"

sonar_plugin_version = "7.2.2.6593"
realm_version = "4.0.1"
realm_version = "4.0.2"
protobuf_plugin_version = "0.9.6"
deps_graph_version = "0.8.0"
tink_version = "1.20.0"
Expand Down Expand Up @@ -270,7 +270,6 @@ plugin-room = { group = "androidx.room", name = "room-gradle-plugin", version.re
android-application = { id = "com.android.application", version.ref = "android_gradlePlugin_version" }
android-library = { id = "com.android.library", version.ref = "android_gradlePlugin_version" }
android-test = { id = "com.android.test", version.ref = "android_gradlePlugin_version" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin_version" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin_version" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp_version" }
gms = { id = "com.google.gms.google-services", version.ref = "gsm_plugin_version" }
Expand Down
Loading