This project follows the IntelliJ Platform Plugin SDK guidelines. For comprehensive information on plugin development, refer to:
- IntelliJ Platform SDK Documentation
- IntelliJ Plugin Development Quick Start Guide
- Gradle IntelliJ Plugin Documentation
The plugin uses the Gradle build system with the Gradle IntelliJ Plugin. Here are the common commands:
# Build the plugin distribution (zip file)
./gradlew buildPlugin
# Run the tests
./gradlew test
# Run an IDE instance with the plugin installed
./gradlew runIde
# Clean build directory
./gradlew clean
# Verify plugin compatibility with specified IDE version
./gradlew verifyPlugin
The IntelliJ Erlang plugin has specific Java version requirements for different components:
- Built with Java 17
- Targets Java 17 bytecode (class file version 61.0)
- Compatible with the latest IntelliJ platform
- Built with Java 11 compatibility
- Targets Java 11 bytecode (class file version 55.0)
- Required for backward compatibility with older IDEs and Java runtimes
The JPS module is loaded by the IntelliJ build system, which may run on various Java versions depending on the IDE version. To ensure maximum compatibility, the JPS module targets Java 11 bytecode.
The main plugin can target the latest Java version supported by the current IntelliJ platform.
If you encounter an error like:
java.lang.UnsupportedClassVersionError: org/intellij/erlang/jps/model/JpsErlangModelSerializerExtension has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
This indicates a Java version mismatch between the compiled classes and the runtime environment. The solution is to:
- Ensure the JPS module is compiled with Java 11 compatibility (already configured in build.gradle)
- Build the plugin using Gradle with the correct JDK version
To build the plugin correctly:
./gradlew clean build
This will:
- Build the main plugin with Java 17 compatibility
- Build the JPS module with Java 11 compatibility
- Package everything together correctly
The plugin includes Gradle tasks to verify that the JPS module is compiled with Java 11 compatibility. These verifications are automatically run as part of the standard build process, including the buildPlugin
task.
If you want to run the verification tasks manually:
# Verify only the JPS module's Java 11 compatibility
./gradlew :jps-plugin:verifyJpsJava11Compatibility
# Verify the compiled class files
./gradlew :jps-plugin:verifyJpsClassFilesJava11Compatible
# Verify the JAR file
./gradlew :jps-plugin:verifyJpsJarJava11Compatible
These tasks check the bytecode version of each class file to ensure it's compatible with Java 11 (class file version 55.0 or lower).
The verification tasks are integrated into the main build pipeline in the following ways:
- The
check
task depends on JPS verification, ensuring all verification happens during testing - The
buildPlugin
task depends on JPS verification, making sure no plugin can be built with incompatible JPS classes - The
prepareSandbox
task depends on JPS verification, ensuring sandbox deployments also verify compatibility
This setup ensures that Java compatibility issues will be caught early in the development process, preventing incompatible builds from being released.
For CI environments, you can use this command to quickly check JPS module compatibility:
# Fast check for CI environments
./gradlew :jps-plugin:compileJava :jps-plugin:verifyJpsClassFilesJava11Compatible
This will compile the JPS module and then verify the Java 11 compatibility of the resulting class files.
This setup addresses the following issues:
- #957: Java version compatibility error with JpsErlangModelSerializerExtension
- #976: IntelliJ 2022.1 class version compatibility error
- #1022: Unsupported class version error
- #1054: Intellij Erlang plugin run configuration not working
To start contributing to the Erlang plugin:
- Fork the repository on GitHub
- Clone your fork locally
- Import the project as a Gradle project in IntelliJ IDEA
- Run
./gradlew runIde
to test your changes in a development instance
src/
- Main plugin source codejps-plugin/
- JPS module for build system integrationresources/
- Plugin resources (icons, templates, etc.)testData/
- Test data filestests/
- Test source code
- Create a branch for your feature or fix
- Make your changes
- Run tests with
./gradlew test
- Test the plugin with
./gradlew runIde
- Submit a pull request
- Adding a new inspection: Create a class that extends
org.intellij.erlang.inspection.ErlangInspection
- Adding a new intention action: Create a class that implements
org.intellij.erlang.intention.ErlangIntention
- Adding new file templates: Add template files to
resources/fileTemplates/
- Modifying the parser: Update
grammars/erlang.bnf
and run the grammar generator
To debug the plugin:
- Run
./gradlew runIde --debug-jvm
- Connect to the JVM using remote debugging in IntelliJ IDEA
- Set breakpoints in your code
- Open the Gradle tool window in IntelliJ IDEA
- Navigate to Tasks → intellij → runIde
- Right-click on runIde and select "Debug 'intellij-erlang [runIde]'"
- Set breakpoints in your code
This second method is more convenient as it allows you to simply click the debug button on an existing run configuration or create a permanent run configuration with debugging enabled. The debugger will attach automatically, and you can start debugging right away without manual connection steps.