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

时间:2011-03-02 18:09:08

标签: java eclipse osgi helios

我跟着http://www.eclipse.org/equinox/documents/quickstart-framework.php,但它看起来很旧而且无效。

没有像org.eclipse.update.configurator_3.2.100.jar所描述的那样的捆绑

我尝试使用org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503,但无效。

任何人都可以告诉我如何让Equinox自动加载plugins文件夹中的包吗?

3 个答案:

答案 0 :(得分:14)

最简单的方法是使用Apache Felix File Install。使用Equinox可以正常工作,只需将文件安装配置参数放入configuration / config.ini即可。请注意,如果您通过启动程序JAR或二进制文件启动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。它更加先进和强大,但我发现它很难使用。

好的是,如果您的应用程序与捆绑包的配置方式无关(并且应该是这样),您可以随时改变主意。

答案 1 :(得分:0)

这是我用ant。编写的自动化eclipse安装程序中的片段。

这将安装自定义更新站点的所有功能。代码是“原样”,但我确实希望有这样的东西来指导我写作时。

此脚本还对ant使用antcontrib扩展名。 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肯定是最缺乏文档的功能之一。

答案 2 :(得分:0)

在您的eclipse安装文件夹中,您有文件bundles.info,例如:

eclipse-3.6.1/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info

您可以修改文件以添加所需的任何捆绑包,以及起始级别。但是将捆绑包添加到eclipse安装的最简单方法是将它们添加到“dropins”文件夹中。这将导致自动修改bundle.info文件。