Android overhaul: one CopyCategoryKeywords task in build-logic instead of a copy in :data and :core:fakes

The task class and its wiring were duplicated verbatim in both build scripts; bundleCategoryKeywords(resourcePath)
registers it once per module. Resource paths and inputs 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:
2026-10-18 22:53:44 +02:00
parent 48fe119ae1
commit e4e6e5d792
11 changed files with 76 additions and 368 deletions
+6 -37
View File
@@ -1,6 +1,8 @@
import se.hagstedt.kvitt.buildlogic.bundleCategoryKeywords
// :core:fakes — scenario-driven fakes of every repository interface of SPEC §14.2.4. Only for tests, screenshot tests
// and debug previews (the architecture check rejects it in release configurations). Computed values come from :domain.
// M7x add their scenarios under src/main/kotlin/se/hagstedt/kvitt/fakes/<feature>/ and nowhere else (SPEC §11.3).
// Each feature's scenarios live under src/main/kotlin/se/hagstedt/kvitt/fakes/<feature>/ (SPEC §11.3).
plugins {
id("kvitt.android.library")
}
@@ -11,39 +13,6 @@ dependencies {
testImplementation(libs.kotlinx.coroutines.test)
}
// The keyword table of the category suggestion (UX-3, SPEC §9.11 CS-6) is bundled as the Java resource
// se/hagstedt/kvitt/fakes/category-keywords.csv, copied from contracts/category-keywords.csv at build time (never
// hand-copied). A missing table fails the build: the task's input file must exist.
abstract class CopyCategoryKeywords : DefaultTask() {
@get:InputFile
@get:PathSensitive(PathSensitivity.NONE)
abstract val table: RegularFileProperty
@get:Input
abstract val resourcePath: Property<String>
@get:OutputDirectory
abstract val outputDir: DirectoryProperty
@TaskAction
fun copy() {
val source = table.get().asFile
if (!source.isFile) throw GradleException("missing ${source.path}")
val root = outputDir.get().asFile
root.deleteRecursively()
val target = root.resolve(resourcePath.get())
target.parentFile.mkdirs()
source.copyTo(target)
}
}
val categoryKeywordsTable = rootProject.layout.projectDirectory.file("../contracts/category-keywords.csv")
val copyCategoryKeywords = tasks.register<CopyCategoryKeywords>("copyCategoryKeywords") {
description = "Copies contracts/category-keywords.csv into the main Java resources."
table.set(categoryKeywordsTable)
resourcePath.set("se/hagstedt/kvitt/fakes/category-keywords.csv")
outputDir.set(layout.buildDirectory.dir("generated/category-keywords"))
}
androidComponents {
onVariants { variant -> variant.sources.resources?.addGeneratedSourceDirectory(copyCategoryKeywords, CopyCategoryKeywords::outputDir) }
}
// The keyword table of the category suggestion (UX-3, SPEC §9.11 CS-6), bundled as the Java resource
// se/hagstedt/kvitt/fakes/category-keywords.csv.
bundleCategoryKeywords("se/hagstedt/kvitt/fakes/category-keywords.csv")