如何构建Eclipse RCP应用程序以便其功能可以自动更新?

twi*_*ham 6 eclipse eclipse-plugin p2 eclipse-rcp tycho

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

我的RCP应用程序配置为每次启动时检查更新.我目前的问题是我需要在构建时"安装"我的某个功能,以便在自动检查更新期间更新,而不必强制用户手动安装它.我需要此功能独立于系统中的其他功能进行更新.

因此,回顾一下,我只是在寻找一种很好的自动方式,在RCP应用程序中安装一个功能,使其独立于其他功能进行更新,并且不需要RCP应用程序的用户安装它手动.

twi*_*ham 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>
Run Code Online (Sandbox Code Playgroud)

我把它放在同一项目中的一个ant文件中,该项目通过Tycho生成我的Eclipse RCP应用程序.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>
Run Code Online (Sandbox Code Playgroud)

我为我的RCP应用程序构建的每个平台提供了更多这些目标.

希望这可以帮助.

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


obe*_*ies 2

同时,第谷明确支持此用例。从Tycho 0.20.0开始,您可以让 Tycho 从产品中单独安装 RCP 的功能。这样,这些功能就可以独立于产品进行更新(甚至卸载)。

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

<features>
   <feature id="org.eclipse.platform"/>
   <feature id="updatable.feature" installMode="root"/>
</features>
Run Code Online (Sandbox Code Playgroud)

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