Eclipse Equinox,如何配置自动加载插件文件夹中的包
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5171551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse Equinox, how to configure auto load the bundles in plugin folder
提问by John John Pichler
I've followed http://www.eclipse.org/equinox/documents/quickstart-framework.phpbut it seems to be old and not valid.
我已经关注了http://www.eclipse.org/equinox/documents/quickstart-framework.php但它似乎很旧而且无效。
There is no such bundles as described org.eclipse.update.configurator_3.2.100.jar
没有描述 org.eclipse.update.configurator_3.2.100.jar 的包
I tried with the org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503, but doesn't work.
我尝试使用 org.eclipse.equinox.simpleconfigurator_1.0.200.v20100503,但不起作用。
Anyone can tell me how to make Equinox auto load the bundles inside plugins folder?
谁能告诉我如何让 Equinox 自动加载插件文件夹中的包?
回答by Ivan Dubrov
Simplest approach would be to use Apache Felix File Install. It works just fine with Equinox, you only need to put File Install configuration parameters into the configuration/config.ini. Note though that if you launch Equinox via launcher JAR or via binary, the working directory would be parent of configuration/ or plugins/ directory.
最简单的方法是使用Apache Felix File Install。它与 Equinox 一起工作得很好,您只需要将 File Install 配置参数放入 configuration/config.ini 中。但请注意,如果您通过启动器 JAR 或二进制文件启动 Equinox,工作目录将是 configuration/ 或 plugins/ 目录的父目录。
Excerpt from our project config.ini:
摘自我们的项目 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
Other possible solution would be to use Eclipse P2. It is much more advanced and powerful, though I find it quite difficult to use.
其他可能的解决方案是使用Eclipse P2。它更先进、更强大,但我发现它很难使用。
Good thing is that if your application is agnostic to the way bundles are provisioned (and it should be this way), you can always change your mind later.
好消息是,如果您的应用程序不知道捆绑包的配置方式(应该是这种方式),您以后可以随时改变主意。
回答by Alexander Pogrebnyak
Here is the fragment from my automated eclipse installer written in ant.
这是我用 ant 编写的自动 eclipse 安装程序的片段。
This installs all features from the custom update site. The code is 'as is', but I sure would have liked to have something like this to guide me when I wrote it.
这将安装来自自定义更新站点的所有功能。代码是“原样”,但我肯定希望在我编写它时有这样的东西来指导我。
This script also uses antcontribextension to ant. Antcontrib tasks are have 'ac:' namespace prefix
该脚本还使用了antcontrib对 ant 的扩展。Antcontrib 任务有 'ac:' 命名空间前缀
Hope this helps.
希望这可以帮助。
<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=""/>
</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. For its usefulness and complexity Eclipse P2 is surely one of the most underdocumented features.
PS 就其有用性和复杂性而言,Eclipse P2 无疑是文档最少的功能之一。
回答by RaduK
In your eclipse installation folder you have the file bundles.info
, for example:
在您的 eclipse 安装文件夹中,您有文件bundles.info
,例如:
eclipse-3.6.1/configuration/org.eclipse.equinox.simpleconfigurator/bundles.info
You can modify the file to add any bundle you want, and also the start level. But the simplest method of adding bundles to an eclipse installation is to add them to the "dropins" folder. This will lead to an automatic modification of the bundle.info file.
您可以修改该文件以添加您想要的任何包,以及开始级别。但是将包添加到 eclipse 安装的最简单方法是将它们添加到“dropins”文件夹中。这将导致 bundle.info 文件的自动修改。