174

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.

Pang
  • 9,564
  • 146
  • 81
  • 122
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
  • See also [Sharing IntelliJ IDEA default run configurations and params](https://stackoverflow.com/questions/43916252/save-default-run-configurations-in-in-the-repo-for-intellij) – Vadzim Nov 27 '17 at 16:39

6 Answers6

206

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.

Nick Humrich
  • 14,905
  • 8
  • 62
  • 85
  • 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? – Daniel Kaplan Jul 08 '14 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: http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging – Nick Humrich Jul 08 '14 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. – Nick Humrich Jul 08 '14 at 22:15
  • Ah, well at work we use SVN. That being said I am using the Git-SVN bridge locally. I have never switched to a different SVN branch from it though. I guess I'll give it a shot. – Daniel Kaplan Jul 08 '14 at 22:20
  • The annoying thing is that intellij puts these shared launch configurations under the .idea folder. Normally i setup .gitignore to ignore the .idea folder. It would be nice if you could configure where these shared launches were stored – Jay Sep 26 '16 at 12:45
  • 4
    @jay you could always add the file to no be excluded in your .gitignore. `!.idea/runConfidurations/name` – Nick Humrich Sep 26 '16 at 21:58
  • 2
    btw, `.idea/runConfigurations/` is only created when OK is clicked. – Martin Tapp Apr 19 '17 at 18:54
  • 1
    There is nothing new yet on this issue, right? It annoys the hell out of me, not being able to shre the "configurations" easily inside the IDE - I don't want to copy some files from here to there. I work with several different projects, and every month or so there comes a new one. And every time I need to copy / recreate these configurations. Why isn't there a "global default configurations" available? I want to set a default remote debugger, and I want to set the default code coverage settings...... – BAERUS Aug 09 '17 at 09:04
  • @NickHumrick It's not uncommon to work on multiple branches at a time, especially when some are minor, and there's obviously the case of reviews (PR / CR) where you switch branches all the time. IntelliJ may index those files rather quickly, but the incremental compiler may not deal with it very well (especially with Scala). It also requires a lot of mental context-switches which are sometimes confusing. There are also times of huge merges where it's just easier having one branch on a side-repo to look at. So yeah, I often work with 2 repos of the same project simultaneously, sometimes even 3. – Eyal Roth Apr 15 '18 at 19:57
  • 2
    I had to re-open the project to get them to show up. – vaughan Nov 02 '18 at 20:05
  • 1
    `.idea/runConfigurations`: I cannot find anything like that. – logbasex Aug 26 '20 at 09:23
  • “However, in the future, you might want to consider using source control branches for app versions rather than separate projects.”—we have now come full circle with git-worktrees(1). Very convenient when you have to do very different things (like deploy the stable code on one worktree while working on a new feature on another). – Guildenstern Oct 09 '21 at 10:04
  • 1
    I have a xml. I want to import it in a new project. How to do it? – Mehul Parmar Nov 26 '21 at 11:55
  • 2
    I think it was renamed to Store as project file. It shows where the configuration file is stored afterwards. I needed to restart pycharm to make it work. – Natan Dec 20 '22 at 08:09
48

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!

Community
  • 1
  • 1
Turgay Celik
  • 651
  • 5
  • 11
  • 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 '19 at 21:56
  • Awesome! This is what I was looking for a long time. – Jonas Gröger Jul 03 '19 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. – Ivan dal Bosco Sep 18 '19 at 07: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

jmj
  • 237,923
  • 42
  • 401
  • 438
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.

de.la.ru
  • 2,994
  • 1
  • 27
  • 32
  • 6
    I believe you need to set them to "share" first as elaborated in the accepted answer. – Muhd May 23 '17 at 03:17
14

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

Pang
  • 9,564
  • 146
  • 81
  • 122
cmlonder
  • 2,370
  • 23
  • 35
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.

jwehrle
  • 4,414
  • 1
  • 17
  • 13