2

Situation

I have developed an Eclipse RCP application. This application may be installed on both Windows and Linux systems.

If this application is installed in Administrator mode (Windows) or by a superuser (Linux), the application is typically installed in a write-protected shared install directory.

  • On Windows, our product installer is always run in Administrator-mode. The default installation directory is the (write-protected) C:\Program Files\MyProduct.
  • On Linux, the installer can be run by both a normal user and a superuser. For a superuser the default installation directory is the (also write-protected) /opt/MyProduct.

This is what Eclipse itself calls a shared install.

Obviously, a normal user running the application does not have rights to modify this directory. Therefore, runtime data such as changed configuration data or auto-updated plug-ins are written to a user-specific private configuration area.

  • On Windows this defaults to a subdirectory of $USERPROFILE\.eclipse\.
  • On Linux this also defaults to a subdirectory of ~/.eclipse/

Problem

By default the private directory within .eclipse has a seemingly random name:

.eclipse/1410846118

If I add an .eclipseproduct metadata file, the default behaviour changes. The content of the file is described in this forum post:

# FILE:
name=MyProduct
id=com.mycompany.myproduct.gui.product
version=1.8.17

This results in a private directory with the following name:

.eclipse/com.mycompany.myproduct.gui.product_1.8.17_1410846118/

This means although the product ID and version are now used, the same seemingly random number is still present as a suffix.

My question is simple: what is this number and how can I calculate it?

Eclipse seems to be able to calculate it after installation. However, I don't seem to find it in any file of the shared installation using

sudo find /opt/MyProduct -name '*' | xargs grep -e '1410846118'
tbacker
  • 772
  • 7
  • 22

1 Answers1

2

The code for this seems to be in org.eclipse.core.runtime.adaptor.LocationManager. This looks for the product id in a file called .eclipseproduct in the installation directory. If the file does not exist it uses the hash code of the install directory path which is presumably what you are seeing.

So I think you need an .eclipseproduct file. See Define .eclipseproduct during build for some more information.

Edit:

Even with the product file the hash code is still appended. The hash is calculated using this:

File installDir = path of install directory from osgi.install.area
int hashCode;
try {
    hashCode = installDir.getCanonicalPath().hashCode();
} catch (IOException ioe) {
    // fall back to absolute path
    hashCode = installDir.getAbsolutePath().hashCode();
}
if (hashCode < 0)
    hashCode = -(hashCode);
String installDirHash = String.valueOf(hashCode);
Community
  • 1
  • 1
greg-449
  • 109,219
  • 232
  • 102
  • 145
  • Thanks, I tested the `.eclipseproduct` file and this is used indeed, but the hash is still used as suffix. I integrated this into my question! – tbacker Sep 04 '13 at 09:08
  • Yes looking at code again the hash is always appended. Added description of how it is calculated. – greg-449 Sep 04 '13 at 10:32
  • Thanks again. Do you have any idea if I can overrule this directory completely? I tried to set the `osgi.user.area` and `osgi.user.area.default` properties, but user-specific stuff always gets placed in `~/.eclipse`... – tbacker Sep 04 '13 at 11:32
  • Looks like it might use `osgi.configuration.area.default` – greg-449 Sep 04 '13 at 11:41