blog220122.Eclipse bundle之MANIFEST headers
- Manifest-Version: 1.0
- Bundle-ManifestVersion: 2
- Bundle-Name: Firewall
- Bundle-SymbolicName: org.eclipse.ui.examples.contributions; singleton:=true
- Bundle-Version: 3.5.0.qualifier
- Bundle-Activator: com.example.Activator
- Require-Bundle: org.eclipse.ui;bundle-version="[3.3.0,4.0.0)", org.eclipse.core.runtime
- Import-Package: org.osgi.util.tracker,org.osgi.service.log;version=1.4
- Export-Package: org.osgi.util.tracker;version=1.3
- Require-Capability: osgi.ee; filter:="(&(osgi.ee=AcmeMin)(version=1.1))"
- Provide-Capability: com.acme.dict; from=nl; to=de; version:Version=1.2
- Bundle-Localization: plugin
- Bundle-RequiredExecutionEnvironment: JavaSE-11
- Bundle-ActivationPolicy: lazy
- Automatic-Module-Name: com.examples.hello
- Bundle-Category: osgi, test, nursery
- Bundle-ClassPath: /jar/http.jar,.
- Fragment-Host: org.eclipse.swt; bundle-version="[3.0.0,4.0.0)"
- Bundle-UpdateLocation: http://www.acme.com/Firewall/bundle.jar
- 一组描述性headers
本文以eclipse 4.20为参考.
MANIFEST.MF中常用到的headers,
Manifest-Version: 1.0
无关osgi.
Bundle-ManifestVersion: 2
2对应的是osgi spec relase 4及之后.
Bundle-Name: Firewall
描述性.
Bundle-SymbolicName: org.eclipse.ui.examples.contributions; singleton:=true
bundle的符号名字, 配合版本号可以唯一标识一个bundle. 是manifest.mf的必设项.
singleton默认是false.
Bundle-Version: 3.5.0.qualifier
bundle的版本号. 最多是4段, major.minor.micro.qualifier. 而qualifer允许alphNum, '_‘和’-'字符.
默认值是0.0.0
Bundle-Activator: com.example.Activator
指定activator.
Require-Bundle: org.eclipse.ui;bundle-version="[3.3.0,4.0.0)", org.eclipse.core.runtime
bundle依赖的bundles.
Import-Package: org.osgi.util.tracker,org.osgi.service.log;version=1.4
bundle依赖的pakcage.
Export-Package: org.osgi.util.tracker;version=1.3
bundle输出的packages. 逗号间隔.
Require-Capability: osgi.ee; filter:="(&(osgi.ee=AcmeMin)(version=1.1))"
bundle依赖的能力集
Provide-Capability: com.acme.dict; from=nl; to=de; version:Version=1.2
bundle提供的能力集.
Bundle-Localization: plugin
指定bundle使用的localization file. 允许plugin.xml和manifest.mf中使用%XXX引用相应字串.
eclipse中通常指定plugin, 会使用./plugin.properties, plugin_de.properties等
默认指定是 Bundle-Localization: OSGI-INF/l10n/bundle, 即使用./OSGI-INF/l10n/bundle[_local].properties
Bundle-RequiredExecutionEnvironment: JavaSE-11
逗号间隔. bundle的运行环境要求.
Bundle-ActivationPolicy: lazy
lazy指明bundle启动后停留在starting状态, 仅在收到第一次请求后方才进入activated状态. 若不指定Bundle-ActivationPolicy, 则直接进入activated状态, 称作eager activation.
Automatic-Module-Name: com.examples.hello
无关osgi, 这是一个关于java 9开始的modular的header, 用于兼容没有modular descriptor(module-info.java)的传统代码.
Bundle-Category: osgi, test, nursery
指定一组category的名字
Bundle-ClassPath: /jar/http.jar,.
指定jar或bundle内的路径做为class path. ‘.‘是bundle根路径.
默认路径既是’.’
Fragment-Host: org.eclipse.swt; bundle-version="[3.0.0,4.0.0)"
指定该fragment的host bundle.
Bundle-UpdateLocation: http://www.acme.com/Firewall/bundle.jar
一组描述性headers
- Bundle-Vendor: OSGi Alliance
- Bundle-Copyright: OSGi © 2002
- Bundle-Description: Network Firewall
- Bundle-ContactAddress: 2400 Oswego Road, Austin, TX 74563
- Bundle-Developers: pkriens; email=pkriens@osgi.org; name=“Peter Kriens”; organization=“OSGi Alliance”
- Bundle-DocURL: http://www.example.com/Firewall/doc
- Bundle-License: Apache-2.0; link=“http://opensource.org/licenses/apache2.0.php”
驽马一架 一花一世界 2022/1/22