Eclipse 在Equinox中,是否可以将一个OSGi包标记为从其包含特性';s p2.inf?

Eclipse 在Equinox中,是否可以将一个OSGi包标记为从其包含特性';s p2.inf?,eclipse,equinox,p2,Eclipse,Equinox,P2,我有一个Eclipse特性,它包括几个包。我想告诉p2在安装该功能时将其中一个捆绑包标记为已启动。这可以使用bundle自己的META-INF/p2.INF,如下所示 instructions.configure = markStarted(started: true) 但我希望在功能级别而不是捆绑包级别(所讨论的捆绑包是第三方的,如果可能的话,我不希望以任何方式修改它) 一些研究表明,应该可以将配置指令移动到包含特性的p2.inf。我尝试过所有明显的事情,比如 units.0.id = &l

我有一个Eclipse特性,它包括几个包。我想告诉p2在安装该功能时将其中一个捆绑包标记为已启动。这可以使用bundle自己的META-INF/p2.INF,如下所示

instructions.configure = markStarted(started: true)
但我希望在功能级别而不是捆绑包级别(所讨论的捆绑包是第三方的,如果可能的话,我不希望以任何方式修改它)

一些研究表明,应该可以将配置指令移动到包含特性的p2.inf。我尝试过所有明显的事情,比如

units.0.id = <bundle symbolic name>
units.0.instructions.configure = \
  org.eclipse.equinox.p2.touchpoint.eclipse.markStarted(started: true)
units.0.id=
units.0.instructions.configure=\
org.eclipse.equinox.p2.touchpoint.eclipse.markStarted(start:true)
但到目前为止,我尝试过的排列都没有任何效果:因为没有发生任何事情,所以捆绑包没有标记为已启动,也没有报告任何错误)

欢迎任何指点。这是与日食春分伽利略(3.5.2)。。。与太阳神有关的答案也非常有用。

p2.inf条目创建了一个新的,它们不会修改其他现有的IU

您基本上必须创建一个完整的。该片段包含相关说明,并附加到包的IU。然后,您需要将功能中的需求添加到此新IU

PDE/Build在生成产品时自动执行此操作。您可以通过创建一个小rcp产品构建来查看生成的p2.inf,该产品构建具有捆绑包的起始级别。
在产品构建中生成的p2.inf将是
buildDirectory/features/org.eclipse.pde.build.container.feature/product/p2.inf

下面是一个我根据一个构建修改的示例,该构建设置了org.eclipse.equinox.common的开始级别。
$version$
将被p2.inf所属功能的版本替换。请注意“hostRequirements”,它指定了我们所属的包

#create a requirement on the IU fragment we are creating
requires.2.namespace=org.eclipse.equinox.p2.iu
requires.2.name=configure.org.eclipse.equinox.common
requires.2.range=[$version$,$version$]
requires.2.greedy=true

#create a IU frament named configure.org.eclipse.equinox.common
units.0.id=configure.org.eclipse.equinox.common
units.0.version=$version$
units.0.provides.1.namespace=org.eclipse.equinox.p2.iu
units.0.provides.1.name=configure.org.eclipse.equinox.common
units.0.provides.1.version=$version$
units.0.instructions.install=installBundle(bundle:${artifact});
units.0.instructions.uninstall=uninstallBundle(bundle:${artifact});
units.0.instructions.unconfigure=setStartLevel(startLevel:-1);markStarted(started:false);
units.0.instructions.configure=setStartLevel(startLevel:2);markStarted(started:true);
units.0.hostRequirements.1.namespace=osgi.bundle
units.0.hostRequirements.1.name=org.eclipse.equinox.common
units.0.hostRequirements.1.range=[3.6.0.v20100503,3.6.0.v20100503]
units.0.hostRequirements.1.greedy=false
units.0.hostRequirements.2.namespace=org.eclipse.equinox.p2.eclipse.type
units.0.hostRequirements.2.name=bundle
units.0.hostRequirements.2.range=[1.0.0,2.0.0)
units.0.hostRequirements.2.greedy=false
units.0.requires.1.namespace=osgi.bundle
units.0.requires.1.name=org.eclipse.equinox.common
units.0.requires.1.range=[3.6.0.v20100503,3.6.0.v20100503]
units.0.requires.1.greedy=false
对问题的答复:

  • 0,1,2

    这些数字有些随意,它们仅用于将一组属性(
    需要
    单元
    或其他任何属性)与另一组属性分开。
    requires
    此处使用了“2”,原因很简单,因为我从pde.build生成的大型p2.inf复制了它,但忘记了更改它,就像我更改了单位一样。0

  • 这些都有必要吗

    对。需要type=bundle上的第二个
    hostRequirements
    。在Helios中,除了翻译片段外,只有一个片段可以连接到IU。通常,可以使用默认的IU来设置所有osgi捆绑包的默认启动级别。为了让我们的定制片段被选择而不是默认片段,它必须具有更高的“特异性”,即满足主机需求的数量

    用于“安装”

    units.0.instructions.install=installBundle(bundle:${artifact}); units.0.instructions.uninstall=uninstallBundle(bundle:${artifact})

    说明。安装
    说明。卸载
    请参阅p2过程的各个阶段。
    installBundle
    uninstallBundle
    指的是OSGi意义上的安装/卸载。您的bundle必须先安装到OSGi系统中,然后才能执行其他操作。这主要涉及将其添加到config.ini或org.eclipse.equinox.simpleconfigurator/bundles.info文件中

    大多数p2安装已经包含默认配置IU,该IU将安装并设置捆绑包的默认启动级别(4)。但是,目前每个捆绑包只能应用一个配置片段,因此当您这样添加自己的配置片段时,默认配置片段将不再应用于捆绑包

  • 主机要求。InstallableUnitFragments页面只描述了什么是片段,没有关于如何创建片段的参考。这是biefly在页面上提到的,但没有解释

    文档中,维基上的。网站上的页面可能会很有趣。这方面有一些帮助,但总的来说,我认为这比文档中提供的要高级一些


  • 看起来这里有很多魔法。你能解释一下0、1和2的意义吗。。。它们是任意的(在这种情况下,为什么从requires.2开始而不是requires.0?)还是由上下文决定的?还有,所有这些都是必要的吗?例如,units.0.instructions.install在我看来是多余的。更一般地说,这些东西记录在哪里?例如,您说是hostRequirements条目指定了这是哪个捆绑包的一个片段,但在您链接到描述可安装单元片段的页面上没有提到这一点。为了确保我正确理解了编号的任意性,如果将“requires.2”替换为贯穿“requires.0”;“units.0.provides.1”替换为“units.0.provides.0”;“units.0.hostRequirements.1”替换为“units.0.hostRequirements.0”;“units.0.hostRequirements.2”替换为“units.0.hostRequirements.1”替换为“units.0.requirements.0”