IntelliJ IDEA 2023.3 Help

Shared indexes

One of the possible ways of reducing the indexing time is by using shared indexes. Unlike the regular indexes that are built locally, shared indexes are generated once and are later reused on another computer whenever they are needed.

IntelliJ IDEA can connect to a dedicated resource to download shared indexes for your JDK and build shared indexes for your project's code. Whenever IntelliJ IDEA needs to reindex your application, it will use the available shared indexes and will build local indexes for the rest of the project. Normally, this is faster than building local indexes for the entire application from scratch.

Shared indexes for JDKs

Indexes for JDK are built by JetBrains and stored on the dedicated CDN resource. IntelliJ IDEA seamlessly connects to a dedicated resource in the background, fetching and applying shared indexes for your JDK automatically. You can change this behavior in settings.

  1. Press Ctrl+Alt+S to open the IDE settings and then select Tools | Shared Indexes.

  2. In the Public Shared Indexes section, expand the JDKs drop-down list and select the required option:

    • Ask before download: confirm every download manually.

    • Don't download, use local indexes: do not use shared indexes for JDKs.

    Shared indexes

JDK indexes will be downloaded to index/shared_indexes in the IDE system directory. After that, IntelliJ IDEA will be using the suitable indexes whenever they are needed.

Shared project indexes

Shared project indexes are built for project sources and its dependencies. By generating indexes on a single computer and distributing them to other computers, you can avoid duplicating the indexing process on each machine. This way, each computer can benefit from the precomputed indexes without having to perform the expensive indexing operations individually. This is the main advantage of shared indexes over ordinary indexes.

Using shared indexes is reasonable for large projects, where indexing might take a lot of time, creating inconveniences for the teams involved. For smaller projects, we recommend other ways of reducing the indexing time.

Make sure the plugin is installed

To be able to use shared project indexes, the Shared Project Indexes bundled plugin must be enabled in the settings:

  1. Press Ctrl+Alt+S to open the IDE settings and then select Plugins.

  2. Switch to the Installed tab, type Shared Project Indexes, and make sure that the checkbox next to it is selected.

    Otherwise, select the checkbox to enable the plugin.

  3. Apply the changes and close the dialog. Restart the IDE if prompted.

Install the plugin

To be able to use shared project indexes, install the Shared Project Indexes plugin:

  1. Press Ctrl+Alt+S to open the IDE settings and then select Plugins.

  2. Switch to the Marketplace tab and type Shared Project Indexes in the search field.

  3. Once the plugin is found in the list of available plugins, click Install next to it.

  4. Apply the changes and close the dialog. Restart the IDE if prompted.

Before you begin

  • To ensure index compatibility, use the same IDE version on the source and the target computer.

  • You can have different operating systems on the source and the target computer.

    However, in previous IntelliJ IDEA versions, shared project indexes were OS-specific. Refer to the documentation that corresponds to your IDE version by using the version switcher in the top-left corner of this page.

Before incorporating shared project indexes into your infrastructure, you can evaluate how much time they can save on indexing by running the command-line tool.

If you are satisfied with the results, you can keep using shared indexes from the command line. In more complex scenarios, you can customize sample scripts from the IntelliJ Shared Indexes Tool Example repository.

Evaluate indexing time with shared indexes

Before using shared project indexes in your workflow, you can see how much time they are able to save you. During evaluation, the tool will generate some files in the directory that you have specified.

  1. Download the latest version of the command-line tool and unzip the archive.

  2. Execute the binary file via the command line by running:

    ./bin/ij-shared-indexes-tool-cli boost

    with the following options:

    • --ij: (mandatory) path to a locally installed IDE.

    • --project: (mandatory) path to the project for which you want to build shared indexes.

    • --port: port for running a local server. The default port is 25561.

    • --data-directory: directory for storing generated indexes and server data. The default directory is ./ij-shared-indexes-tool-data. You can use a server running locally or remotely or any S3-compatible storage to host these files for access.

    For example:

    ./bin/ij-shared-indexes-tool-cli boost --ij "/Users/jetbrains/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-1/232.8453.116/IntelliJ IDEA 2023.2 EAP.app" --project "/Users/jetbrains/IdeaProjects/spring-petclinic"
  3. Wait for some time. After that, you will see the indexing time with shared indexes and without them.

    Estimated indexing time

