在我的 RCP 应用程序中,我想将属性 (osgi.java.profile
) 指向一个文件,并且更喜欢使用相对于我的安装和配置目录的路径。
config.ini 中支持哪些类型的变量有明确的规范吗?
@config.dir 似乎受支持,内置中有参考,并且总是将其作为典型示例提及(例如 这个答案)
但是,查看 Eclipse help/运行时选项,它提到了一些“符号位置”,例如@user.home;然而,这似乎相当有限,并且不包括@config.dir。
甚至还深入研究了 org.eclipse.osgi 源代码,但没有发现对此的引用(我确实找到了 LocationManager 及其对 @user.dir & co 的硬编码变量替换)。
我可以以某种方式引用任意系统属性吗?
这个@config.dir是一个特殊情况,仅由P2处理吗? 更新:情况似乎是这样..查看Eclipse SDK,关于..配置对话框显示@config.dir未解析,可能是由Equinox字面意思理解的..
感谢您的任何提示。
In my RCP app, I would like to point a property (osgi.java.profile
) to a file, and would prefer using paths relative to my installation and config dir.
Is there a definitive spec on what kind of variables are supported in config.ini?
@config.dir seems to be supported, there are references in the builtin, and it's always mentioned as typical example (e.g this SO answer )
However, looking at docs like Eclipse help/Runtime Options, it mentions a few "symbolic locations" like @user.home; however that seems fairly limited and doesn't include @config.dir.
Have even dug into org.eclipse.osgi
sources as well, and found no references to this (I did find LocationManager and its hard coded variable substitutions for @user.dir & co).
Can I refer to arbitrary system properties there in some way?
Is this @config.dir a special case, only handled by P2? UPDATE: this seems to be the case.. looking at Eclipse SDK, About .. Configuration dialog shows @config.dir unresolved, probably taken literally by the Equinox..
Thanks for any hints.
发布评论
评论(5)
我参加聚会迟到了,但希望这能对其他人有所帮助。
从 Eclipse 3.8/4.2(2012 年 6 月)开始,您可以将 Java 属性和环境变量替换到 config.ini 文件中 (Eclipse 错误 241192)。 Equinox 启动程序不支持 eclipse.ini 启动程序文件中的替换。语法使用美元符号($VARIABLE$)来指示变量替换:
我想您可以使用类似的东西来达到您的目的:
I'm late to the party, but hopefully this will help others in the future.
Starting with Eclipse 3.8/4.2 (June 2012), you can substitute Java properties and environment variables into your config.ini file (Eclipse Bug 241192). The Equinox launcher does not support substitution in the eclipse.ini launcher file. The syntax uses dollar signs ($VARIABLE$) to indicate variable substitution:
I imagine you could use something like this for your purposes:
您可以使用平台 URL (平台 URI 方案)来实现此目的,即
在
config.ini
中,将指向文件java_profile.txt
当前配置目录。您还可以使用 config.ini 中的现有系统属性:
You can use a platform URL (Platform URI scheme) to achieve this, i.e.
in
config.ini
, would point to the filejava_profile.txt
in the current configuration directory.You might also use existing system properties in config.ini:
来自 org.eclipse.core.runtime.adaptor.LocationManager,以下是特殊标记:
From org.eclipse.core.runtime.adaptor.LocationManager, here are the special tokens:
为什么不使用两个系统属性变量?
一种名为
-Dmy.relativepath=filename
,由您的eclipse安装文件夹(工作空间或任何地方)相对路径的代码处理,另一种名为-Dmy.path=absolutepath
代码>.系统属性被传递给jvm,如果你想在其值中使用变量,你需要在本机启动器(如eclipse.exe)中使用一些技巧(在运行时翻译变量)。
Why not use two system property variables?
One is named
-Dmy.relativepath=filename
, which is processed by your code of relative path of eclipse installation folder(workspace or anywhere), another is called-Dmy.path=absolutepath
.The system property is passed to the jvm, you need some tricky(translate the variable in runtime) in the native launcher(like eclipse.exe) if you wants to use variable in its value.
看看 osgi.java.profile 在 org.eclipse.osgi.framework.internal.core.Framework 中是如何解析的:
这意味着 osgi.java.profile 必须指向一个完全限定的 URL,或者指向一个系统包中的相对路径 (
org.eclipse.osgi
)。这使得在不修补 Eclipse 的情况下无法使用安装目录相对路径。Look how osgi.java.profile is resolved in
org.eclipse.osgi.framework.internal.core.Framework
:That means osgi.java.profile must point either to a fully qualified URL, or to a relative path in system bundle (
org.eclipse.osgi
). This makes impossible usage of installation directory relative path without patching Eclipse.