Start here if you are setting up a brand new development environment, or want to reconfigure your environment from scratch.
The instructions below assume you already have available:
A recent version of IntelliJ. These steps have been validated on IntelliJ 2020.2.2
JDK 1.8 installed and configured in IntelliJ
A local git clone of the apache/beam repository in your home directory ("~/beam")
To set up your IntelliJ project:
- Launch the New Project wizard by closing your project File | Close Project.
- Then click Open from the splash page to open a new project (Depending on what version of IntelliJ you may need to find an option to "Import project" instead)
- Select the settings.gradle.kts in the root of your beam git repo
You shouldn't need to modify the project settings. But you should double check on the Java SDK version. File → Project Structure Project → Settings
In the Project pane, set the Project SDK to "1.8", and select Apply.
Note: If the 1.8 SDK is not displayed, Download Java 8 and extract it (to any location) from the tar.gz option on the Oracle website.
Then add it under Platform Settings → SDKs-> + icon. (Removing other SDKs if you don't need them will help eliminate potential issues, but isn't required).
(Also set it up so that java -version uses this SDK on the command line. By setting up your PATH and JAVA_HOME properly to refer to the same location (And remove other java installation files, if necessary))
Double check these settings (but they shouldn't need to change) while the project syncs:
Open File | Settings... In left pane, navigate to Build, Execution, Deployment | Build Tools | Gradle | Runner. Select Delegate IDE build/run actions to gradle, and Run tests using: Gradle Test Runner. Then select Apply and OK.
Open View | Tool Windows | Gradle to open the Gradle pane.
Wait for the Gradle project to sync-- it may take 30 minutes or more. It should complete with no errors, and populate the list of Gradle projects in the Gradle pane.
Verify that your project is correctly configured by building and testing a single module.
You may also want to setup a specialized environment for the Beam modules you're working on:
Make sure to set the formatting options. Otherwise IntelliJ will make unnecessary changes.
File → Settings → Editor → Code Style → Java → Tabs and Indents
Make sure the settings match below:
Also disable "*" style imports
File → Settings → Editor → Code Style → Java → Imports
Set Class count to use import with '*'; to 999