By looking at the difference in time, you can decide whether you want to use shared project indexes in your workflow or not.

Generate indexes from the command line

Generate indexes and start a local server

Use these steps to generate indexes and start a local server to host the index files.

  1. Download the latest version of the command-line tool and unzip the archive.

  2. Execute the binary file via the command line by running:

    ./bin/ij-shared-indexes-tool-cli indexes-server

    with the following options:

    • --ij: (mandatory) path to a locally installed IDE.

    • --project: (mandatory) path to the project for which you want to build shared indexes.

    • --port: port for running a local server. The default port is 25561.

    • --data-directory: directory for storing generated indexes and server data. The default directory is ./ij-shared-indexes-tool-data. You can use a server running locally or remotely or any S3-compatible storage to host these files for access.

    For example:

    ./bin/ij-shared-indexes-tool-cli indexes-server --ij "/Users/jetbrains/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-1/232.8453.116/IntelliJ IDEA 2023.2 EAP.app" --project "/Users/jetbrains/IdeaProjects/spring-petclinic"
  3. Once the project indexes have been generated, you will see a message with the information required to configure shared indexes in your project.

    Shared indexes are generated

After the tool has finished running, two folders appear in the directory that you have specified when generating index files: server and temp. The index files are stored within the server directory.

Generate indexes without running a server

Use these steps to generate index files without starting a local server. In this case, you will need to upload the files to a file server or S3-compatible storage after the indexes have been generated.

  1. Download the latest version of the command-line tool and unzip the archive.

  2. Execute the binary file via the command line by running:

    ./bin/ij-shared-indexes-tool-cli indexes

    with the following options:

    • --ij: (mandatory) path to a locally installed IDE.

    • --project: (mandatory) path to the project for which you want to build shared indexes.

    • --base-url: (mandatory) URL for storing indexes on the server.

    • --data-directory: directory for storing generated indexes and server data. The default directory is ./ij-shared-indexes-tool-data. You can use a server running locally or remotely or any S3-compatible storage to host these files for access.

    For example:

    ./bin/ij-shared-indexes-tool-cli indexes --ij "/Users/jetbrains/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-1/232.8453.116/IntelliJ IDEA 2023.2 EAP.app" --project "/Users/jetbrains/IdeaProjects/spring-petclinic" --base-url "http://your-aws-bucket.s3-website.eu-north-1.amazonaws.com"
  3. Once the project indexes have been generated, you will see a message with the information required to configure shared indexes in your project.

    Shared indexes are generated

After the tool has finished running, two folders appear in the directory that you have specified when generating index files: server and temp. The index files are stored within the server directory.

Other commands that you can run:

version

Displays shared indexes version information. Options:

  • --ij: (mandatory) path to a locally installed IDE.

server

Starts a server on local indexes. Options:

  • --port: port for running a local server. The default port is 25561.

  • --server-directory: directory for server data. The default directory is ./ij-shared-indexes-tool-data/server.

You can keep using shared indexes from the command line. In more complex scenarios, you can customize sample scripts from the IntelliJ Shared Indexes Tool Example repository.

Upload files to the storage

After the tool has finished running, two folders appear in the directory that you have specified when generating index files: server and temp. The index files are stored within the server directory.

  • Upload the data and the project folders from the server directory to your file server or S3-compatible storage.

Configure access to shared indexes

Once the project indexes are uploaded to the file storage, they can be downloaded and applied on another computer.

  1. In the project directory, create a new file intellij.yaml and copy the information from the terminal to the new file, for example:

    YAML file with shared indexes

    In the default configuration, the IDE will be downloading shared indexes automatically. You can confirm every download manually.

  2. Restart your project.

Project indexes will be downloaded to index/shared_indexes in the IDE system directory.

When the indexes are being downloaded, the progress is displayed in the status bar.

Downloading shared indexes

When everything is ready, you will see a corresponding notification in the Notifications tool window.

Shared indexes are downloaded

Change the way indexes are downloaded

In the default configuration, the IDE will be downloading shared indexes automatically. You can confirm every download manually.

  1. From the intellij.yaml file, remove the consents section and restart your project.

  2. In the Settings dialog (Ctrl+Alt+S) , select Tools | Shared Indexes and in the Project Shared Indexes area, select Ask before download.

    Configuring options for downloading shared indexes
  3. Apply the changes and close the dialog.

Last modified: 19 March 2024