Skip to content

Commit

Permalink
docs(owlbot-java): explaining why not using formatter in pom.xml (#1511)
Browse files Browse the repository at this point in the history
Fixes #1502
  • Loading branch information
suztomo authored Aug 1, 2022
1 parent 653c514 commit 26ea255
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docker/owlbot/java/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
# build from the root of this repo:
FROM gcr.io/cloud-devrel-public-resources/java8

# The OwlBot Java postprocessor does not rely on project's Java formatter.
# When you upgrade the formatter version, see the issue below for the required
# changes:
# https://github.com/googleapis/synthtool/issues/1502
ARG JAVA_FORMAT_VERSION=1.7

RUN apt-get install -y --no-install-recommends jq
Expand Down
6 changes: 6 additions & 0 deletions docker/owlbot/java/bin/format_source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@

set -e

# Why OwlBot Java postprocessor does not use the formatter defined in pom.xml?
# It's because the postprocessor runs in a privileged (albeit limited)
# environment. We limit the risk of running somebody else's malicious Maven
# plugin code in the environment.

# Find all the java files relative to the current directory and format them
# using google-java-format
list="$(find . -name '*.java' -not -path ".*/samples/snippets/generated/**/*" )"
Expand All @@ -33,6 +38,7 @@ do
fi
done

# This JAR file is downloaded by Dockerfile
cat $tmpfile | xargs java -jar /owlbot/google-java-format.jar --replace

rm $tmpfile

0 comments on commit 26ea255

Please sign in to comment.