Skip to content

refactor(build-logic): extract the KMP test-fixture generator into a convention plugin - #1293

Merged
bmc08gt merged 1 commit into
code/cashfrom
refactor/kmp-test-fixtures-plugin
Aug 21, 2026
Merged

refactor(build-logic): extract the KMP test-fixture generator into a convention plugin#1293
bmc08gt merged 1 commit into
code/cashfrom
refactor/kmp-test-fixtures-plugin

Conversation

@bmc08gt

Copy link
Copy Markdown
Collaborator

Problem

libs/encryption/base58/build.gradle.kts and libs/codes/kikcode/build.gradle.kts each carried a byte-identical copy of GenerateTestFixtures — differing only in the package the generated file is declared in (com.getcode.vendor vs com.getcode.codes.kikcode) — plus an identical block wiring the AGP lint tasks to the generator:

tasks.matching { it.name.startsWith("lint") || it.name.endsWith("LintModel") }
.configureEach { dependsOn(generateTestFixtures) }

That copy-paste already broke code/cash once. #1288 added the lint wiring to kikcode; #1289 then introduced the same generator in base58 without it, and lint failed over an undeclared dependency on generated sources (fixed in #1292).

The failure mode is easy to hit: kotlin.srcDir(taskProvider) carries the task dependency to the Kotlin compile tasks only, while lint reads the same source directories straight off disk. Nothing about copying the generator suggests the extra wiring is needed, and it's invisible until CI runs lint.

Change

Move the task into build-logic behind a new flipcash.kmp.test.fixtures convention plugin:

  • GenerateTestFixtures — the task, unchanged apart from the package becoming a @get:Input property. The output path is derived from it, so com.getcode.vendor still lands at com/getcode/vendor/TestFixtures.kt.
  • TestFixturesExtensionpackageName (required) and fixtures (defaults to src/commonTest/resources).
  • KmpTestFixturesConventionPlugin — registers the task, adds the generated directory to commonTest, and wires the lint dependency automatically. A module that applies the plugin cannot omit it.

Both modules drop from ~75 lines of build script to four:

plugins {
kotlin("multiplatform")
id("com.android.kotlin.multiplatform.library")
alias(libs.plugins.flipcash.kmp.test.fixtures)
}
testFixtures {
packageName ="com.getcode.vendor"
}

Notes

packageName has no default, so a module that applies the plugin and forgets to set it fails with Gradle's standard "property 'packageName' doesn't have a configured value". I opted against defaulting to the Android namespace: base58's namespace (com.getcode.encryption.base58) doesn't match its fixture package (com.getcode.vendor), and a silently-wrong default is worse than a loud missing one.

…convention plugin
`libs/encryption/base58` and `libs/codes/kikcode` each carried a byte-identical
copy of `GenerateTestFixtures`, differing only in the package the generated file
is declared in, plus an identical block wiring the AGP lint tasks to depend on
the generator.
That copy-paste broke `code/cash` once already: #1288 added the lint wiring to
kikcode, then #1289 introduced the same generator in base58 without it, and lint
failed over an undeclared dependency on generated sources. Adding the source
directory only carries the dependency to the Kotlin compile tasks -- lint reads
the same directories straight off disk -- so the wiring is easy to forget and
invisible until CI runs.
Move the task into `build-logic` behind a `flipcash.kmp.test.fixtures`
convention plugin. The plugin takes the package via a `testFixtures {}`
extension, registers the generated directory on `commonTest`, and wires the lint
dependency itself, so a module that applies it cannot omit it. Both modules drop
from ~75 lines of build script to four.
@github-actionsgithub-actionsBot added type: refactor Code restructuring, no behavior change area: crypto Solana, keys, encryption, signing area: build-system Gradle, convention plugins, build-logic labels Aug 21, 2026
@bmc08gt
bmc08gt merged commit 563e071 into code/cashAug 21, 2026
3 checks passed
@bmc08gt
bmc08gt deleted the refactor/kmp-test-fixtures-plugin branch August 21, 2026 13:46
bmc08gt added a commit that referenced this pull request Aug 21, 2026
…esign
* origin/code/cash:
fix(core): add \ to escape ' in What's (#1298)
feat(shared-core): wrap the framework in a Swift target (#1297)
chore: update display name entry title/hint (#1296)
ci(shared-core): write a placeholder local.properties before publishing (#1295)
build(shared-core): publish the XCFramework to flipcash-shared-core-spm (#1294)
refactor(build-logic): extract the KMP test-fixture generator into a convention plugin (#1293)
build(base58): declare the base58 lint tasks' dependency on generated fixtures (#1292)
test(base58): run the vector gate on Kotlin/Native, not just the JVM (#1289)
build(codes): declare the kikcode lint tasks' dependency on generated fixtures (#1288)
# Conflicts:
#	apps/flipcash/core/src/main/res/values/strings.xml
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build-systemGradle, convention plugins, build-logicarea: cryptoSolana, keys, encryption, signingtype: refactorCode restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@bmc08gt