Daniel Kaplan
Daniel Kaplan

Reputation: 67360

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

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.


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.

Upvotes: 184

Views: 91890

Answers (6)

cmlonder
cmlonder

Reputation: 2530

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 outside of ./idea

store as project

Upvotes: 21

Nick Humrich
Nick Humrich

Reputation: 15755

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.

Upvotes: 214

jwehrle
jwehrle

Reputation: 4774

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.

Upvotes: 0

Turgay Celik
Turgay Celik

Reputation: 663

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!

Upvotes: 49

de.la.ru
de.la.ru

Reputation: 3144

You should copy the folder

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

to

~/your-new-project/.idea/

That's the folder that contains the run configurations.

Upvotes: 14

Jigar Joshi
Jigar Joshi

Reputation: 240900

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

Upvotes: 24

Related Questions