So for the longest time (a few months now), I had *not* been able to get Flex Builder to play nicely with version control. At Grooveshark we use Subversion.

First, naively, I tried just committing the whole project folder to the repo. Then I realized all the various hidden files that Eclipse makes (like .project, etc) would also be committed, and if any other developers also starting committing work, we’d break each others projects every time one of us updated after the other committed.

So then I committed only the /source folder where the actual code lives. However, then all the hidden .svn folders that SVN created showed up in the tree view of Flex Builder’s Navigator. I could ignore that, except it also completely broke Flex’s code hinting, Outline view said nothing but ! Root, and Design mode (which I almost never use, but still…) would say nothing but, “An unknown item is declared as the root of your MXML document. Switch to source mode to correct it.”

Looking up the Design mode error on Google found a lot of people mentioning it, but no real solutions, except really stupid stuff like, ‘delete all the whitespace in your code.’ (Which, when I tried it on a small test project, surprisingly did work, until you closed Flex Builder and opened it again. Then you’d have to delete all your whitespace all over again. Obviously, this is NOT a viable solution.)

The only solution I found that looked promising was to install Subclipse into Flex Builder, and create a new project by checking the code out from the repository. So I went about trying to install Subclipse.

At the time, I was using Flex Builder 2, for OS X. I’d never used Eclipse before I started using Flex Builder, and I have the stand-alone Flex Builder, not the Eclipse plugin. Everything I read about Subclipse seemed to imply that it required Tortoise SVN to work, which, as a Mac user, is obviously not an option. Now on the Subclipse site there is no mention of Tortoise. I don’t know if that’s something that’s changed in the past few months or not, cause I’m pretty sure I read all this on the official Subclipse site. Somewhere though, I remember reading that as long as I had the command-line svn client installed (I did) that it would still work for Mac.

I followed the instructions on the Subclipse site to install Subclipse, but whenever I got to the end, it would complain that I was missing some dependencies and that it could not install. I was not able to figure out exactly what dependencies I was missing, or where I could get them from, and I finally gave up.

I still needed version control, so instead I hacked together a little set of Automator scripts to help me get the job done. I had two copies of the /source folder for my Flex project: one was in the Flex project’s directory (~/Documents/Flex Builder 3/Grooveshark Lite/source), and one in a separate directory that I have the rest of our repo checked out into for local testing (/Applications/MAMP/htdocs/GS/trunk/flex/Grooveshark Lite/source). My Automator apps copy the files from one to the other and vice versa, dropping a numbered backup into a separate folder, just in case I screw up. Then I can commit my files using SmartSVN. I could have written a bash script to do the same thing, but Automator lets me add a pretty little confirmation box, just in case I hit one by accident.

They look a little something like this:

Copy Flex to SVN

Ask for Confirmation
tar -cvf /Users/krichard/Documents/Backups/FlexToSVN.tar --backup=numbered /Applications/MAMP/htdocs/GS/trunk/flex/Grooveshark\ Lite/
rsync -vrC --exclude=.DS_Store --delete /Users/krichard/Documents/Flex\ Builder\ 3/Grooveshark\ Lite/source/ /Applications/MAMP/htdocs/GS/trunk/flex/Grooveshark\ Lite/source/

Copy SVN to Flex

Ask for Confirmation (Twice! If I accidentally overwrite the SVN directory, I can just delete and re-check out. If I accidentally overwrite the Flex Builder directory, I've lost work. The backups prevent any real damage, but still...)
tar -cvf /Users/krichard/Documents/Backups/SVNToFlex.tar --backup=numbered /Users/krichard/Documents/Flex\ Builder\ 3/Grooveshark\ Lite/
rsync -vrC --exclude=.DS_Store --delete /Applications/MAMP/htdocs/GS/trunk/flex/Grooveshark\ Lite/source/ /Users/krichard/Documents/Flex\ Builder\ 3/Grooveshark\ Lite/source/

The nice part about using rsync is that the -C automatically excludes the .svn folders from being passed around. I’m also excluding the .DS_Store files that OS X likes to stick everywhere.

So fast forward a few months: I’d switched from Flex Builder 2 to Flex Builder 3, and was still using my Automator scripts. Today I was setting up Subversion on my Slice for a personal project I’m about to start working on. I *really* didn’t feel like writing another set of Automator scripts for this new project, especially as sometimes I’ll be working on it on my off hours at the office (so I can use the huge widescreen monitor), and sometimes just at home on my iBook. So I decided to give Flex Builder and SVN another shot.

Well, I still had all the same problems. However, this time my searching came up with a link to this article. I noticed the screenshots were obviously OS X, not Windows, and felt a sliver of hope.

I followed the instructions, and no errors this time! No complaining about dependencies. Everything installed just fine. I’m not sure what to attribute to the difference in my experience from a couple months ago. Is it a new version of Subclipse? Is it because I had Flex Builder 3 instead of 2? Were these instructions just flat out better than the ones I read before on Subclipse’s own site?

So now I had Subclipse installed. Getting to the import process was slightly different than in the given instructions, I assume because I’m using the stand-alone Flex Builder and not the plugin. Instead of just choosing File -> Import -> Checkout projects from SVN, I had to choose File -> Import -> Other -> Other (Yes, that’s two Others, not a typo) -> Checkout projects from SVN.

And… it worked! It checked out my folders, and I was able to commit changes with no problems. My code hinting still works. I backed up my Grooveshark Lite files, deleted the project, and checked it out as a new project from the Grooveshark repo too. Everything in that project is working fine as well. Bye-bye Automator scripts!

So for anyone out there who has tried in vain to get Flex Builder working with Subclipse on OS X, try the instructions at http://www-128.ibm.com/developerworks/opensource/library/os-ecl-subversion/ with Flex Builder 3. Hopefully you’ll be as pleasantly surprised as I was.

7 Responses to “FINALLY got Flex Builder and SVN to play nice”

  1. chanel Says:

    pretty nifty hack. im really glad cause i can check out that repository and study all of your flex kung fu. keep up the amazing work

  2. Shanimal Says:

    Dude TY – I needed that.

  3. Katy Richard Says:

    No problem, glad I could help :)

  4. Xavier Says:

    I second that: much needed, appreciate your post!

    I haven’t found any good tutorials on ‘best practices’ with SVN for Flex Builder 3 development. If I succeed in capturing the Adobe Connect screenshare among our development team, I will post that link here.

  5. Simon Says:

    I, too, struggled with installing SVN support into Flex Builder 3 and used your scripts for a while. Until I got fed up and wrestled with FB for a good hour to install Subversive. The download servers were slow, so I grabbed the tar archive from a mirror server and installed from there. FB’s automatic software update install thingy offered a multitude of stuff to be installed alongside Subversive, I deselected everything but Subversive itself and the SVNKit 1.1.7 connector (apparently, Subversive needs external libraries to actually talk to SVN…). Once it’s installed, just make yure you don’t try to import a working copy you have in your filesystem somewhere, but to use Import > SVN > Project from SVN (which checks out a new working copy directly from the repos).

    Cheers, Simon

  6. dave Says:

    @simon

    Import > SVN > Project from SVN does not exit, you moron

  7. Robert Says:

    Thanks. Works like a charm.

Leave a Reply