views:

451

answers:

2

Concrete use case: In the Eclipse IDE, new 'plugins' can be added by copying a plugin's file(s) into the $ECLIPSE_HOME/plugins directory. However, I want to keep my original Eclipse installation 'clean' without additional plugins because I want to run this basic installation on its own at times.

What is a way of avoiding having to copy the files (and hence therefore not being able to run a clean version) and instead logically 'overlaying' the contents of another directory so that it appears to be in the directory at runtime?

e.g. something like:

gravelld@gravelld-laptop:~$ ls $ECLIPSE_HOME/plugins/
org.junit_3.8.2.v200706111738
org.junit4_4.3.1
org.junit.source_3.8.2.v200706111738
gravelld@gravelld-laptop:~$ ls myplugins/
org.dangravell.myplugin.jar
gravelld@gravelld-laptop:~$ overlay myplugins/ $ECLIPSE_HOME/plugins
gravelld@gravelld-laptop:~$ ls $ECLIPSE_HOME/plugins/
org.dangravell.myplugin.jar
org.junit_3.8.2.v200706111738
org.junit4_4.3.1
org.junit.source_3.8.2.v200706111738

Another use case may be around patching and so on...

Can something be done with symbolic links or mnt for this?

Thanks!

+1  A: 

Have a look at Manage your eclipse environment article, especially the Method 3

Creating a links folder to manage product extensions

If you have product extensions sitting on your file system, like the one we made in Method 1, you can create a few simple files in your Eclipse program directory to notify Eclipse that it needs to check these directories for plug-ins.

First, create a directory inside your Eclipse installation folder (for example, /opt/eclipse) called links. Within this folder, you can create *.link files (for example, emfPlugins.link). Each link file points to a product extension location. Eclipse will scan this links folder on startup and find the plug-ins in each product extension pointed to by a link file.

This is still supported in eclipse3.4 even though the new p2 provisioning system is quite different.


Now that the "'links' directory mechanism" is known, it means the difference between a vanilla eclipse and an eclipse with custom common plugins is just the presence of that 'links' directory.

So, why not have a 'vanilla eclipse distribution' with a symbolic link inside, 'links', pointing to ../links ?

Any user getting that vanilla eclipse would have at first no 'links' directory alongside it, so it will run as a vanilla distribution. But as soon the user creates a links directory or make another symbolic link to a common remote 'links' directory, that same distribution will pick up the common plugins remote directory...

/path/links -> /remote/links/commonPlugins
/eclipse/links -> ../links


Finally, if you create the "/remote/links/commonPlugins" with a given group "aGroup", and protect it with a '750' mask, you have yourself one eclipse setup which will be:

  • vanilla eclipse for any user whom 'id -a' does not include 'aGroup'
  • eclipse with plugins for any user part of "aGroup"
VonC
Look interesting, but I was thinking that this was possible to do in Linux in a way that is transparent to Eclipse or any other application viewing the filesystem (hence the lack of an 'eclipse' tag). It seems the way you describe would be a pain to change when I want the 'vanilla' Eclipse.
a vanilla eclipse is just a 'links' directory away of an eclipse with common custom plugin. I.e., remove the 'links' directory, and you get back a vanilla eclipse
VonC
Ok, but what happens if I want to run two instances at the same time, one vanilla, and one with the plugins? Given Eclipse's lazy loading would the behaviour be non deterministic... e.g. if the former is loaded first, the link created and then the latter, might the former see the link directory?
nope, if you create link after the startup of first (vanilla) eclipse, only the second eclipse will detect plugins. The first will remain vanilla until shutdown. You can also create the remote plugin dir with a read-only attribute for a given group, and launch any vanilla session from another group!
VonC
A: 

You could use an overlay filesystem for this. The three overlay filesystems that I know of in Linux are unionfs, aufs, and minifo.

Unionfs is included in recent Ubuntu kernels.

Rob Adams