Mac OS, IntelliJ IDEA 14 on JDK 1.7 with SVN and GIT

00311910_medium

This time I’ve decided to write a bit more on the whole “setting up the dev environment on Mac OS” thing. Primarily, I’m going to focus on setting up IntelliJ IDEA running on JDK 1.7 with SVN and GIT as version control system of choice. (BTW I’ve recently wrote IntelliJ IDEA 13 on MacOS with JDK 1.7 but that post only touched a one of the problems I faced and that solution didn’t last long.)

So, Problem #1 you are going to face if you’ve got JDK 1.7 installed on your Mac(and since JDK 1.7 is target platform for any code I write these days, it’s quite reasonable to have it installed on my dev machine as well) and would like to start IntelliJ IDEA is that IDEA is by default packaged in a way that it only can be started on JDK1.6.

The solution to this problem that is suggested by many on the web is that you have to edit /Applications/IntelliJ\ IDEA\ 14.app/Contents/Info.plist and change JVMVersion from 1.6* to 1.7*. This will allow you to start the IDE but by altering a file inside .app you are actually breaking a signature on the application and OS will not trust it henceforth.

A simple solution which may help with Mac OS being vigilant/paranoid consists of running the following single command in your terminal:

sudo codesign -f -s – /Applications/IntelliJ\ IDEA\ 13.app

So, again keeping the app signed with a valid signature is important because otherwise IDEA may not be able to work with other OS tools like Keychain. If the command I provided does not help and further on you face issues with IDEA not saving passwords for SVN, you may also try the solution mentioned in the comments here by Jeroen which requires generating a new cert and signing IDEA’s app with it.

Anyway, now after you’ve got your favorite IDE running, you might want to checkout/clone your code from SVN/GIT to work with it. I personally have found that both SVN and GIT clients that go along with Mac OS are somewhat outdated. This is why I suggest installing latest version using Homebrew which is a really awesome tool. After getting Homebrew and using it to install newest GIT/SVN clients you should be ready to proceed further down this article.

In case if you went with SVN, when you first use console client to access your remote repo, Keychain will allow you to save your user/password in it. Then next time when you checkout from your repo in console or do any task that requires authentication, Keychain will ask if you wish to let SVN access the password. You should click “Always Allow” in the dialog. This is needed if you wish IDEA to be able to get this password from keychain as well.

So, the key note here, is that you should first use console SVN(and GIT) client and make sure you are able to do checkout/pull before moving forward.

In your IntelliJ IDEA you should go into “Preferences -> Version Control -> Subversion” and you should set “Use command line client” and set it to “/usr/local/bin/svn“(this is actually what “which svn” should return to you if you run it in terminal).

All these steps are primarily needed if you want your IDEA to be able to work with the SVN repos without asking for user/password every time you restart it(which I find super annoying).

For GIT I suggest using the following settings: “Path to Git executable” should be set to “/usr/local/bin/git” and “SSH executable” should be chosen as “Native”. With these setting your IDEA should be able to rely to Mac OS built-in ssh-agent that is capable of using Keychain for storing pass-phases of your SSH keys besides agent built into IntelliJ will only try to use the first ssh key from your .ssh directory when you can have several(e.g. one for GitHub, one for BitBucket and one for accessing your Linux servers).

You can find extra info on working with SSH keys and Keychain here. The bottom line again is that you should first set things up in Terminal and then when you can run all your commands in console smoothly IDEA with the aforementioned settings should have no issues with accessing your repo.

So, the biggest benefit that I got out of figuring how to set all these settings is that now I do not need to enter passwords/pass-phases/master-passwords every time I try to pull/checkout new updates from remote repositories and at the same time I do not need to worry about my passwords stored in insecure way somewhere on disc. Good luck!