fix(java-client): checkGeneratedClean via ProviderFactory.exec — Project.exec is gone in Gradle 9
This commit is contained in:
@@ -72,16 +72,18 @@ tasks.register('checkGeneratedClean') {
|
||||
group = 'verification'
|
||||
description = 'Fails if the committed generated Java tree differs from a fresh regeneration.'
|
||||
dependsOn 'generateProto'
|
||||
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
|
||||
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
|
||||
}
|
||||
def dirty = stdout.toString().trim()
|
||||
doLast {
|
||||
def dirty = gitStatus.standardOutput.asText.get().trim()
|
||||
if (!dirty.isEmpty()) {
|
||||
throw new GradleException(
|
||||
"Generated Java is stale:\n${dirty}\n" +
|
||||
|
||||
Reference in New Issue
Block a user