2011-03-02 86 views

回答

12

最简单的方法是使用Apache Felix File Install。它对Equinox来说工作得很好,你只需要将文件安装配置参数放入配置/ config.ini。但请注意,如果通过启动器JAR或通过二进制启动Equinox,工作目录将是配置/或插件/目录的父级。从我们的项目的config.ini

摘录:

# Start File Install itself 
osgi.bundles=reference\:file\:[email protected]\: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的配置方式(它应该是这种方式),你可以随时改变主意。

+0

我想使用Apache Felix文件安装,但是我怎样才能在Eclipse config.ini中放入“felix.fileinstall.dir”配置? 我试过felix.fileinstall.dir = .. \ plugins \ without sucess ...我怎样才能把这个系统属性放在配置文件中? – 2011-03-02 19:11:46

+1

我正在使用带有jvm参数的文件安装到系统属性。这就像-Dparemter =值.. 它现在正在工作。 – 2011-03-02 21:46:32

+0

你有没有试过felix.fileinstall.dir =。/ plugins?如果通过启动程序jar/binary启动Equinox,则工作目录将是配置/目录的父目录。除此之外,应该工作得很好。 – 2011-03-03 04:13:10

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 

您可以修改该文件以添加任何你想要的捆绑,并启动级别。但是在eclipse安装中添加bundle的最简单方法是将它们添加到“dropins”文件夹中。这将导致自动修改bundle.info文件。

+0

hmmm ...“droppins”文件夹在哪里?春分会在运行时自动更改bundles.info? – 2011-03-03 14:11:38

+1

在eclipse-3.6.1 /中,与插件和功能处于同一级别。是的,春分会自动做到这一点。在这里你有更多的信息:[链接](http://wiki.eclipse.org/Equinox_p2_Getting_Started#Dropins)。该机制类似于felix安装的机制,但“日食方式”:) – RaduK 2011-03-03 14:14:55

+0

这对于普通的Equinox安装不起作用。来自dropins目录的JAR不会自动加载。 – Robert 2011-03-07 12:49:44

相关问题