From ba0428fc9b9c40aaff4dffc83c06c3dd1f7d61d1 Mon Sep 17 00:00:00 2001 From: Elango Cheran Date: Tue, 28 Jun 2022 14:49:59 -0700 Subject: [PATCH] Instructions about source formatter --- docs/build.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/build.md b/docs/build.md index acc375804..7f3e744de 100644 --- a/docs/build.md +++ b/docs/build.md @@ -87,7 +87,22 @@ Currently, some tests run on the generated output files of a tool (ex: in order | UVERSION | 14.0.0 | -### Eclipse-specific Additional Setup +### Editing and tool execution setup + +#### Source code formatting + +Like other projects, Unicode Tools uses a source formatter to ensure a consistent code style automatically, and it uses a single common formatter to avoid spurious diff noise in code reviews. This is now enforced via a [formatter](https://github.com/google/google-java-format) that is [configured in the Maven build](https://github.com/unicode-org/unicodetools/pull/254) via a [Maven plugin](https://github.com/diffplug/spotless/tree/main/plugin-maven) and checked by continuous integration on pull requests. + +When creating pull requests, you can check the formatting locally using the command `mvn spotless:check`. You can apply the formatter's changes using the command `mvn spotless:apply`. Continuous integration errors for formatting can be fixed by committing the changes resulting from applying the formatter locally and pushing the new commit. + +Some IDEs can integrate the formatter via plugins, which can minimize the need to manually run the formatter separately. The following links for specific IDEs may work: + +* Eclipse: Follow the [instructions](https://source.android.com/devices/tech/test_infra/tradefed/development/eclipse#auto_format) in the "Auto format" section. You can alternatively use this link for [`android-formatting.xml`](https://raw.githubusercontent.com/aosp-mirror/platform_development/master/ide/eclipse/android-formatting.xml). +* VSCode: Follow the [instructions](https://code.visualstudio.com/docs/java/java-linting#_formatter) in "Applying formatter settings", but use the same `android-formatting.xml` link mentioned for Eclipse (ex: `"java.format.settings.url": "https://raw.githubusercontent.com/aosp-mirror/platform_development/master/ide/eclipse/android-formatting.xml",`). Also use the profile name corresponding to that XML file: (ex: `"java.format.settings.profile": "Android",`). +* IntelliJ: Use the [official plugin](https://plugins.jetbrains.com/plugin/8527-google-java-format/) for the formatter. + + +#### Eclipse-specific Additional Setup 1. Follow the Eclipse-specific settings at 1. Edit the cldr-code project’s Build Path: