GitHub - JetBrains/intellij-community: IntelliJ IDEA & IntelliJ Platform

5 min read Original article ↗

official JetBrains project IntelliJ IDEA build status PyCharm build status

IntelliJ Open Source Repository

This repository is the open-source part of the JetBrains IDEs codebase. It also serves as the basis for IntelliJ Platform development.

These instructions will help you build and run open source parts of IntelliJ Platform / IntelliJ IDEA / PyCharm.

If you are new to the community and would like to contribute code or help others learn, see CONTRIBUTING.md to get started.

The following conventions will be used to refer to directories on your machine:

  • <USER_HOME> is your OS user's home directory.
  • <IDEA_HOME> is the root directory for the IntelliJ source code.

Getting the Source Code

This section will guide you through getting the project sources and help avoid common issues in Git config and other steps before opening it in the IDE.

Prerequisites

  • Install Git.
  • On Windows, set these Git options to avoid common issues during cloning:
    git config --global core.longpaths true
    git config --global core.autocrlf input

Clone Main Repository

IntelliJ open source repository is available from the GitHub repository, which can be cloned or downloaded as a zip file (based on a branch) into <IDEA_HOME>. The master (default) branch contains the source code which will be used to create the next major version of all JetBrains IDEs. The branch names and build numbers for older releases of JetBrains IDEs can be found on the Build Number Ranges page.

You can clone this project using IntelliJ IDEA (see Opening the IntelliJ IDEA Source Code in the IDE).

Alternatively, run the following commands in the terminal:

git clone https://github.com/JetBrains/intellij-community.git
cd intellij-community

Tip

  • For faster download: If the complete repository history isn't needed, create shallow clone. To download only the latest revision of the repository, add --depth 1 option after clone.
  • Cloning in IntelliJ IDEA also supports creating shallow clone.

Get Android Modules

IntelliJ IDEA requires additional Android modules from separate Git repositories. Run the following script from project root <IDEA_HOME> to get the required modules:

  • Unix: ./getPlugins.sh
  • Windows: getPlugins.bat

Important

Always git checkout the intellij-community and android Git repositories to the same branches/tags.


Building IntelliJ IDEA

These instructions will help you build IntelliJ IDEA from source code, which is the basis for IntelliJ Platform development.

Important

IntelliJ IDEA project is currently being migrated to the Bazel build system. The migration is still in progress, so you may encounter some rough edges or temporary issues along the way, mostly related to IDE integration.

  • Building the project using only IDE built-in capabilities is not supported anymore, so make sure the Bazel plugin is installed and enabled.
  • Known issue: some tests are not yet possible to be run with Bazel. In case of any issues, please depend on the tests.cmd script mentioned in the Running IntelliJ IDEA in a CI/CD environment section.

Opening the IntelliJ IDEA Source Code in the IDE

Prerequisites:

Using the latest IntelliJ IDEA, click File | Open and select the <IDEA_HOME>/.bazelproject. If IntelliJ IDEA displays a message about a missing or out-of-date required plugin (e.g., Kotlin), enable, upgrade, or install that plugin and restart IntelliJ IDEA.

Building the IntelliJ IDEA Application

In IntelliJ IDEA, choose Build | Build Project from the main menu.

From the command line, run the bazel-build-all-community.cmd script in the <IDEA_HOME> directory (note: all *.cmd scripts work on both Windows and Unix systems).

To build installation packages, run the installers.cmd script in the <IDEA_HOME> directory. Options to build installers are passed as system properties to installers.cmd command. You may find the list of available properties in BuildOptions.kt

Pass --debug to suspend and wait for the debugger to attach to port 5005.

Installer build examples:

# Build installers only for current operating system:
./installers.cmd -Dintellij.build.target.os=current

Tip

The installers.cmd is used to run OpenSourceCommunityInstallersBuildTarget from the command line. You can also call it directly from IDEA, using run configuration Build IntelliJ IDEA Installers (current OS).

Dockerized Build Environment

To build installation packages inside a Docker container with preinstalled dependencies and tools, run the following command in <IDEA_HOME> directory (on Windows, use PowerShell):

docker build . --target intellij_idea --tag intellij_idea_env
docker run --rm --user "$(id -u)" --volume "${PWD}:/community" intellij_idea_env

Note

Please remember to specify the --user "$(id -u)" argument for the container's user to match the host's user. This prevents issues with permissions for the checked-out repository, the build output, if any.


Running IntelliJ IDEA

To run the IntelliJ IDEA that was built from source, choose Run | Run... from the main menu and choose the preconfigured run configuration Run //build:idea_community.

To run tests on the build, apply these settings to the Run | Edit Configurations... | Templates | JUnit configuration tab:

  • Working dir: <IDEA_HOME>/bin
  • VM options: -ea

Running IntelliJ IDEA in a CI/CD environment

To run tests outside IntelliJ IDEA, use the tests.cmd command in <IDEA_HOME> directory. Options to run tests are passed as system properties to tests.cmd command. You may find the list of available properties in TestingOptions.kt

# Run specific run configuration:
./tests.cmd -Dintellij.build.test.configurations=ApiCheckTest
# Run a specific test: 
./tests.cmd -Dintellij.build.test.patterns=com.intellij.util.ArrayUtilTest

To debug tests, use: -Dintellij.build.test.debug.enabled=true -Dintellij.build.test.debug.suspend=true -Dintellij.build.test.debug.port=5005.

tests.cmd is used just to run CommunityRunTestsBuildTarget from the command line. You can also call it directly from IDEA, see run configuration tests for an example.