Eclipse is not widely used to Beam contributors, and the steps below are best-effort. If you're choosing a Java IDE, IntelliJ is a good choice.
Use a recent Eclipse version that includes Buildship for Gradle integration. Currently we recommend Eclipse Oxygen. Start Eclipse with a fresh workspace in a separate directory from your checkout.
Before setting up Eclipse integration, verify that you can successfully build from the commandline by building a sample package:
If you receive any errors, first verify your environment setup:
- If running on Mac or Linux, launch Eclipse from a terminal. This is necessary to ensure that Eclipse has proper environment setup from user profile scripts, i.e. .bashrc.
- Install Buildship Gradle Integration. This will allow importing and interacting with the Gradle build.
- Open the project import wizard in Eclipse via “File” > “Import”.
- From the “Import” screen, select “Gradle” > “Existing Gradle Project”, and click Next.
- From the “Import Gradle Project” screen, fill in the Project root directory with your local git path, and click Finish.
Eclipse will scan the project tree and import each as a separate Package.
Verify that your workspace is correctly configured by invoking ‘runners:direct-java:build’ from the “Gradle Tasks” pane. The build should succeed with no errors.
After your Eclipse workspace is properly setup, you will have a “Gradle Tasks” window with a set of operations. If you don’t see the pane, open it from “Window” > “Show View” > Other.. > “Gradle” > “Gradle Tasks”.
From the “Gradle Tasks” window, you can build any task registered with Gradle. For example, if you are working on Kinesis IO, select ‘sdks:java:io:kinesis:build’.
Eclipse supports checkstyle within the IDE using the Checkstyle plugin.
- Install the Checkstyle plugin.
- Configure the Checkstyle plugin by going to Preferences -> Checkstyle.
- Click “New…”
- Select “External Configuration File” for type
- Click “Browse…” and select
- Enter “Beam Checks” under “Name:”
- Click “OK”, then “OK”
Eclipse supports code styles within the IDE. Use one or both of the following to ensure your code style matches the project’s checkstyle enforcements.
- The simplest way to have uniform code style is to use the Google Java Format plugin
- You can also configure Eclipse to use
- Go to Preferences -> Java -> Code Style -> Formatter
- Click “Import…” and select
- Click “Apply” and “OK”