Can Someone Help With These Eclipse Files?

Is anyone familar with the format of the files in .metadata/.plugins/org.eclipse.core.resources/.projects in the workspace of Eclipse 3.0? I have an Ant task that uses the .classpath file of a project, along with the JDT preferences to build an Ant classpath for a project with an external build file, and I’m now trying to support projects that depend on other projects. I can see from the .classpath file which projects are referenced, either as a “src” type or a “lib” type, depending on how you added it, but I need to actually FIND those projects and get their build info.

I poked around in my workspace and discovered the directory I mentioned above. For each project that Eclipse knows about there is a subdirectory for it. Inside each subdirectory is a file called .location. I can see by looking at this file with a hex editor, that it does indeed contain the full path to the project. But it’s a binary file, and I don’t know the format. Is it documented anywhere?

I also did a little poking around the Eclipse API. I found a ResourcePlugin which sounded useful, but experiments from within Jython were fruitless. I would also like to avoid hooking into the Eclipse API since I’m trying to support multiple versions of Eclipse, but if that’s the only way to get to the data, I’ll do it.

The question, then, can be broken down into three subparts:

  1. Does anyone know the file formats?
  2. Does anyone have a code snippet of using the proper Eclipse API outside of Eclipse to get to the info in those files?
  3. Does anyone have a better solution to this problem?

Since I’ve taken down the writeback feature of this blog, thanks to certain miscreants, if you have a suggestion, please email it to Thanks.

Free Eclipse Classpath Ant Task

This software is no longer supported! I have neither used nor updated this software since I originally posted it, back in 2004. You are welcome to both the binary and source versions, but I no longer do anything with it or support it. If you need something changed, you will have to do it yourself, using the source. Sorry, but after I released it, I realized how little I really needed it, and thus stopped using it.

I’ve just released version 1.0 of a free Ant custom task to make it a little easier to work on a project using both Ant and Eclipse. What this task does is read the .classpath file that Eclipse uses to maintain your project’s classpath, combines that with your Eclipse preferences to expand classpath variables and then creates a path-like structure in your Ant project that you can compile against.

I wrote this because I use Eclipse and I always also have a build file. Keeping the two in sync, classpath-wise, was always a hassle. Now I can simply update the classpath inside Eclipse, and whenever I do an Ant build it will automatically be in sync.

I wrote it against Eclipse 3.0 M8 originally. Then I upgraded to M9 and it stopped working. So with a bit of futzing about, I got it to work with both 3.0 versions and 2.1.3, all three of which keep the preferences file in completely different places with completely different names. But that’s taken care of now. I have also tested on both WindowsXP and Linux, but more on XP than Linux.

To use it, drop the jar file (plus jdom.jar if you don’t already have it) in ANT_HOME/lib. Then taskdef the task

  <taskdef resource="com/joeygibson/ant/"/>  

Then call the task. There are several optional attributes, but if you want the classpath to end up in a path called “classpath”, then you can probably get by with just this

  <eclipsecp workspace="/home/me/workspace"/>  

If you are on Windows, and using Eclipse 3.0 M8 or later and you keep your workspace in C:/Eclipse/workspace then you don’t even have to do that much. You can get by with


Once you’ve executed the task, just reference the newly-created path from your javac task or anything else that takes a path as an argument.

You can read more about it in the README.txt

I’ve got several downloadable versions available, in both zip and tar.gz formats, with and without source, and with and without jdom.jar. If you use it and like it/don’t like it/have suggestions, please let me know.

Binary only
Binary w/ JDOM
Source only

I’ve heard there are other tools out there that do this, but I didn’t find them, so I wrote my own. Please email me with any comments you have about it.

Die Spammers, DIE!!!

I want to personally thank all you worthless pieces of human filth that keep vandalizing my website with your childish “ads” for prescription drugs, pr0n and gambling. Because of this pathetic, sophomoric shits-and-giggles-fest of yours, I’ve had to take down my comment system again! Because you have nothing better to do than deface other people’s property, attempting to raise your Google page rank, I have to change MY website. I hope you worthless little shit-pigs eventually get to spend several years in some sleazy Southern county jail being the bitch for some really pissed-off biker dude named “Doris”… Even that is too good for you. Bastards.