diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 8f015e1..e3f1f5a 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -92,5 +92,4 @@ dependencies { implementation(libs.kotlinx.coroutines.core) implementation(libs.kotlinx.datetime) implementation(libs.coil) - implementation(libs.coil.compose) } diff --git a/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidApplicationPlugin.kt b/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidApplicationPlugin.kt index 3c011f5..1b64525 100644 --- a/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidApplicationPlugin.kt +++ b/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidApplicationPlugin.kt @@ -4,31 +4,16 @@ import com.android.build.api.dsl.ApplicationExtension import org.gradle.api.Plugin import org.gradle.api.Project -/** The `:app` module: SDK levels from the catalog, Java 17 bytecode, shared lint rules. */ +/** The `:app` module: [configureAndroidModule] plus the target SDK from the catalog. */ class AndroidApplicationPlugin : Plugin { override fun apply(target: Project) { with(target) { pluginManager.apply("com.android.application") pluginManager.apply("kvitt.architecture") - val catalog = libs extensions.configure(ApplicationExtension::class.java) { - compileSdk = catalog.version("compileSdk").toInt() - defaultConfig { - minSdk = catalog.version("minSdk").toInt() - targetSdk = catalog.version("targetSdk").toInt() - } - compileOptions { - sourceCompatibility = org.gradle.api.JavaVersion.VERSION_17 - targetCompatibility = org.gradle.api.JavaVersion.VERSION_17 - } - testOptions { - unitTests.isIncludeAndroidResources = true - } - lint { kvittLint(this) } + configureAndroidModule(this) + defaultConfig.targetSdk = libs.version("targetSdk").toInt() } - configureKotlinAndroid() - configureRobolectricJvm() - dependencies.add("testImplementation", catalog.library("junit")) } } } diff --git a/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidCommon.kt b/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidCommon.kt index 970a944..485c9d4 100644 --- a/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidCommon.kt +++ b/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidCommon.kt @@ -1,11 +1,30 @@ package se.hagstedt.kvitt.buildlogic +import com.android.build.api.dsl.CommonExtension import com.android.build.api.dsl.Lint +import org.gradle.api.JavaVersion import org.gradle.api.Project import org.gradle.api.tasks.testing.Test import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +/** + * What every Android module shares (application and library): SDK levels from the catalog, Java 17 bytecode, Android + * resources in unit tests (Robolectric), the shared lint rules and JUnit. + */ +internal fun Project.configureAndroidModule(android: CommonExtension) { + val catalog = libs + android.compileSdk = catalog.version("compileSdk").toInt() + android.defaultConfig.minSdk = catalog.version("minSdk").toInt() + android.compileOptions.sourceCompatibility = JavaVersion.VERSION_17 + android.compileOptions.targetCompatibility = JavaVersion.VERSION_17 + android.testOptions.unitTests.isIncludeAndroidResources = true + kvittLint(android.lint) + configureKotlinAndroid() + configureRobolectricJvm() + dependencies.add("testImplementation", catalog.library("junit")) +} + /** * Lint rules shared by every Android module. A string key missing from `values-sv` (or present only there) fails the * build (SPEC AC-19.1). No baseline file: findings are fixed, never silenced (CLAUDE.md › Anti-patterns). diff --git a/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidLibraryPlugin.kt b/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidLibraryPlugin.kt index bc94fef..cf9376d 100644 --- a/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidLibraryPlugin.kt +++ b/android/build-logic/src/main/kotlin/se/hagstedt/kvitt/buildlogic/AndroidLibraryPlugin.kt @@ -4,32 +4,17 @@ import com.android.build.api.dsl.LibraryExtension import org.gradle.api.Plugin import org.gradle.api.Project -/** Android library module: SDK levels from the catalog, Java 17 bytecode, shared lint rules. */ +/** Android library module: [configureAndroidModule] with the namespace derived from the module path. */ class AndroidLibraryPlugin : Plugin { override fun apply(target: Project) { with(target) { pluginManager.apply("com.android.library") pluginManager.apply("kvitt.architecture") - val catalog = libs extensions.configure(LibraryExtension::class.java) { namespace = kvittNamespace() - compileSdk = catalog.version("compileSdk").toInt() - defaultConfig { - minSdk = catalog.version("minSdk").toInt() - } - compileOptions { - sourceCompatibility = org.gradle.api.JavaVersion.VERSION_17 - targetCompatibility = org.gradle.api.JavaVersion.VERSION_17 - } - testOptions { - unitTests.isIncludeAndroidResources = true - } - lint { kvittLint(this) } + configureAndroidModule(this) } - configureKotlinAndroid() - configureRobolectricJvm() failOnNoTestsOnlyWhenTestsExist() - dependencies.add("testImplementation", catalog.library("junit")) } } }