The IntelliJ ecosystem has many plugins to integrate additional tooling into the IDE. Below are instructions to configure them for the Beam codebase.

The plugins listed here are not required in order to use IntelliJ for Beam development. If you're just getting started, we recommend getting familiar with the base IntelliJ setup before enabling additional plugins.

Checkstyle

IntelliJ supports checkstyle within the IDE using the Checkstyle-IDEA plugin.

Note: Older versions of IntelliJ may not support the Checkstyle file used by Beam.

  1. Install the Checkstyle-IDEA plugin from the IntelliJ plugin repository
  2. Configure the plugin by going to Settings | Other Settings | Checkstyle
  3. Set Checkstyle version to the same as in /buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy (e.g. 8.7)
  4. Set the Scan Scope to Only Java sources (including tests)
  5. In the Configuration File pane, add a new configuration using the plus icon:
    1. Set the Description to “Beam”
    2. Select Use a local Checkstyle file, and point it to sdks/java/build-tools/src/main/resources/beam/checkstyle.xml within your repository
    3. Check the box for Store relative to project location, and click Next
    4. Configure the checkstyle.suppressions.file property value to suppressions.xml, and click Next, then Finish
  6. Select “Beam” as the only active configuration file, and click Apply and OK
  7. Checkstyle will now give warnings in the editor for any Checkstyle violations

You can also scan an entire module by opening the Checkstyle tools window and clicking the Check Module button. The scan should report no errors.

Note: Selecting Check Project may report some errors from the archetype modules as they are not configured for Checkstyle validation.

Code Formatting

Uniform formatting for Java and Groovy code is automated by the build through the Spotless Gradle plugin. Instead of relying on the IDE, now you can run ./gradlew spotlessApply to reformat changes prior to commit.

If you want to autoformat in the same way while you are developing, use the Google Java Format plugin.

  • No labels