Do you need to keep your code under source/revision control with a solution like Git, Subversion (SVN), Mercurial? Are you using an Eclipse-based IDE like xTIMEcomposer (XMOS) or Code Composer Studio (Texas Instruments) and hate all the /.metadata
junk that should stay far away from your precous code?
That's exactly what I wanted. I literally wanted just my code sitting under version control (SVN in my case) and I needed to be able to pull and build that code on multiple machines. Putting your entire workspace folder under version control is a really bad idea (I tried it) because it's got a bunch of junk created by Eclipse that you never wanted. It also isn't portable. Making a pull on a new machine results in a bunch of Eclipse errors.
This was my answer to my own question I posted/asked on the XMOS forums. The original post is here. I did have to compromize and leave the .project
and .cproject
files alongside the code, but I personally am fine with that.
Let's get started.
Starting with a full workspace of XMOS lib_* folders and my own project, I did the following...
- Clean the workspace to remove unnecessary files from the workspace
- Project > Clean
- Select "Clean all projects"
- Uncheck "Start build immediately", otherwise it will re-create the files we are trying to remove.
- Click "OK"
- Export all projects and libraries in workspace to my local (working copy) SVN dir
- File > Export > File System
- Select All
- Navigate to my SVN dir in "To directory"
- Choose "Create only selected directories"
- Finish
- Close xTIMEcomposer
- Manually copy and paste workspace folder somewhere temporary (just so you don't lose any code along the way)
- Make a new workspace (or simply empty out the old one if you like it's location on your computer)
- Open xTIMEcomposer
- If you changed the workspace location, do this. Otherwise skip these steps
- File > Switch Workspace > Other
- Navigate to the new workspace folder
- xTIMEcomposer will restart in the new workspace
- Link (but don't copy) projects and libraries from SVN dir into workspace
- File > Import > General > Existing Projects into Workspace
- Choose "Select root directory"
- Click "Browse" and navigate to the SVN dir where your projects and libraries were exported
- Click "Select All" to choose all projects and libraries
- Make sure "Copy projects into workspace" is not checked
- Finish
Now if you use your computer's normal file manager (Windows = File manager, Mac = "Finder", etc...) and navigate to the [new] workspace location, you should only see a /.metadata
directory. There should be no projects or libraries. If I make changes to, say, main.xc
, my SVN client will notice the changes, but none of the workspace-specific files (i.e. the whole /.metadata
directory madness) are tracked.
On any new machine, after I checkout my SVN repo, (assuming a clean/empty workspace folder) I simply have to run through the Import operation (Step 8), being careful to make sure the "copy" option is unchecked, and I should be good to go. For any new libraries or projects I make, I can choose to create them inside the SVN dir, instead of the workspace. This results in the same behavior as above where the files are linked to but not inside of the workspace folder.
✅ No Eclipse settings
✅ No Eclipse addons
✅ Works across machines
✅ Happiness
Since this has nothing to do with SVN in particular, but rather the separation of my code from the workspace folder, this should work fine for Git, Mercurial, or whatever else you feel like using.
Hope this helps.