How to use a Dropbox folder for eclipse projects
Bear Giles | September 8, 2010Dropbox is a service that lets you synchronize files between systems and even a web interface. If you’re willing and able to install the application on your work system it’s a clean way to share files between home and office. One obvious drawback is that you need to be careful about what you put into the folder. Resume? check. Pictures of the family? check. Pictures of the family at the nude beach? not such a great idea.
Sounds like a great place to put your eclipse projects. It’s a regular folder during the day but accessible from home. It turns out there are some pretty important details.
First attempt: create an eclipse workspace under ~/Dropbox and… sproing. Not such a great idea – eclipse keeps some logs that can’t be synced by dropbox if they’re updated simultaneously by two eclipse instances (think work and home). It barfed so bad that I had to nuke my workspace.
Second attempt: create an eclipse workspace in the usual place and link it to an external source folder under ~/Dropbox. You have to create a buck-naked project and add all of the natures (java, maven, etc.) to it explicitly and/or manually. (I just updated .project and .classpath with values from an existing project.) It works great, you can bounce between systems without incident… until you log into your old linux box with a fairly small /home partition. 100% disk usage.
It turns out that the linux dropbox client keeps some sort of database about changes. The Windows (and other) clients probably keep a database as well. That’s not a big deal if your dropbox contains a copy of your resume and a few family pictures but is a killer if it is continuously rebuilding even a trivial spring-enabled webapp. In a day or two I had pumped gigabytes of data into that file. Oops. A 500 GB partition will delay the inevitable but at some point you’ll run out of disk space. And really piss off dropbox.com because of your heavy network usage.
Third attempt: create a dropbox-workspaces-target under my home directory (Linux) and my /Users/me folder (NOT under My Documents!). This folder is on my local hard disk. I then set it as my output directory in my pom.xml file:
- <build>
- <directory>${user.home}/dropbox-workspaces-target/${project.artifactId}/target</directory>
- <outputDirectory>${user.home}/dropbox-workspaces-target/${project.artifactId}/classes</outputDirectory>
- <testOutputDirectory>${user.home}/dropbox-workspaces-target/${project.artifactId}/test-classes</testOutputDirectory>
- </build>
<build> <directory>${user.home}/dropbox-workspaces-target/${project.artifactId}/target</directory> <outputDirectory>${user.home}/dropbox-workspaces-target/${project.artifactId}/classes</outputDirectory> <testOutputDirectory>${user.home}/dropbox-workspaces-target/${project.artifactId}/test-classes</testOutputDirectory> </build>
That fixes the problem for maven. The native eclipse build still puts the files under dropbox but that’s also configurable.
Hi. I’m a Dropbox user, on a free account with about 8GB, 60% used. I’m considering syncing some of my Eclipse projects to Dropbox, mainly as a backup, but also possibly for work on other PCs. I use Ubuntu 10.10 on my main PC and Windows7 on the other.
I was planning to put the Eclipse project folder in Dropbox, as per your Second Attempt. It would seem a good approach. My Ubuntu set up is a single main partition, including /home, with plenty of space.
In your description of the problem with your Second Attempt, you mention the changes log maintained by Dropbox. Is this on their website?
I do wonder whether it’s wise to use something like Dropbox to sync a dev environment that is frequently generating new versions of build files. There would be a lot of updates. My alternative plan is to periodically (maybe manually) create a ZIP archive of my Eclipse project and copy this to Dropbox, keeping the actual project folder outside of Dropbox.
I’d be interested in your thoughts on this and to hear how you are getting on with your own Dropbox Eclipse set up.
–Thomas.
In your home directory there is a .dropbox directory. It seems to have a copy of every variation of your files, at least for some period of time. This folder can grow to a fairly substantial size if you make a lot of frequent changes. It’s something you don’t notice on newer systems but I also have Dropbox installed on my netbook with a whole 16 GB disk (including Windows XP installation) and an older Linux system with a smaller disk and a nearly full /home partition and they were so overwhelmed that I had to uninstall Dropbox, delete the directory, and reinstall.
The other issue is the network traffic involved. The dropbox daemon sends a copy of every changed file to the server (where you’re working) and pulls it down from the server (on all other systems where you have dropbox running) so your network usage can really add up. That’s a good use of network resources if you’re creating new content, e.g., editing source files, but your class files can be regenerated at any time from your source files – there’s no real gain in distributing them to other dropbox instances. That’s the other concern I had when putting all of my class files in a different directory.
Thanks for the extra info. As my main concern is backup, I’ll probably resort to periodic ZIP archiving and put this in Dropbox or Google Docs.
Alternatively, I’m using Git locally (I’m new to Git) with Egit in Eclipse, so I might try pushing my code to GitHub as a backup.