Eclipse Equinox,如何配置自动加载插件文件夹中的捆绑包

8
我遵循了http://www.eclipse.org/equinox/documents/quickstart-framework.php,但似乎已经过时且无效。
没有像org.eclipse.update.configurator_3.2.100.jar描述的那样的bundles。
我尝试使用org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503,但不起作用。
有人可以告诉我如何使Equinox自动加载plugins文件夹中的bundles吗?
3个回答

14

最简单的方法是使用 Apache Felix File Install。它可以很好地与Equinox配合使用,您只需要将File Install配置参数放入configuration/config.ini中即可。请注意,如果您通过launcher JAR或binary启动Equinox,则工作目录将是configuration/或plugins/目录的父目录。

我们项目config.ini的摘录:

# Start File Install itself
osgi.bundles=reference\:file\:org.apache.felix.fileinstall_3.1.0.jar@1\:start
# The name of the directory to watch
felix.fileinstall.dir=./plugins
# A regular expression to be used to filter file names
# We have all bundles in plugins/ directory, this regexp
# forbids monitoring bundles that are started via osgi.bundles property
felix.fileinstall.filter=^(?!org.apache.felix.fileinstall|org.eclipse.osgi).*
# Determines if File Install waits felix.fileinstall.poll milliseconds before doing an initial scan or not.
felix.fileinstall.noInitialDelay=true
# Not sure why we have this...
felix.fileinstall.start.level=2

另一种可能的解决方案是使用Eclipse P2。它更为先进和强大,但我发现它很难使用。

好消息是,如果你的应用程序对bundle的提供方式没有特别要求(应该是这样),你总是可以随时改变主意。


我想使用Apache Felix文件安装,但如何在Eclipse的config.ini中放置“felix.fileinstall.dir”配置?我尝试了felix.fileinstall.dir=..\plugins\,但没有成功...... 我该如何将此系统属性放入配置文件中? - John John Pichler
1
我现在正在使用带有JVM参数的文件安装到系统属性中。就像-Dparameter=value一样。现在它正在工作。 - John John Pichler
你尝试过 felix.fileinstall.dir=./plugins 吗?如果你通过启动器 jar/binary 启动 Equinox,工作目录将是 configuration/ 目录的父级。除此之外,应该可以正常工作。 - Ivan Dubrov
我现在只是遇到了一些类路径错误... Activator类找不到JFrame主类。奇怪的是两者都在同一个bundle中,在Eclipse中它可以工作。 =\ - John John Pichler

0

这是我用Ant编写的自动化Eclipse安装程序的片段。

它会从自定义更新站点安装所有功能。代码是“原样”,但当我编写它时,我肯定希望有类似这样的东西来指导我。

此脚本还使用antcontrib扩展到Ant。Antcontrib任务具有“ac:”命名空间前缀

希望这可以帮助到您。

    <property name="real.eclipse.home" location="${eclipse.home}/eclipse"/>

    <property file="${real.eclipse.home}/configuration/config.ini" prefix="ECLIPSE_CONFIG"/>

    <property name="eclipse-plugins.dir" location="${real.eclipse.home}/plugins"/>

    <path id="newest.equinox.launcher-library.path.id">
      <dirset dir="${eclipse-plugins.dir}">
        <include name="org.eclipse.equinox.launcher.*"/>
      </dirset>
    </path>

    <property name="equinox.launcher-library.full-path" refid="newest.equinox.launcher-library.path.id"/>

    <basename property="equinox.launcher-library.dir" file="${equinox.launcher-library.full-path}"/>

    <echo message="equinox.launcher-library.dir='${equinox.launcher-library.dir}'"/>

    <path id="newest.equinox.launcher.path.id">
      <fileset dir="${eclipse-plugins.dir}">
        <include name="org.eclipse.equinox.launcher_*.jar"/>
      </fileset>
    </path>

    <property name="equinox.launcher.jar" refid="newest.equinox.launcher.path.id"/>
    <basename property="equinox.launcher.jar.basename" file="${equinox.launcher.jar}"/>

    <echo message="equinox.launcher.jar='${equinox.launcher.jar}'"/>

    <java jar="${equinox.launcher.jar}"
      fork="true"
      failonerror="true"
    >
      <arg value="-consolelog"/>
      <arg value="-application"/>
      <arg value="org.eclipse.equinox.p2.director"/>
      <arg value="-repository"/>
      <arg value="http://${repository.server}/custom-update-site"/>
      <arg value="-list"/>
      <redirector
        logError="true"
        outputproperty="features.list"
      >
        <outputfilterchain>
          <linecontains>
            <contains value="feature.group="/>
          </linecontains>
          <replaceregex pattern="(.*feature\.group)=.*$" replace="\1"/>
        </outputfilterchain>
      </redirector>
    </java>

    <ac:for list="${features.list}" delimiter="${line.separator}" trim="true" param="feature">
      <sequential>
        <ac:if>
          <isset property="feature.comma.list"/>
          <then>
            <ac:var name="feature.comma.list" value="${feature.comma.list},@{feature}"/>
          </then>
          <else>
            <property name="feature.comma.list" value="@{feature}"/>
          </else>
        </ac:if>
      </sequential>
    </ac:for>

    <echo message="Found following features to install"/>
    <echo message="${features.list}"/>

    <java jar="${equinox.launcher.jar}"
      fork="true"
      failonerror="true"
    >
      <arg value="-consolelog"/>
      <arg value="-application"/>
      <arg value="org.eclipse.equinox.p2.director"/>
      <arg value="-repository"/>
      <arg value="http://${repository.server}/custom-update-site"/>
      <arg value="-destination"/>
      <arg file="${real.eclipse.home}"/>
      <arg value="-installIU"/>
      <arg value="${feature.comma.list}"/>
      <arg value="-profile"/>
      <arg value="${ECLIPSE_CONFIG.eclipse.p2.profile}"/>
    </java>

P.S. 由于其实用性和复杂性,Eclipse P2 绝对是最缺乏文档的功能之一。


0
在您的Eclipse安装文件夹中,有一个名为bundles.info的文件,例如:
eclipse-3.6.1/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

您可以修改文件以添加任何捆绑包,也可以设置起始级别。但是将捆绑包添加到“dropins”文件夹是向Eclipse安装中添加捆绑包的最简单方法。这将自动修改bundle.info文件。


哼...“droppins”文件夹在哪里呢?朔日会自动在运行时更改bundles.info吗? - John John Pichler
1
在eclipse-3.6.1/中,与plugins和features在同一级别。是的,equinox会自动完成。这里有更多信息:[链接](http://wiki.eclipse.org/Equinox_p2_Getting_Started#Dropins)。该机制类似于felix安装程序所做的操作,但采用“eclipse方式”:) - RaduK
这对于普通的Equinox安装无效。来自dropins目录的JAR文件不会自动加载。 - Robert
1
是的,你说得对,这在标准的Equinox安装中是不可用的。你必须安装p2捆绑包才能监视dropins文件夹。 - RaduK
不确定为什么这被投票否决了...但这正是我所需要的。我试图让插件在我被迫使用的旧版eclipse中工作,而这是唯一的方法,我才能找到并加载它们。我尝试了所有其他“标准”方法,但由于某种原因,在这个特定的安装中,它们都没有起作用。 - Droj

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接