如何构建一个Eclipse RCP应用程序,使其特性能够自动更新?

时间:2023-01-19 10:59:50

I am building an RCP application that will be made up of several Features.

我正在构建一个RCP应用程序,它将由几个特性组成。

My RCP application is configured to check for updates each time it starts. My current problem is that I need one of my Features to be 'Installed' at build time so that it will get updated during this automatic check for updates without forcing the user to manually install it. I need this feature to update independently from the other features in the system.

我的RCP应用程序被配置为每次启动时检查更新。我目前的问题是,我需要在构建时“安装”我的一个特性,以便在这个自动检查更新时更新它,而不必强制用户手动安装它。我需要这个特性独立于系统中的其他特性进行更新。

So, to recap, I'm just looking for a nice automated way to have a Feature installed in an RCP app in such a way that it updates independently from other features, and doesn't require the user of the RCP app to install it manually.

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

3 个解决方案

#1


2  

In the meanwhile, Tycho has explicit support for this use case. Starting with Tycho 0.20.0, you can make Tycho install features of an RCP separately from the product. In this way, these features can be updated (or even be uninstalled) independently of the product.

同时,Tycho对这个用例有明确的支持。从第谷0.20.0开始,可以将第谷的RCP安装特性与产品分开。通过这种方式,可以独立于产品更新(甚至卸载)这些特性。

To install features independently, just add an attribute installMode="root" to the respective feature tags in the product file. Example:

要独立地安装特性,只需向产品文件中相应的特性标记添加属性installMode="root"即可。例子:

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

For more information, see this documentation page.

有关更多信息,请参见本文档页面。

#2


5  

After a long search, I have found the answer. It's kind of a kludge, but I'm willing to do anything at this point. My solution is dependent upon the fact that my built RCP application includes p2 application org.eclipse.equinox.p2.director. I guess if your RCP app doesn't contain this application, you can refer to another Eclipse install in order to launch the Director. I just did it this way to avoid having an instance of Eclipse sitting on my build machine.

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

I used the p2-dev mailing list, and Paul Webster answered my question. (Thanks Paul)

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

He suggested using ant to launch the p2 director application to install the IU into my built RCP application.

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

Here's his answer on the p2-dev mailing list http://dev.eclipse.org/mhonarc/lists/p2-dev/msg04735.html

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

Here's the ant target I came up with.

这是我想到的蚂蚁目标。

<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>

I put this in an ant file in the same project that produces my Eclipse RCP application via Tycho. Tycho produces my build artifacts in a directory called "target" so my parameters to the ant target above look like this...

我将它放在通过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>

I have a few more of these targets for each platform that my RCP application is built for.

对于RCP应用程序构建的每个平台,我都有更多的目标。

Hope this helps.

希望这个有帮助。

UPDATE: May 8th, 2014. Tobias has brought it to my attention that I should change the accepted answer from this one to the one that has the new feature that was added to Tycho 0.20.0 that enables this behavior in a much more simple fashion. So, the new accepted answer is the proper solution for this question now.

更新:2014年5月8日。托拜厄斯让我注意到,我应该将已被接受的答案从这个改为一个有新特性的答案,这个新特性被添加到Tycho 0.20.0中,以一种更简单的方式实现这种行为。所以,新的公认答案是现在这个问题的正确答案。

#3


1  

Before I found the answer that is documented here and accepted, I tried and failed to solve this problem in the following ways:

在我找到这里记录的答案并接受之前,我尝试过以下方法来解决这个问题,但失败了:

I tried putting the Feature in the product definition. This get's the feature installed successfully, but it takes away my ability to have it update independently from other features in the RCP application.

我尝试在产品定义中加入这个特性。这个get成功地安装了这个功能,但是它剥夺了我让它独立于RCP应用程序中的其他功能进行更新的能力。

I have a p2 touchpoint command that is currently working. It adds a repository to the available update sites in the RCP application using a p2.inf file. It looks like this...

我有一个p2接触点命令,它现在正在工作。它使用p2向RCP应用程序中可用的更新站点添加一个存储库。inf文件。是这样的……

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);\\

