Make google-java-format easier to use for non-chromium checkouts like R8

1. Use "codereview.settings" in addition to "buildtools" as the marker
   that identifies a project root.
2. Allow the presence of any .jar file to indicate the availability of
   google-java-format.
3. Do not pass --aosp when running google-java-format

Bug: 456461246
Change-Id: Id27b3c03f592a0ed73fb7a6b4dd662707a649166
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7102758
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
This commit is contained in:
Andrew Grieve
2025-10-30 12:05:33 -07:00
committed by LUCI CQ
parent 251779412a
commit 33744dc6bc
3 changed files with 21 additions and 14 deletions

View File

@@ -80,7 +80,8 @@ def _GetPrimarySolutionPathInternal(cwd):
return os.path.join(gclient_root, source_dir_name)
# Some projects might not use .gclient. Try to see whether we're in a git
# checkout that contains a 'buildtools' subdir.
# checkout that contains a "buildtools" directory or "codereview.settings"
# file.
top_dir = cwd
try:
top_dir = subprocess2.check_output(
@@ -90,7 +91,8 @@ def _GetPrimarySolutionPathInternal(cwd):
except subprocess2.CalledProcessError:
pass
if os.path.exists(os.path.join(top_dir, 'buildtools')):
if (os.path.exists(os.path.join(top_dir, 'codereview.settings'))
or os.path.exists(os.path.join(top_dir, 'buildtools'))):
return top_dir
return None