Skip to content

Commit f97dedb

Browse files
JPercivalclaude
andcommitted
Adopt shared cqf.spotless-conventions plugin
Replace the per-subproject spotless setup with a single root-applied convention plugin vendored from home/shared/gradle/conventions/. The plugin pins: - spotless 8.4.0 (was 8.2.1) - palantirJavaFormat 2.89.0 (was 2.88.0) - ktfmt 0.56 + kotlinlangStyle (was 0.53) Targets `**/*.java`, `**/*.kt`, and `**/*.gradle.kts` from rootDir, including build-logic/, with generated/, build/, bin/, and .gradle/ excluded. Per-subproject `id("cqf.spotless-conventions")` applications are removed; the root application covers them via the rootDir-rooted globs. spotlessApply was run; the resulting reformat affects: - Java files where palantir 2.88→2.89 changed chained-method wrap rules - Kotlin script files where ktfmt 0.56 now applies (build-logic and root-level *.gradle.kts files were not previously inspected) Canonical source: home/shared/gradle/conventions/. Drift between shared/ and consumers is the signal — reconcile by porting good local changes back to shared/, or reverting bad ones in the consumer. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2452fee commit f97dedb

37 files changed

Lines changed: 617 additions & 526 deletions

build-logic/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ plugins {
33
alias(libs.plugins.buildconfig)
44
}
55

6-
fun Provider<PluginDependency>.asDep() =
7-
map { "${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" }
6+
fun Provider<PluginDependency>.asDep() = map {
7+
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}"
8+
}
89

910
repositories {
1011
gradlePluginPortal()

build-logic/gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
# Gradle plugins (used in build.gradle.kts dependencies)
33
kotlin = "2.3.20"
4-
spotless = "8.2.1"
4+
spotless = "8.4.0"
55
errorprone-gradle = "5.0.0"
66
animalsniffer = "2.0.1"
77
buildconfig = "6.0.7"
@@ -11,7 +11,7 @@ vanniktech-publish = "0.36.0"
1111
checkstyle = "12.2.0"
1212
error-prone-core = "2.42.0"
1313
jacoco = "0.8.14"
14-
palantir-format = "2.88.0"
14+
palantir-format = "2.89.0"
1515
gummy-bears = "0.12.0"
1616
ktfmt = "0.53"
1717

build-logic/src/main/kotlin/GitVersion.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import org.gradle.process.ExecOutput
1616
* 2. **main SNAPSHOT** — if on the `main` branch with no release tag at HEAD, take the most recent
1717
* tag reachable from HEAD matching [VersionScheme.describeGlob], feed it through
1818
* [VersionScheme.bumpForSnapshot], and append `-SNAPSHOT`.
19-
* 3. **Branch SNAPSHOT** — otherwise, append a sanitized branch identifier and the short SHA to
20-
* the bumped base (e.g. `2026.03.R02-feature-xyz-5ac419a5d-SNAPSHOT`). Branch name is taken
21-
* from `GITHUB_REF_NAME` / `CI_COMMIT_REF_NAME` if set (CI convention), else from `git
22-
* rev-parse`; a detached HEAD falls back to the literal `detached`.
19+
* 3. **Branch SNAPSHOT** — otherwise, append a sanitized branch identifier and the short SHA to the
20+
* bumped base (e.g. `2026.03.R02-feature-xyz-5ac419a5d-SNAPSHOT`). Branch name is taken from
21+
* `GITHUB_REF_NAME` / `CI_COMMIT_REF_NAME` if set (CI convention), else from `git rev-parse`; a
22+
* detached HEAD falls back to the literal `detached`.
2323
*
2424
* Fallbacks keep the build working in edge cases: no tags anywhere → [VersionScheme.fallbackBase];
2525
* `git` invocation failure → empty string, which callers treat as "no data."
@@ -43,9 +43,9 @@ fun gitVersion(rootDir: File, scheme: VersionScheme, providers: ProviderFactory)
4343
}
4444

4545
val lastTag =
46-
git("describe", "--tags", "--abbrev=0", "--match=${scheme.describeGlob}")
47-
.trim()
48-
.takeIf { it.isNotEmpty() }
46+
git("describe", "--tags", "--abbrev=0", "--match=${scheme.describeGlob}").trim().takeIf {
47+
it.isNotEmpty()
48+
}
4949
val baseVersion = lastTag?.removePrefix("v") ?: scheme.fallbackBase
5050
val bumped = scheme.bumpForSnapshot(baseVersion)
5151

