6

我正在构建一个由多个功能组成的 RCP 应用程序。

我的 RCP 应用程序配置为在每次启动时检查更新。我当前的问题是我需要在构建时“安装”我的一项功能,以便在自动检查更新期间对其进行更新,而无需强制用户手动安装它。我需要此功能独立于系统中的其他功能进行更新。

所以,回顾一下,我只是在寻找一种很好的自动化方式来在 RCP 应用程序中安装一个功能,这样它就可以独立于其他功能进行更新,并且不需要 RCP 应用程序的用户安装它手动。

4

3 回答 3

5

经过长时间的搜索,我找到了答案。这有点像kludge,但我愿意在这一点上做任何事情。我的解决方案取决于我构建的 RCP 应用程序包括 p2 应用程序 org.eclipse.equinox.p2.director 的事实。我猜如果您的 RCP 应用程序不包含此应用程序,您可以参考另一个 Eclipse 安装以启动 Director。我这样做是为了避免在我的构建机器上放置一个 Eclipse 实例。

我使用了 p2-dev 邮件列表,Paul Webster 回答了我的问题。(感谢保罗)

他建议使用 ant 启动 p2 director 应用程序将 IU 安装到我构建的 RCP 应用程序中。

这是他在 p2-dev 邮件列表 http://dev.eclipse.org/mhonarc/lists/p2-dev/msg04735.html上的回答

这是我想出的蚂蚁目标。

<target name="install_IU">
  <path id="launcher.paths">
    <fileset
       dir="${app.dir}"
       includes="plugins/org.eclipse.equinox.launcher_*" />
  </path>
  <property
      name="launcherPath"
      refid="launcher.paths" />
  <echo>-installIU ${iu.id} </echo>
  <java 
      jar="${launcherPath}"
      failonerror="false"
      dir="${app.dir}"
      timeout="900000"
      fork="true"
      output="${basedir}/director.log"
      resultproperty="directorcode">
      <arg line="-application org.eclipse.equinox.p2.director" />
      <arg line="-noSplash" />
      <arg line="-installIUs ${iu.id}" />
      <arg line="-repository ${iu.repo}" />
      <arg line="-destination ${app.dir}" />
      <arg line="-bundlepool ${app.dir}" />
  </java>

  <zip destfile="${app.zip}"
    basedir="${app.dir}"/>
</target>

我将它放在通过 Tycho 生成我的 Eclipse RCP 应用程序的同一个项目中的一个 ant 文件中。Tycho 在名为“target”的目录中生成我的构建工件,因此我对上面 ant 目标的参数如下所示......

<target name="modify_x86">
  <antcall target="install_IU">
    <param name="iu.id" value="com.mydomain.the.feature.i.want.to.install.feature.feature.group"/>
    <param name="iu.repo" value="http://mydomain.com/thep2repository/where/i/deploy/the/feature/to/install"/>
    <param name="app.dir" value="${basedir}/target/products/com.mydomain.myRCPapplication/win32/win32/x86"/>
    <param name="app.zip" value="${basedir}/target/products/com.mydomain.myRCPapplication-win32.win32.x86.zip"/>
  </antcall>
</target>

对于构建我的 RCP 应用程序的每个平台,我还有几个这样的目标。

希望这可以帮助。

更新:2014 年 5 月 8 日。Tobias 已引起我的注意,我应该将接受的答案从这个答案更改为具有添加到 Tycho 0.20.0 的新功能的答案,该功能以更简单的方式启用此行为. 因此,新接受的答案现在是该问题的正确解决方案。

于 2012-05-15T21:15:41.843 回答
2

同时,Tycho 明确支持此用例。从Tycho 0.20.0开始,您可以让 Tycho 独立于产品安装 RCP 的功能。通过这种方式,这些功能可以独立于产品进行更新(甚至卸载)。

要独立安装功能,只需将属性添加installMode="root"到产品文件中的相应功能标签即可。例子:

<features>
   <feature id="org.eclipse.platform"/>
   <feature id="updatable.feature" installMode="root"/>
</features>

有关详细信息,请参阅此文档页面

于 2012-07-26T08:01:37.877 回答
1

在我找到此处记录并接受的答案之前,我尝试并未能通过以下方式解决此问题:

我尝试将功能放入产品定义中。该功能已成功安装,但它使我无法独立于 RCP 应用程序中的其他功能进行更新。

我有一个当前正在运行的 p2 接触点命令。它使用 p2.inf 文件将存储库添加到 RCP 应用程序中的可用更新站点。看起来像这样...

instructions.configure=\
 org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:http${#58}//myUpdateSsite/myFeature,type:0,name:My Feature Name,enabled:true);\
 org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:http${#58}//myUpdateSsite/myFeature,type:1,name:My Feature Name,enabled:true);\\

我试图添加这样的一行来安装该功能,但是当我运行 mvn clean install 时我的 tycho 构建失败

instructions.configure=\
 org.eclipse.equinox.p2.touchpoint.eclipse.installFeature(feature:My Feature Name,featureId:com.my.domain.my.feature.id,version:1.0.0);

这是来自 maven / tycho 的一些错误信息

An error occurred while configuring the installed items session context was:
(profile=DefaultProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Configure, operand=null --> 
[R]{my.domain.my.rcp.product.plugin 1.1.6.20120427-1346}, 
action=org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.InstallFeatureAction).
Installable unit contains no artifacts: [R]my.domain.my.rcp.product.plugin 1.1.6.20120427-1346.

我的直觉告诉我,这个错误消息是说我的 RCP 应用程序插件缺少一些东西,它会告诉 p2 在哪里可以找到我想要在构建时安装的功能。我认为???

于 2012-08-29T18:19:40.717 回答