IntelliJ IDEA + Gradle Setup for OpenEMS

1. Prerequisites

  • IntelliJ IDEA (Community or Ultimate)

  • A JDK matching the OpenEMS build requirements (commonly JDK 21; e.g., Temurin 21)

  • Git

  • (Optional for UI) Node.js + npm, and the Angular CLI (or the tooling used in your OpenEMS UI setup)

2. Import the repository as a Gradle project

  1. Start IntelliJ IDEA (open any project or use the Welcome screen).

  2. Select File → New → Project from Existing Sources…

  3. Choose the repository folder (commonly named openems) and import it as a Gradle project.

  4. If IntelliJ asks which window to use, select This Window.

Import the project as Gradle (not as a plain IntelliJ project). This ensures IntelliJ uses the Gradle model for module structure, dependencies, and tasks.

Settings

3. Load / sync the Gradle project

After opening the repository, IntelliJ should show a popup like “Gradle build scripts found”.

  1. Click Load Gradle Project.

  2. Wait until the Gradle import finishes (you can see progress in the status bar, e.g. “Importing Gradle Project …”).

Settings

4. Create a Run configuration for Edge (JAR)

The common workflow is:

  • Build the Edge JAR with a Gradle task (e.g. buildEdge)

  • Run the generated JAR from IntelliJ

4.1. Create a “JAR Application” configuration

  1. Open Run → Edit Configurations…

  2. Click + and add a new JAR Application configuration.

  3. Fill in the values similar to the following (adapt paths to your machine):

    • Name: Run Edge (example)

    • Path to JAR: /<path-to-your-repo>/build/openems-edge.jar (example)

    • Working directory: /<path-to-your-repo>/

    • JRE: select your configured JDK (e.g., temurin-21)

If the jar name or location differs in your checkout, search in your repository for the jar output produced by the Gradle task buildEdge and use that path.

Settings
Settings
Settings

4.2. Add a “Before launch” Gradle task

To ensure the JAR is up-to-date on every run:

  1. In the same Run configuration, find the Before launch section.

  2. Add a Gradle task.

  3. Set:

    • Gradle project: openems

    • Tasks: buildEdge

Now, running Run Edge will build the Edge jar first and then launch it.

Settings
Settings

5. Install required IDE plugins

Install these IntelliJ plugins:

  • Adapter for Eclipse Code Formatter

  • CheckStyle-IDEA

Path: Settings/Preferences → Plugins.

6. Configure Checkstyle

  1. Open Settings/Preferences → Tools → Checkstyle.

  2. Add a new configuration:

    • Description: OpenEMS (example)

    • File: point to the repository checkstyle configuration (commonly cnf/checkstyle.xml)

  3. Click Next → Finish and activate the created configuration.

Settings

7. Enable Eclipse formatting

This aligns IntelliJ formatting with the formatting used in Eclipse-based setups.

  1. Open Settings/Preferences → Adapter for Eclipse Code Formatter.

  2. Enable Use Eclipse’s Code Formatter.

  3. Set the Eclipse installation folder to your local Eclipse installation (only needed if your plugin version requires it).

  4. Select a profile, e.g. Eclipse (built-in) or the profile agreed upon in your project.

If your team has an exported Eclipse formatter profile (e.g. .xml or .prefs), prefer that to ensure consistent formatting across IDEs.

Settings

8. IntelliJ code style tweaks (imports and tabs)

Some teams require specific import and indentation behavior.

8.1. Imports: avoid wildcard imports

  1. Open Settings/Preferences → Editor → Code Style → Java → Imports.

  2. Configure the thresholds for wildcard imports to high values (example: 999) to avoid * imports:

    • (1) Remove java.awt. and javax.swing.* imports*: unchecked (unless your project uses these packages)

    • (2) Class count to use import with ''*: 999

    • (2) Names count to use static import with ''*: 999

Settings

8.2. Indentation: tabs vs spaces

  1. Open Settings/Preferences → Editor → Code Style → Java → Tabs and Indents.

  2. If your project uses tabs, enable Use tab character.

Settings
  1. Repeat for other languages used in your project (e.g., Kotlin, XML, etc.) if they have different indentation rules.

Settings

Follow your repository / team conventions. If unsure, check existing source files and the formatting rules.

9. Debugging tests (Kotlin coroutine agent)

If test debugging behaves unexpectedly, disable the Kotlin coroutine agent:

  1. Go to Settings/Preferences → Build, Execution, Deployment → Debugger.

  2. Under Kotlin, uncheck Attach coroutine agent.

Settings

10. Run the UI from IntelliJ (optional)

You can start the UI dev server from IntelliJ via a Shell Script configuration.

  1. Open Run → Edit Configurations…

  2. Add a new configuration of type Shell Script.

  3. Set:

    • Name: UI

    • Script text: ng serve -o -c openems-edge-dev

    • Working directory: /<path-to-your-repo>/ui

  4. Apply and run.

This requires that UI dependencies are installed (usually via npm install) and that ng is available (Angular CLI).

Settings

11. IntelliJ Commit

To ensure code is properly formatted and quality checks run on commit. Click on gear icon in the Commit tool window and enable:

  • Reformat code

  • Run Checkstyle

  • Optimize imports

  • Scan with Checkstyle

  • Perform SonarQube for IDE analysis (if SonarQube plugin is installed)

  • Check TODOs

Settings