build-logic/src/main/kotlin/VersionScheme.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
22
* Strategy for parsing release tags and computing the next SNAPSHOT base version.
33
*
4-
* Canonical source: `home/shared/gradle/conventions/VersionScheme.kt`. Consumers vendor a copy
5-
* into their own `build-logic/`; propagate enhancements through `shared/`.
4+
* Canonical source: `home/shared/gradle/conventions/VersionScheme.kt`. Consumers vendor a copy into
5+
* their own `build-logic/`; propagate enhancements through `shared/`.
66
*
77
* [gitVersion] is scheme-agnostic; all format-specific behavior lives here so the same resolver can
88
* be shared across repos with different versioning conventions. Two built-in schemes are provided:
9-
* [SemverScheme] for `X.Y.Z` (bumps minor) and [CalendarReleaseScheme] for `YYYY.MM.RNN` (bumps
10-
* the `R` counter).
9+
* [SemverScheme] for `X.Y.Z` (bumps minor) and [CalendarReleaseScheme] for `YYYY.MM.RNN` (bumps the
10+
* `R` counter).
1111
*/
1212
interface VersionScheme {
1313
/**
@@ -37,9 +37,7 @@ interface VersionScheme {
3737
fun bumpForSnapshot(baseVersion: String): String
3838
}
3939

40-
/**
41-
* Semantic versioning (`X.Y.Z`). Bump rule: increment minor, reset patch.
42-
*/
40+
/** Semantic versioning (`X.Y.Z`). Bump rule: increment minor, reset patch. */
4341
object SemverScheme : VersionScheme {
4442
override val tagRegex = Regex("""\d+\.\d+\.\d+.*""")
4543
override val describeGlob = "v*.*.*"

build-logic/src/main/kotlin/cqf.animal-sniffer-conventions.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
plugins {
2-
id("ru.vyarus.animalsniffer")
3-
}
1+
plugins { id("ru.vyarus.animalsniffer") }
42

53
dependencies {
64
"signature"("com.toasttab.android:gummy-bears-api-34:${BuildConfig.GUMMY_BEARS}@signature")

build-logic/src/main/kotlin/cqf.ci-conventions.gradle.kts

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ import cqf.LinkedBuildRegistry
55

66
tasks.register("resolveLinkedBuilds") {
77
group = "ci"
8-
description = "Parses Depends-On from the PR description and sets up composite builds for linked repos."
8+
description =
9+
"Parses Depends-On from the PR description and sets up composite builds for linked repos."
910

1011
outputs.upToDateWhen { false }
1112

1213
doLast {
1314
fun run(vararg args: String): String {
14-
val proc = ProcessBuilder(*args)
15-
.directory(project.projectDir)
16-
.redirectErrorStream(true)
17-
.start()
15+
val proc =
16+
ProcessBuilder(*args)
17+
.directory(project.projectDir)
18+
.redirectErrorStream(true)
19+
.start()
1820
val output = proc.inputStream.bufferedReader().readText()
1921
val exitCode = proc.waitFor()
2022
if (exitCode != 0) {
@@ -23,12 +25,13 @@ tasks.register("resolveLinkedBuilds") {
2325
return output.trim()
2426
}
2527

26-
val prNumber = (findProperty("prNumber") as? String)
27-
?: System.getenv("PR_NUMBER")
28-
?: throw GradleException(
29-
"resolveLinkedBuilds requires a PR number. " +
30-
"Pass -PprNumber=123 or set PR_NUMBER env var."
31-
)
28+
val prNumber =
29+
(findProperty("prNumber") as? String)
30+
?: System.getenv("PR_NUMBER")
31+
?: throw GradleException(
32+
"resolveLinkedBuilds requires a PR number. " +
33+
"Pass -PprNumber=123 or set PR_NUMBER env var."
34+
)
3235

3336
// Fetch PR body via gh CLI
3437
val prBody = run("gh", "pr", "view", prNumber, "--json", "body", "--jq", ".body")
@@ -68,16 +71,22 @@ tasks.register("resolveLinkedBuilds") {
6871
cloneDir.parentFile.mkdirs()
6972

7073
run(
71-
"git", "clone", "--depth", "1", "--branch", branch,
74+
"git",
75+
"clone",
76+
"--depth",
77+
"1",
78+
"--branch",
79+
branch,
7280
"https://github.com/$repoSlug.git",
73-
cloneDir.absolutePath
81+
cloneDir.absolutePath,
7482
)
7583

76-
val buildPath = if (build.buildRoot.isNotEmpty()) {
77-
"${cloneDir.absolutePath}/${build.buildRoot}"
78-
} else {
79-
cloneDir.absolutePath
80-
}
84+
val buildPath =
85+
if (build.buildRoot.isNotEmpty()) {
86+
"${cloneDir.absolutePath}/${build.buildRoot}"
87+
} else {
88+
cloneDir.absolutePath
89+
}
8190

8291
properties.setProperty(build.propertyKey, buildPath)
8392
}

build-logic/src/main/kotlin/cqf.git-version.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ val scheme: VersionScheme =
1414
"semver" -> SemverScheme
1515
"calendar" -> CalendarReleaseScheme
1616
else ->
17-
error(
18-
"Unknown cqf.gitVersion.scheme: '$schemeName' (expected 'semver' or 'calendar')"
19-
)
17+
error("Unknown cqf.gitVersion.scheme: '$schemeName' (expected 'semver' or 'calendar')")
2018
}
2119
val resolvedVersion = gitVersion(rootDir, scheme, providers)
2220

0 commit comments

Comments
 (0)