diff --git a/build.gradle b/build.gradle index ce4a8c0e9..0af7084f9 100644 --- a/build.gradle +++ b/build.gradle @@ -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}") } }