How to share run configurations in IntelliJ IDEA

Apr 03, 2020
How to share run configurations in IntelliJ IDEA
Finally, with IDEA 2020.1, you can easily share your run configurations among your team members utilizing version control.

IDEA settings sharing

When developing in a team, it is vital to stick to a common set of practices to keep consistency in the development process. Having your IDE configured in the similar way can greatly help you with this. Fortunately, IDEA offers several ways of settings sharing, which can be very useful in such situations. It can be also beneficial for individuals when working with multiple machines. You can read more about it in the following article:

IntelliJ IDEA Tips: Synchronization and Sharing of Settings

IntelliJ IDEA Tips: Synchronization and Sharing of Settings
Did you know IDEA offers two ways of synchronization of you settings among multiple instances of your IDE? You can use it when working on multiple computers or to share unified settings in your team.

Run configuration sharing

You can see your Run Configurations of top of the IDE window next to Run and Debug buttons.

IDEA Run Configurations location

A configuration can be as simple as running your project. You can have one for running tests, deploying to an application server, or various others. Configurations can get more complicated as you introduce more settings such as environmental variables, command-line arguments, VM options, and much more.

In the case of these more complicated configs, it is vital to be able to share them with your team, so they can use the app right after cloning with no advanced setup. Not only is it useful for simplification of the initial setup, but it can also help to ensure that everybody is running with the same settings.

To edit individual configurations, you can hit double Shift and then search for Edit Configurations....

Default behavior

The default behavior of IDEA run configurations is not very sharing-friendly. All your run configs are shared in .idea/workspace.xml.

This is problematic as the file also contains a lot of user-specific information, so it is not really suitable for sharing among team members. As a result the whole .idea folder usually ends up in .gitignore file.

Share through VCS

As a result, IDEA later introduced the concept of sharing your run configuration through VCS.

This is configured per each configuration so that you can have both your personal and shared configurations at the same time.

IDEA share run config through VCS

It works in a way that it stores your shared run configurations in .idea/runConfigurations. Each configuration has its own separate file. This is better, but still not ideal. Ignoring the whole .idea dir does not work anymore, and you need to have more complicated config to ignore everything except the run configs directory. Otherwise, it won't work.

IDEA share run config through VCS ignored folder

Store project file

In version 2020.1, you can now easily store run configurations as external files, not necessarily under .idea directory.

This replaces the old Share through VCS option. For backward compatibility with older IDE versions, you can still store your files under .idea/runConfigurations.

IDEA Save Run configuration as project file

You can check an example of stored run configuration file.

Importing configuration

When creating a new project, IDEA can usually pick up your configurations easily when stored inside .idea/runConfigurations. When using a different location, it can have trouble. You can still add these configurations manually, fortunately.

Just go to Add configuration... (Or Edit Configurations...) and you should see your stored configs in the list. From there, you can easily add them as usual.

Manually adding IDEA run configurations

Summary

Sharing run configurations can greatly simplify your project setup and ensure consistency among your team members. For even better results, consider combining it with general IDEA settings sharing.




Let's connect