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'
description = 'Fails if the committed generated Java tree differs from a fresh regeneration.'
dependsOn 'generateProto'
def generatedDir = 'clients/java/src/main/generated'
def repoRoot = rootProject.projectDir.parentFile.parentFile
// Project.exec was removed in Gradle 9; ProviderFactory.exec runs the git-status probe
// lazily (captured at configuration time, evaluated in doLast) and works on both the
// installed Gradle and Gradle 9.
def gitStatus = providers.exec {
workingDir(repoRoot)
commandLine('git', 'status', '--porcelain', '--', generatedDir)
ignoreExitValue = true
}
doLast {
def generatedDir = 'clients/java/src/main/generated'
def stdout = new ByteArrayOutputStream()
def result = exec {
workingDir = rootProject.projectDir.parentFile.parentFile
commandLine 'git', 'status', '--porcelain', '--', generatedDir
standardOutput = stdout
ignoreExitValue = true
}
def dirty = stdout.toString().trim()
def dirty = gitStatus.standardOutput.asText.get().trim()
if (!dirty.isEmpty()) {
throw new GradleException(
"Generated Java is stale:\n${dirty}\n" +