From e7d71068e90e22bba2e4fcedf2941c8cd0f11be7 Mon Sep 17 00:00:00 2001 From: Brandon McAnsh Date: Tue, 25 Aug 2026 14:13:14 -0400 Subject: [PATCH] feat(gradle): build the contract packages from local checkouts Trying a proto change meant publishing a version for it, because the contract packages are only ever consumed at the versions pinned in libs.versions.toml. Setting protoLocalRoot in local.properties includes ocp-client-protocol and flipcash2-client-protocol as composite builds instead, and Gradle substitutes the com.flipcash modules for them on its own, because the coordinates match. Verified by pinning both versions to a nonexistent 99.99.99: :services:opencode resolves with protoLocalRoot set, and reports com.flipcash:ocp-client-protocol:99.99.99 FAILED without it, so the opt-in is what selects the local build rather than a cached artifact. local.properties is untracked and CI never writes it, so release builds keep resolving the published versions. --- settings.gradle.kts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/settings.gradle.kts b/settings.gradle.kts index 3ef8ed0a1..61926becf 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -21,6 +21,36 @@ plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" } +// The contract packages are consumed at the versions pinned in gradle/libs.versions.toml, +// which means trying a proto change would mean publishing one. Point protoLocalRoot at the +// directory holding ocp-client-protocol/ and flipcash2-client-protocol/ to build against +// those checkouts instead: +// +// # local.properties +// protoLocalRoot=/Users/you/dev/bmcreations/code +// +// Gradle substitutes com.flipcash:ocp-client-protocol and com.flipcash:flipcash2-client-protocol +// for the included builds on its own, because the coordinates match. The version in +// libs.versions.toml is ignored while this is on. +// +// local.properties is untracked and CI never writes it, so release builds always resolve the +// pinned versions from Maven Central. +val protoLocalRoot = java.util.Properties().apply { + val f = File(settingsDir, "local.properties") + if (f.exists()) f.inputStream().use { load(it) } +}.getProperty("protoLocalRoot")?.trim()?.takeIf { it.isNotEmpty() } + +if (protoLocalRoot != null) { + listOf("ocp-client-protocol", "flipcash2-client-protocol").forEach { repo -> + val dir = File(protoLocalRoot, repo) + require(dir.isDirectory) { + "protoLocalRoot=$protoLocalRoot has no $repo checkout in it" + } + includeBuild(dir) + } + logger.lifecycle("Contract packages: building from $protoLocalRoot, not the pinned versions") +} + dependencyResolutionManagement { repositoriesMode = RepositoriesMode.PREFER_SETTINGS repositories {