OSGI Eclipse configuration: relative paths and / or @ config.dir-like replacements?

In my RCP application, I would like to specify the property ( osgi.java.profile ) in a file and would rather use paths relative to my dir installation and configuration.

Is there a specific specification of which variables are supported in config.ini?


@ config.dir seems to be supported, there are links in the built-in, and it is always referred to as a typical example (for example, this SO answer ) However, looking at documents such as Eclipse help / "Run-time parameters" , it is mentioned several "symbolic places" such as @ user.home; however this seems rather limited and does not include @ config.dir.

And they even dug org.eclipse.osgi into the sources, and did not find references to this (I found the LocationManager and its hard-coded variable replacements for @ user.dir and co). Is there any way to refer to arbitrary properties of the system?

Is this @ config.dir special case handled only by P2? UPDATE: it seems to be so. looking at the Eclipse SDK, About .. The configuration dialog shows @ config.dir unresolved, probably taken literally Equinox ..

Thanks for any tips.

+7
source share
5 answers

I'm late for the party, but hopefully this helps others in the future.

Starting with Eclipse 3.8 / 4.2 (June 2012), you can replace Java variables and environment variables in the config.ini file ( Eclipse Bug 241192 ). Equinox does not support substitution in the eclipse.ini startup file. The syntax uses dollar signs ($ VARIABLE $) to indicate the replacement of variables:

 osgi.configuration.area=$APPDATA$/MyCompany/MyProgram/configuration osgi.user.area=$APPDATA$/MyCompany/MyProgram/user osgi.instance.area=$APPDATA$/MyCompany/MyProgram/instance 

I assume that you could use something like this for your own purposes:

 osgi.java.profile=$osgi.install.area$/path/to/profile.txt 
+3
source

From org.eclipse.core.runtime.adaptor.LocationManager, here are the special tokens:

  // Data mode constants for user, configuration and data locations. private static final String NONE = "@none"; //$NON-NLS-1$ private static final String NO_DEFAULT = "@noDefault"; //$NON-NLS-1$ private static final String USER_HOME = "@user.home"; //$NON-NLS-1$ private static final String USER_DIR = "@user.dir"; //$NON-NLS-1$ 
+1
source

Why not use two system property variables?

One of them is called -Dmy.relativepath=filename , which is processed by your code relative to the path to the eclipse installation folder (workspace or elsewhere), the other is called -Dmy.path=absolutepath .

The system property is passed to jvm, you need some kind of complex (translate the variable in runtime) to native launcher (e.g. eclipse.exe) if you want to use the variable in its value.

+1
source

See how osgi.java.profile is resolved in org.eclipse.osgi.framework.internal.core.Framework :

 // check for the java profile property for a url String propJavaProfile = FrameworkProperties.getProperty(Constants.OSGI_JAVA_PROFILE); if (propJavaProfile != null) try { // we assume a URL url = new URL(propJavaProfile); } catch (MalformedURLException e1) { // try using a relative path in the system bundle url = findInSystemBundle(propJavaProfile); } 

This means that osgi.java.profile must specify either the full URL or the relative path in the system bundle ( org.eclipse.osgi ). This makes it impossible to use the relative path of the installation directory without fixing Eclipse.

+1
source

You can use the platform URL ( Platform URI Scheme ) to achieve this, i.e.

 osgi.java.profile = platform:/config/java_profile.txt 

in config.ini , point to the java_profile.txt file in the current configuration directory.

You can also use existing system properties in config.ini:

 osgi.java.profile = ${osgi.configuration.area}/java_profile.txt 
+1
source

All Articles