167

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.

1

6 Answers 6

202

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.

14
  • 2
    "you might want to consider using source control branches for app versions rather than separate projects" How does that work? I'm concerned that 20x source files will make Intellij run slower. Does it only consider one at a time? Jul 8, 2014 at 22:12
  • 3
    @tieTYT Yes. How a source control branch works is that it edits all your local files to match the branch. Then you switch branches, it does it again. You end up having less space used in your local file system. Heres a good read for you: git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging Jul 8, 2014 at 22:14
  • 3
    @tieTYT Basically, you only have one branch existing on your local machine at a time. When you want to work on another version, the source control changes it to that version for you. You wont have "20x source files" because you only have 1x at a time. Jul 8, 2014 at 22:15
  • 4
    @jay you could always add the file to no be excluded in your .gitignore. !.idea/runConfidurations/name Sep 26, 2016 at 21:58
  • 2
    btw, .idea/runConfigurations/ is only created when OK is clicked. Apr 19, 2017 at 18:54
47

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!

3
  • This rules, its exactly what I wanted to know, because indeed we were ignoring .idea and there was no way to unignore it without big headaches.
    – David Mann
    Jan 29, 2019 at 21:56
  • Awesome! This is what I was looking for a long time. Jul 3, 2019 at 14:55
  • 2
    For my team, putting the Run configurations in the VCS is not an option. The Run configurations contain values - such as paths - that differ between users. What I need is sharing the Run configurations among my own projects, not among team members. Sep 18, 2019 at 7:53
22

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

1
  • I think you have to check Share first like Humdinger said Jul 8, 2014 at 22:09
14

You should copy the folder

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

to

~/your-new-project/.idea/

That's the folder that contains the run configurations.

1
  • 6
    I believe you need to set them to "share" first as elaborated in the accepted answer.
    – Muhd
    May 23, 2017 at 3:17
11

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

3
  • 2
    How to import the xml in a new project? Nov 26, 2021 at 9:20
  • 3
    @MehulParmar cp <old_project>/.run -R <new_project>/.run Mar 24, 2022 at 23:25
  • Open Left Project Pane -> Copy .run folder -> open another project without closing intellij -> Paste on main project level. Your previously saved run config appears here. Jun 4, 2022 at 6:55
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.