I've tried to add a line like this to get that feature installed, but my tycho build fails when I run mvn clean install

我尝试过添加这样的一行来安装这个特性,但是当我运行mvn clean安装时,我的第谷构建失败了

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

Here's some of the error message from maven / tycho

下面是来自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.

My intuition tells me that this error message is saying that my RCP application plugin is missing something that will tell p2 where to find the feature that I want to install at build time. I think???

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

#1


2  

In the meanwhile, Tycho has explicit support for this use case. Starting with Tycho 0.20.0, you can make Tycho install features of an RCP separately from the product. In this way, these features can be updated (or even be uninstalled) independently of the product.

同时,Tycho对这个用例有明确的支持。从第谷0.20.0开始,可以将第谷的RCP安装特性与产品分开。通过这种方式,可以独立于产品更新(甚至卸载)这些特性。

To install features independently, just add an attribute installMode="root" to the respective feature tags in the product file. Example:

要独立地安装特性,只需向产品文件中相应的特性标记添加属性installMode="root"即可。例子:

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

For more information, see this documentation page.

有关更多信息,请参见本文档页面。

#2


5  

After a long search, I have found the answer. It's kind of a kludge, but I'm willing to do anything at this point. My solution is dependent upon the fact that my built RCP application includes p2 application org.eclipse.equinox.p2.director. I guess if your RCP app doesn't contain this application, you can refer to another Eclipse install in order to launch the Director. I just did it this way to avoid having an instance of Eclipse sitting on my build machine.

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

I used the p2-dev mailing list, and Paul Webster answered my question. (Thanks Paul)

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

He suggested using ant to launch the p2 director application to install the IU into my built RCP application.

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

Here's his answer on the p2-dev mailing list http://dev.eclipse.org/mhonarc/lists/p2-dev/msg04735.html

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

Here's the ant target I came up with.

这是我想到的蚂蚁目标。

<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>

I put this in an ant file in the same project that produces my Eclipse RCP application via Tycho. Tycho produces my build artifacts in a directory called "target" so my parameters to the ant target above look like this...

我将它放在通过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>

I have a few more of these targets for each platform that my RCP application is built for.

对于RCP应用程序构建的每个平台,我都有更多的目标。

Hope this helps.

希望这个有帮助。

UPDATE: May 8th, 2014. Tobias has brought it to my attention that I should change the accepted answer from this one to the one that has the new feature that was added to Tycho 0.20.0 that enables this behavior in a much more simple fashion. So, the new accepted answer is the proper solution for this question now.

更新:2014年5月8日。托拜厄斯让我注意到,我应该将已被接受的答案从这个改为一个有新特性的答案,这个新特性被添加到Tycho 0.20.0中,以一种更简单的方式实现这种行为。所以,新的公认答案是现在这个问题的正确答案。

#3


1  

Before I found the answer that is documented here and accepted, I tried and failed to solve this problem in the following ways:

在我找到这里记录的答案并接受之前,我尝试过以下方法来解决这个问题,但失败了:

I tried putting the Feature in the product definition. This get's the feature installed successfully, but it takes away my ability to have it update independently from other features in the RCP application.

我尝试在产品定义中加入这个特性。这个get成功地安装了这个功能,但是它剥夺了我让它独立于RCP应用程序中的其他功能进行更新的能力。

I have a p2 touchpoint command that is currently working. It adds a repository to the available update sites in the RCP application using a p2.inf file. It looks like this...

我有一个p2接触点命令,它现在正在工作。它使用p2向RCP应用程序中可用的更新站点添加一个存储库。inf文件。是这样的……

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);\\

I've tried to add a line like this to get that feature installed, but my tycho build fails when I run mvn clean install

我尝试过添加这样的一行来安装这个特性,但是当我运行mvn clean安装时,我的第谷构建失败了

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

Here's some of the error message from maven / tycho

下面是来自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.

My intuition tells me that this error message is saying that my RCP application plugin is missing something that will tell p2 where to find the feature that I want to install at build time. I think???

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