platform/eel/docs/EelApi_Real_World_Examples.md
This document provides an overview of how the EEL API is used in IntelliJ IDEA plugins and features. It builds on the concepts introduced in the EelApi Tutorial.
EelApi enables IntelliJ IDEA to run build tools like Gradle and Maven in different environments (local, Docker, WSL) with a unified approach. This is crucial for projects that need to be built in specific environments.
The key pattern in build tool integration is checking if the environment is local or remote, and adapting the execution strategy accordingly. The EelTargetEnvironmentConfigurationProvider class implements this pattern for Gradle, skipping custom execution for local environments and providing environment-specific execution for remote environments.
For remote environments, the provider:
When executing build tools in remote environments, it's essential to convert paths between local and remote representations. The EelMavenRemoteProcessSupportFactory handles this for Maven by:
EelApi enables version control systems like Git to work seamlessly across different environments, ensuring that VCS operations work consistently whether the project is local, in a Docker container, or in WSL.
The key benefit of using EelApi with Git is that it automatically adapts to the environment where the project is located. The GitRecentProjectsBranchesProvider demonstrates this by:
This approach ensures that Git operations work consistently across all environments without requiring environment-specific code.
RustRover uses EelApi to enable seamless Rust development across different environments (local, Docker, WSL). This allows Rust developers to work with projects located in any environment without having to worry about the underlying details.
The key component is the RsEelToolchain class, which provides environment-specific implementations for Rust toolchain operations. It handles:
The RsEelToolchainProvider creates instances of RsEelToolchain when appropriate, allowing RustRover to:
IntelliJ IDEA's terminal integration uses EelApi to provide a consistent terminal experience across different environments. This allows users to work with terminals in Docker containers, WSL distributions, or remote SSH hosts just as easily as with local terminals.
The terminal plugin uses EelApi to determine the appropriate shell to use based on the environment. The TerminalProjectOptionsProvider handles this by:
The terminal plugin executes commands using EelApi, ensuring they run in the appropriate environment. The ShellRuntimeContextReworkedImpl demonstrates this by:
This approach allows the terminal plugin to:
These real-world examples demonstrate how EelApi enables IntelliJ IDEA plugins to work seamlessly across different environments. The key benefits include:
Environment Abstraction: Code written against EelApi works in any environment (local, Docker, WSL) without environment-specific logic.
Path Handling: EelApi automatically handles path conversion between different environments, making it easy to work with files across environments.
Process Execution: Running processes in different environments is simplified with a consistent API, regardless of the underlying OS.
By using EelApi, plugin developers can focus on their functionality rather than the complexities of different environments, resulting in a consistent user experience across all supported platforms.