mirror of
https://github.com/google/nomulus.git
synced 2025-07-27 21:16:25 +02:00
Make the formatting tasks work with Java 17 (#2301)
TESTED=ran gradle jIFA locally after intentionally mis-formatting a Java file.
This commit is contained in:
parent
2166c28d6d
commit
a4903c27b9
4 changed files with 11 additions and 28 deletions
|
@ -503,10 +503,8 @@ def createGetBuildSrcDirectDepsTask(outputFileName) {
|
|||
|
||||
rootProject.ext {
|
||||
invokeJavaDiffFormatScript = { action ->
|
||||
println("JAVA_HOME=${System.env.JAVA_HOME}")
|
||||
println("PATH=${System.env.PATH}")
|
||||
println(ext.execInBash("type java", "${rootDir}"))
|
||||
println(ext.execInBash("java -version", "${rootDir}"))
|
||||
def javaHome = project.findProperty('org.gradle.java.home')
|
||||
println("Running the formatting tool with JDK at $javaHome")
|
||||
def scriptDir = rootDir.path.endsWith('buildSrc')
|
||||
? "${rootDir}/../java-format"
|
||||
: "${rootDir}/java-format"
|
||||
|
@ -517,7 +515,7 @@ rootProject.ext {
|
|||
def pythonExe = getPythonExecutable()
|
||||
|
||||
return ext.execInBash(
|
||||
"PYTHON=${pythonExe} ${formatDiffScript} ${action}", "${workingDir}")
|
||||
"JAVA=${javaHome}/bin/java PYTHON=${pythonExe} ${formatDiffScript} ${action}", "${workingDir}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
BIN
java-format/google-java-format-1.19.2-all-deps.jar
Normal file
BIN
java-format/google-java-format-1.19.2-all-deps.jar
Normal file
Binary file not shown.
Binary file not shown.
|
@ -40,37 +40,22 @@ where:
|
|||
show show the effect of the formatting as unified diff"
|
||||
|
||||
SCRIPT_DIR="$(realpath $(dirname $0))"
|
||||
JAR_NAME="google-java-format-1.8-all-deps.jar"
|
||||
JAR_NAME="google-java-format-1.19.2-all-deps.jar"
|
||||
|
||||
# Make sure we have a valid python interpreter.
|
||||
if [ -z "$PYTHON" ]; then
|
||||
echo "You must specify the name of a python3 interpreter in the PYTHON" \
|
||||
echo "You must specify the name of a Python interpreter in the PYTHON" \
|
||||
"environment variable."
|
||||
exit 1
|
||||
elif ! "$PYTHON" -c ''; then
|
||||
echo "Invalid python interpreter: $PYTHON"
|
||||
echo "Invalid Python interpreter: $PYTHON"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Locate the java binary.
|
||||
if [ -n "$JAVA_HOME" ]; then
|
||||
JAVA_BIN="$JAVA_HOME/bin/java"
|
||||
if [ ! -x "$JAVA_BIN" ]; then
|
||||
echo "No java binary found in JAVA_HOME (JAVA_HOME is $JAVA_HOME)"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Use java from the path.
|
||||
JAVA_BIN="$(which java)" || JAVA_BIN=""
|
||||
if [ -z "$JAVA_BIN" ]; then
|
||||
echo "JAVA_HOME is not defined and java was not found on the path"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! "$JAVA_BIN" -version 2>&1 | grep 'version "11\.' >/dev/null; then
|
||||
echo "Bad java version. Requires java 11, got:"
|
||||
"$JAVA_BIN" -version
|
||||
# Make sure we have a valid JRE binary
|
||||
if [ -z "$JAVA" ]; then
|
||||
echo "You must specify the name of a JRE binary in the JAVA" \
|
||||
"environment variable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -80,7 +65,7 @@ function runGoogleJavaFormatAgainstDiffs() {
|
|||
|
||||
git diff -U0 "$forkPoint" | \
|
||||
"${PYTHON}" "${SCRIPT_DIR}/google-java-format-diff.py" \
|
||||
--java-binary "$JAVA_BIN" \
|
||||
--java-binary "$JAVA" \
|
||||
--google-java-format-jar "${SCRIPT_DIR}/${JAR_NAME}" \
|
||||
-p1 "$@" | \
|
||||
tee gjf.out
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue