问题
My company produces a small suite of Eclipse RCP applications that are installed into the same shared location on Windows (C:\Program Files (x86)\MyCompany). They share a plug-ins directory but have separate configuration areas.
The desired location for osgi.configuration.area, osgi.user.area, and osgi.instance.area are in a user's roaming application data area (%APPDATA% on Windows XP/7). Due to localization requirements and differences in path locations between the OSes, it is not sufficient to build a path in the PRODUCT.ini launcher file starting from @user.home. Bug 241192 added the ability to specify environment variables in the config.ini file, but not in the PRODUCT.ini file.
This is the installation directory structure:
C:/Program Files (x86)/MyCompany
configurationProgram1/config.ini
configurationProgram2/config.ini
configurationProgram3/config.ini
jre/
plugins/*.jar
Program1.exe
Program1.ini
Program2.exe
Program2.ini
Program3.exe
Program3.ini
This is an example PRODUCT.ini file:
--launcher.defaultAction
openFile
-clean
-vmargs
-Xmx768m
-Dosgi.locking=none
-Dosgi.requiredJavaVersion=1.7
-Dvisualvm.display.name=Program1
-Dosgi.baseConfiguration.area=file:configurationProgram1
-Dosgi.sharedConfiguration.area=file:configurationProgram1
This is an example config.ini file:
#Product Runtime Configuration File
eclipse.application=com.mycompany.app.program1.application
osgi.bundles.defaultStartLevel=4
eclipse.product=com.mycompany.app.program1.product
osgi.splashPath=platform:/base/plugins/com.mycompany.app.program1
osgi.bundles= ...
org.eclipse.equinox.common@2:start,\
...
org.eclipse.equinox.launcher.win32.win32.x86,\
org.eclipse.swt.win32.win32.x86
osgi.configuration.area=$APPDATA$/MyCompany/Program1/configuration
osgi.user.area=$APPDATA$/MyCompany/Program1/user
osgi.instance.area=$APPDATA$/MyCompany/Program1/instance
If the working directory is in installation directory when the application is launched (e.g. double-click the exe in Windows Explorer, use a shortcut with the "Start in" variable defined as the installation directory), the relative path for osgi.baseConfiguration.area is resolved to the correct absolute path and osgi.configuration.area is set to the correct location in APPDATA. If the working directory is not the installation directory (e.g. open the application by double-clicking a file in Explorer associated with the program, launch from the command line from any non-installation directory), the program launches but osgi.baseConfiguration.area is still listed as a relative path and osgi.configuration.area reverts to its fallback position (for admins: C:/Program Files (x86)/MyCompany/configuration, for users: %USERPROFILE%/.eclipse/configuration). osgi.user.area and osgi.instance.area are correctly set in both instances.
My custom local configuration (configurationProgram1/config.ini) is clearly found, otherwise the application would fail to launch at all. However in the problem case, the Equinox launcher is either ignoring my osgi.configuration.area declaration or resetting it. I do not know how to step through the Equinox launcher start up class (org.eclipse.equinox.launcher.Main) to diagnose the problem further. The correct behavior is observed if osgi.baseConfiguration.area is defined as an absolute path rather than a relative path.
The RCP applications are based on Eclipse Platform 3.8.1. I confirmed the problem still exists in version 3.8.2, the last release of the 3.x branch. Upgrading to the e4 platform is not a viable option at this time, but I would be interested in knowing if this issue is fixed in e4.
I realize my shared installation for multiple application is a unique case as the assumptions for a shared installation appear to be a single application with multiple local configurations for users and a single shared configuration. Still I suspect this is an Equinox bug; however, I wanted to ask the community whether I have misconfigured my installation or have misunderstood the documentation with regard to these osgi properties before doing so.
回答1:
@SheldonWarkentin reported in another question that LocationManager (file in 3.9 branch) requires the plugins/ and configuration/ directories to be in the same directory and named exactly so in order to use a relative path, which must be defined by -startup and --launcher.library to define the plugins/ directory. His recommendation addresses my immediate concerns.
I am using this answer to improve the visibility of Eclipse Bug 426189 ("osgi.baseConfiguration.area and -configuration does not resolve using a relative path"), which I submitted to address this issue. I will close this question when this bug is addressed by the Equinox team.
Update: Eclipse bug fixed
Bug 426189 was fixed and will be part of the Eclipse 4.4 (Luna) release.
来源:https://stackoverflow.com/questions/21145365/osgi-baseconfiguration-area-does-not-resolve-using-a-relative-path