Android overhaul: one configureAndroidModule for the application and library plugins; coil-compose out of :app
AndroidApplicationPlugin and AndroidLibraryPlugin repeated the SDK levels, Java 17, unit-test resources, lint, Kotlin, Robolectric JVM and JUnit set-up; both call configureAndroidModule(CommonExtension) now (the gate's task inputs did not change: every test task stayed up to date). :app imports nothing from coil-compose; it still arrives through :core:design, so the runtime classpaths are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TQd3pEP9UeN2uifbHknQ7B
This commit is contained in:
@@ -92,5 +92,4 @@ dependencies {
|
|||||||
implementation(libs.kotlinx.coroutines.core)
|
implementation(libs.kotlinx.coroutines.core)
|
||||||
implementation(libs.kotlinx.datetime)
|
implementation(libs.kotlinx.datetime)
|
||||||
implementation(libs.coil)
|
implementation(libs.coil)
|
||||||
implementation(libs.coil.compose)
|
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-18
@@ -4,31 +4,16 @@ import com.android.build.api.dsl.ApplicationExtension
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
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<Project> {
|
class AndroidApplicationPlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
with(target) {
|
with(target) {
|
||||||
pluginManager.apply("com.android.application")
|
pluginManager.apply("com.android.application")
|
||||||
pluginManager.apply("kvitt.architecture")
|
pluginManager.apply("kvitt.architecture")
|
||||||
val catalog = libs
|
|
||||||
extensions.configure(ApplicationExtension::class.java) {
|
extensions.configure(ApplicationExtension::class.java) {
|
||||||
compileSdk = catalog.version("compileSdk").toInt()
|
configureAndroidModule(this)
|
||||||
defaultConfig {
|
defaultConfig.targetSdk = libs.version("targetSdk").toInt()
|
||||||
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) }
|
|
||||||
}
|
}
|
||||||
configureKotlinAndroid()
|
|
||||||
configureRobolectricJvm()
|
|
||||||
dependencies.add("testImplementation", catalog.library("junit"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,30 @@
|
|||||||
package se.hagstedt.kvitt.buildlogic
|
package se.hagstedt.kvitt.buildlogic
|
||||||
|
|
||||||
|
import com.android.build.api.dsl.CommonExtension
|
||||||
import com.android.build.api.dsl.Lint
|
import com.android.build.api.dsl.Lint
|
||||||
|
import org.gradle.api.JavaVersion
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.tasks.testing.Test
|
import org.gradle.api.tasks.testing.Test
|
||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
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
|
* 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).
|
* build (SPEC AC-19.1). No baseline file: findings are fixed, never silenced (CLAUDE.md › Anti-patterns).
|
||||||
|
|||||||
+2
-17
@@ -4,32 +4,17 @@ import com.android.build.api.dsl.LibraryExtension
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
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<Project> {
|
class AndroidLibraryPlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) {
|
override fun apply(target: Project) {
|
||||||
with(target) {
|
with(target) {
|
||||||
pluginManager.apply("com.android.library")
|
pluginManager.apply("com.android.library")
|
||||||
pluginManager.apply("kvitt.architecture")
|
pluginManager.apply("kvitt.architecture")
|
||||||
val catalog = libs
|
|
||||||
extensions.configure(LibraryExtension::class.java) {
|
extensions.configure(LibraryExtension::class.java) {
|
||||||
namespace = kvittNamespace()
|
namespace = kvittNamespace()
|
||||||
compileSdk = catalog.version("compileSdk").toInt()
|
configureAndroidModule(this)
|
||||||
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) }
|
|
||||||
}
|
}
|
||||||
configureKotlinAndroid()
|
|
||||||
configureRobolectricJvm()
|
|
||||||
failOnNoTestsOnlyWhenTestsExist()
|
failOnNoTestsOnlyWhenTestsExist()
|
||||||
dependencies.add("testImplementation", catalog.library("junit"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user