The IntelliJ plugin for Bazel includes the Fast Build feature, allowing you to run tests and executables without recompiling the entire target. This feature detects which Java files have changed and compiles only those files, significantly speeding up the development process.
To enable Fast Build, you must add specific VM options to your IntelliJ configuration.
The flags are required to run Java compilation inside the IntelliJ process, so that there's
no need to spawn a separate javac
process.
Follow these steps:
- Navigate to Help -> Edit Custom VM Options.
- Add the following entries:
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
Please use rules_java 7.12.2 or newer
To use Fast Build, locate your test or executable in the editor. Click the gutter icon and select either Fast Run or Fast Test.