Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions synthtool/languages/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
DEFAULT_FORMAT_VERSION = "1.6"


def format_code(path: str, version: str = DEFAULT_FORMAT_VERSION) -> None:
def format_code(
path: str, version: str = DEFAULT_FORMAT_VERSION, times: int = 2
) -> None:
"""
Runs the google-java-format jar against all .java files found within the
provided path.
Expand All @@ -39,7 +41,8 @@ def format_code(path: str, version: str = DEFAULT_FORMAT_VERSION) -> None:

# Run the formatter as a jar file
log.info("Running java formatter on {} files".format(len(files)))
shell.run(["java", "-jar", str(jar), "--replace"] + files)
for _ in range(times):
shell.run(["java", "-jar", str(jar), "--replace"] + files)


def _download_formatter(version: str, dest: Path) -> None:
Expand Down