I actually Googled around first, and several people have tried putting an Eclipse workspace into Dropbox, but encountered a couple of problems:
- The additional hidden metadata Dropbox stores to keep track of changes and past version can grow out of hand pretty quickly on the binaries compiled by Eclipse. Also the network traffic ends up being very high. That’s on top of the space required for the binaries themselves, which could be critical if you’re using a free account.
- You can’t have some projects shared via Dropbox while others are local (e.g. work projects reside only on my work computer, personal projects are shared). You can switch workspaces, of course, but that’s a pain
The solution is to, for a given project, sync only the source files. Now, this does have the disadvantage that it requires a certain amount of setup on each computer that will be accessing the Eclipse project, but it lacks the problems above (and the first one can apparently be crippling).
- Create a directory for source files in your Dropbox folder. Something like “Dropbox\MyProject\source”
- Run New Java Project in Eclipse. Use your default workspace location. Make sure you have “Create separate folders for sources and class files”. Click Next (not Finish)
- Right-click that “src” file and choose “Remove from Build Path”. Then click the “Link Additional Source” (under Details, or the leftmost button fo the right-hand group at the top), and pick the source folder you created in your Dropbox. Go to the Libraries tab and add whatever libraries you need. The jars for user libraries shold probably be in your Dropbox too, just so you have them available.
- click Finish.
Now you can create classes, build (and the binaries will be in your local workspace), etc. The only files that will be synced will be your source code, which will save on bandwidth and space.
On another computer, you can boot up Eclipse, and create the Java project, using the Link Additional Source option again. You’ll find that if you make changes on one computer, you’ll probably have to Refresh the project and do a fresh build when you switch to the other computer, but that isn’t all that onerous.
Of course, technically you should be using real source control (Git, CVS, Subversion). But free hosting for a private project is hard to find, setting up a repository on your home box and then making it remotely accessible is a pain, and you have to do explicit commits and checkouts every time you switch computers. Plus good practice dictates that your project should at a minimum be in a buildable state every time you commit, which may not be possible if you haven’t tracked down that stray error at the end of the day… So with Dropbox you can work privately on multiple computers, set up a private source control repository at home and use proper SCC practices. Win-win.