fix(java-client): checkGeneratedClean via ProviderFactory.exec — Project.exec is gone in Gradle 9

This commit is contained in:
Joseph Doherty
2026-08-18 06:38:35 -04:00
parent fd941c249e
commit df45cb4a37
@@ -72,16 +72,18 @@ tasks.register('checkGeneratedClean') {
group = 'verification' group = 'verification'
description = 'Fails if the committed generated Java tree differs from a fresh regeneration.' description = 'Fails if the committed generated Java tree differs from a fresh regeneration.'
dependsOn 'generateProto' dependsOn 'generateProto'
doLast {
def generatedDir = 'clients/java/src/main/generated' def generatedDir = 'clients/java/src/main/generated'
def stdout = new ByteArrayOutputStream() def repoRoot = rootProject.projectDir.parentFile.parentFile
def result = exec { // Project.exec was removed in Gradle 9; ProviderFactory.exec runs the git-status probe
workingDir = rootProject.projectDir.parentFile.parentFile // lazily (captured at configuration time, evaluated in doLast) and works on both the
commandLine 'git', 'status', '--porcelain', '--', generatedDir // installed Gradle and Gradle 9.
standardOutput = stdout def gitStatus = providers.exec {
workingDir(repoRoot)
commandLine('git', 'status', '--porcelain', '--', generatedDir)
ignoreExitValue = true ignoreExitValue = true
} }
def dirty = stdout.toString().trim() doLast {
def dirty = gitStatus.standardOutput.asText.get().trim()
if (!dirty.isEmpty()) { if (!dirty.isEmpty()) {
throw new GradleException( throw new GradleException(
"Generated Java is stale:\n${dirty}\n" + "Generated Java is stale:\n${dirty}\n" +