[Edit on 2011/01/02: Updated path '/usr/local/' to '/opt/' and corrected some glitches.]
This is useful if you want to keep the plugin directory apart from the Eclipse installation directory. This allows you to have several installations of Eclipse using the same plugins, and also alleviates switching to a new version without going through the hassle of installing all the plugins again.
I assume you already have installed Java.
This HowTo comes in four parts:
1. Installation of Eclipse
2. How to configure and use a central plugin directory
3. How to avoid remembering unnecessary command line stuff
4. How to share manually downloaded plugins
1. Installation of Eclipse
As the Eclipse version in the repository is outdated, we install Eclipse manually. Download the version you prefer from the official website, untar it and move it to '/opt':
Code:
$ sudo mv eclipse-xy /opt/
Actually, I prefer to have a directory structure like
Code:
/opt/eclipse-3.5-galileo
/opt/eclipse-3.6-helios
and so on for different versions, but that's up to you. For simplicity, everything below assumes you chose '/opt/eclipse-xy' (where 'eclipse-xy' stands for the actual version) as the program directory.
Assuming you didn't change the directory name like I did, we care for the permissions:
Code:
$ cd /opt
$ sudo chown -R root:users eclipse-xy
$ sudo chmod -R +r eclipse-xy
$ sudo chmod -R g+w eclipse-xy
$ sudo chmod +x `sudo find eclipse-xy -type d`
Once we are doing directory stuff, we also prepare the central plugin directory and in the 'real' eclipse installation directory another directory which will be used for the links to the central plugin directory:
Code:
$ sudo mkdir -p eclipse/extensions
$ sudo mkdir eclipse-xy/links
As we want to be able to write to these directories as a normal user, we have to do two things. First, change the group the directory is belonging to and also it's permissions:
Code:
$ sudo chgrp users eclipse-xy/links
$ sudo chmod 2775 eclipse-xy/links
$ sudo chgrp users eclipse/extensions
$ sudo chmod 2775 eclipse/extensions
You might not have seen a permission setting like 2775 yet. The "2" simply says that all files which will be put into that directory will have the same group like the directory - not the one of the user as normally.
Second thing to do is adding the user(s) who shall be able to install plugins to the group "users".
Code:
$ sudo vim /etc/group
Look for the line with group users. Afterwards, it should look like this:
Code:
users:x:100:my_user
Now we need an executable in the PATH:
Save this
Code:
#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse-xy"
$ECLIPSE_HOME/eclipse $*
as '/opt/eclipse/bin/eclipse-xy'
and make it executable:
Code:
$ sudo chmod +x /opt/eclipse/bin/eclipse-xy
If you have multiple Eclipse installations, you simply save different bash scripts like /opt/eclipse/bin/eclipse-1, /opt/eclipse/bin/eclipse-2, or whatever, with the different appropriate paths to the Eclipse executables.
Finally an (or multiple) application starter(s):
Code:
$ sudo vim /usr/share/applications/eclipse.desktop
with this content:
Code:
[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/eclipse.svg
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true
As you can see, there is a path to an icon. As Eclipse doesn't seem to provide an icon anymore, I searched the net and simply downloaded the icon. Don't remember now where I got it from. As I have my different Eclipse installations in subdirectories, as described above, having the icon in the central super directory is convenient, so it can be used for all the different application starters.
Before I go on I have to give credits to Ivar Abrahamsen, who described most of the manual installation process on this site.
2. How to configure and use a central plugin directory
This time I will give the credits first because I don't feel like repeating what Michael Scharf wrote in his blog. It boils down to starting Eclipse with a parameter each time you want to install a plugin. This requires some discipline, because you shouldn't install two plugins during the same run of Eclipse, as the concept is to use a separate directory for each plugin.
Michael only wrote about Windows. Here is an Eclipse call we would use for example:
Code:
$ eclipse -configuration /opt/eclipse/extensions/testng/eclipse/configuration
This way, all plugins will be saved in subdirectories of '/opt/eclipse/extensions/'. The last call was for installing the TestNG plugin. The second thing that has to be done is adding a link to the installed plugin in the link directory of the Eclipse installation directory (or in all the link directories of the different Eclipse installations you might have):
Code:
$ echo "path=/opt/eclipse/extensions/testng" > /opt/eclipse-xy/links/testng.link
Now, after restarting Eclipse, the plugin can be used even though it's not in the Eclipse program directory.
3. How to avoid remembering unnecessary command line stuff
As I found it tedious to remember this cryptic command line stuff for installing new plugins, I devised a simple GUI solution. Save my script 'plgi-eclipse.sh' (plgi = plugin installation) somewhere in your PATH (I usually use ~/bin, so I don't forget to migrate my scripts when moving on to a new computer or Ubuntu installation):
Code:
#!/bin/bash
# plgi-eclipse.sh (for plugin-installation-eclipse)
# starts Eclipse for installation of a certain plugin into a central plugin directory
# see http://michaelscharf.blogspot.com/2009/02/p2-how-i-install-plugins-in-extension.html
# for more information about this way of handling plugins.
# uses zenity for Gnome, if you want to use it in KDE, you got to replace that with kdialog.
pluginName=$(zenity --entry --text "Please enter a name for the plugin you wish to install")
eclipse -configuration /opt/eclipse/extensions/$pluginName/eclipse/configuration
# here you might want to change the path(s) to the "links" directories on your system.
echo "path=/opt/eclipse/extensions/$pluginName" > /opt/eclipse-xy/links/$pluginName.link
touch /opt/eclipse/extensions/$szAnswer/eclipse/.eclipseextension
exit 0
If this script is called, it will ask you for a name for the plugin you want to install and will call Eclipse with the correct parameter as well as adding the link in the link directory.
Last thing needed is an application starter, so it's really GUI only. Save the following as '/usr/share/applications/eclipse-plugin-install.desktop':
Code:
[Desktop Entry]
Encoding=UTF-8
Name=Plugin Install For Eclipse
Comment=Start Eclipse for central plugin installation
Exec=plgi-eclipse.sh
Icon=/opt/eclipse/eclipse.svg
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true
That's it. Try it and tell me how it works for you. This is easily expandable. For example, you could come up with a dialog where the user can decide for which Eclipse installations links should be added. At the moment, I simply add the needed links directories directly in 'plgi-eclipse.sh', so there are multiple calls to 'echo':
Code:
echo "path=/opt/eclipse/extensions/$szAnswer" > /opt/eclipse-3.5-galileo/links/$szAnswer.link
echo "path=/opt/eclipse/extensions/$szAnswer" > /opt/eclipse-3.6-helios/links/$szAnswer.link
4. How to share manually downloaded plugins
All the above is for plugins which you download using Eclipse's update mechanism. But you might have already downloaded some plugins which you don't want to download again. There's also a solution for sharing those plugins (though I'm not sure if it's advisable - I think plugins which were downloaded manually outside of Eclipse won't benefit from the update mechanism. Take a look at this link. All you have to do is adding this line to your eclipse.ini (and creating the directory 'dropins'):
Code:
-Dorg.Eclipse.equinox.p2.reconciler.dropins.directory=/opt/eclipse/dropins
Have fun
Bookmarks