How do I share IntelliJ Run/Debug configurations between projects?

Intellij Idea

Intellij Idea Problem Overview


I have many different versions of my app. Each one is a separate IntelliJ project. Every time I open a new one, the list of configurations starts blank:

enter image description here

The annoying thing about this is I deploy to 1 VM and I have to copy and paste the debug configurations each time I want to test a different version. IntelliJ makes this dialog modal per IntelliJ Instance, so I can't copy and paste the fields between Project Instances.

I end up taking a screenshot of one configuration and copying the fields by hand into the other project. It's a pretty primitive solution. Is there a more convenient way to get a run configuration from one project to another?

I'm using IntelliJ 13 on Windows 7.


https://stackoverflow.com/questions/5313946/can-i-share-settings-for-intellij-idea-across-different-projects may have the answer to this, but the question is different. It's about window layout. Therefore I don't consider it a duplicate.

Intellij Idea Solutions


Solution 1 - Intellij Idea

The best way to do this is to click the "share" checkmark next to Name field when you edit/create the configuration. You can get to this Dialog with Run > Edit Configurations.

enter image description here

The share check-mark pulls the setting out of your workspace.xml and instead puts it in the directory .idea\runConfigurations. This is designed so you can share the setting with others. You could copy this file and put it in the same location in all your idea projects.

However, in the future, you might want to consider using source control branches for app versions rather than separate projects. IntelliJ handles these very well.


UPDATE (June 2021): IntelliJ now puts this in the .run folder as its own file, no longer in .idea/runConfigurations.

Solution 2 - Intellij Idea

Run configurations are stored in .idea/workspace.xml by default. First alternative is to share this file but it is not feasible because you also share a lot of unnecessary configurations. As already said, the first step is to check "share" option to separate run configurations from workspace.xml.

dispatching run configurations from workspace.xml

After that, I recommend adding runConfigurations to source control. But the main problem is, probably you have already marked .idea folder as ignored. You can unignore the folder by configuring your source control system. For example, if you are using git, you can change .gitignore file as follows:

.idea/*
!/.idea/runConfigurations

don't forget adding * after .idea/

As the last step, add your run configurations to source control and enjoy your shared configurations!

Solution 3 - Intellij Idea

goto

Run > Edit Configuration > create or select existing configuration you want to use > click save and persist it on file system > click on share check mark

now copy this file from

 PROJECT_ROOT_DIRECTORY/.idea/runConfigurations/ConfigurationName.xml

to your NEW_PROJECT_ROOT_DIRECTORY/.idea/runConfigurations at the same place and it is available now to your run configuration

Solution 4 - Intellij Idea

You should copy the folder

~/your-old-project/.idea/runConfigurations 

to

~/your-new-project/.idea/

That's the folder that contains the run configurations.

Solution 5 - Intellij Idea

An update for this question with the new IntelliJ updates:

Now you can "Store as project file" which will create a folder named ".run" and export your setting to that folder. In the example below, I did it for all my test settings. This removes the requirement of editing .gitignore since files are now not outside of ./idea

store as project

Solution 6 - Intellij Idea

This is not exactly an answer to your question but it answers a question similar to your question and one that I had, and I'm assuming others might as well.

That is, How to save unit and instrumentation test run configurations? I usually right-click on the test directory which brings up a menu with the option to Run whatever is in that directory. AndroidStudio then creates a run configuration on the fly and in the Run Configuration drop-down menu a new option will appear, "Save new configuration?" or something similar.

Clicking that option brings up the Run Configuration menu and at that point I check the Share box as many others have already mentioned. This then will prompt the version control system to ask me if I want to add this new run configuration file. If you haven't registered your version control system you can find the new files under .idea/runConfigurations.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDaniel KaplanView Question on Stackoverflow
Solution 1 - Intellij IdeaNick HumrichView Answer on Stackoverflow
Solution 2 - Intellij IdeaTurgay CelikView Answer on Stackoverflow
Solution 3 - Intellij IdeajmjView Answer on Stackoverflow
Solution 4 - Intellij Ideade.la.ruView Answer on Stackoverflow
Solution 5 - Intellij IdeacmlonderView Answer on Stackoverflow
Solution 6 - Intellij IdeajwehrleView Answer on Stackoverflow