1
0
mirror of https://github.com/google/nomulus synced 2026-01-06 05:27:13 +00:00

Make the formatting tasks work with Java 17 (take 2) (#2305)

We should not assume org.gradle.java.home to exist on kokoro or GCB.
This commit is contained in:
Lai Jiang
2024-01-25 12:08:30 -05:00
committed by GitHub
parent a4903c27b9
commit 0112b3ae06

View File

@@ -504,7 +504,13 @@ def createGetBuildSrcDirectDepsTask(outputFileName) {
rootProject.ext {
invokeJavaDiffFormatScript = { action ->
def javaHome = project.findProperty('org.gradle.java.home')
println("Running the formatting tool with JDK at $javaHome")
def javaBin
if (javaHome != null) {
javaBin = "$javaHome/bin/java"
} else {
javaBin = ext.execInBash("which java", rootDir)
}
println("Running the formatting tool with $javaBin")
def scriptDir = rootDir.path.endsWith('buildSrc')
? "${rootDir}/../java-format"
: "${rootDir}/java-format"
@@ -515,7 +521,7 @@ rootProject.ext {
def pythonExe = getPythonExecutable()
return ext.execInBash(
"JAVA=${javaHome}/bin/java PYTHON=${pythonExe} ${formatDiffScript} ${action}", "${workingDir}")
"JAVA=${javaBin} PYTHON=${pythonExe} ${formatDiffScript} ${action}", "${workingDir}")
}
}