在Eclipse中使用来自现有JAR Archives 向导的插件是否正确将OSGi包添加到Eclipse RCP项目?我知道Eclipse RCP使用OSGi包,并且该向导有效地重新打包JAR以使它们成为OSGi包,但是如果MANIFEST.MF文件已经包含OSGi包装信息怎么办?
作为一个例子,我想将Jersey REST Client添加到RCP项目,而jersey-client.jar的MANIFEST.MF包含以下内容
Manifest-Version: 1.0
Bnd-LastModified: 1504605074705
Build-Jdk: 1.8.0_144
Built-By: pavel
Bundle-Description: Jersey core client implementation
Bundle-DocURL: http://www.oracle.com/
Bundle-License: https://oss.oracle.com/licenses/CDDL+GPL-1.1, https://
oss.oracle.com/licenses/CDDL+GPL-1.1
Bundle-ManifestVersion: 2
Bundle-Name: jersey-core-client
Bundle-SymbolicName: org.glassfish.jersey.core.jersey-client
Bundle-Vendor: Oracle Corporation
Bundle-Version: 2.26.0
Created-By: Apache Maven Bundle Plugin
Export-Package: org.glassfish.jersey.client;uses:="javax.inject,javax.
net.ssl,javax.ws.rs,javax.ws.rs.client,javax.ws.rs.core,javax.ws.rs.e
xt,org.glassfish.jersey,org.glassfish.jersey.client.spi,org.glassfish
.jersey.internal,org.glassfish.jersey.internal.inject,org.glassfish.j
ersey.internal.util,org.glassfish.jersey.internal.util.collection,org
.glassfish.jersey.message,org.glassfish.jersey.message.internal,org.g
lassfish.jersey.spi";version="2.26.0",org.glassfish.jersey.client.aut
hentication;uses:="javax.ws.rs,javax.ws.rs.client,javax.ws.rs.core";v
ersion="2.26.0",org.glassfish.jersey.client.filter;uses:="javax.ws.rs
.client,javax.ws.rs.core";version="2.26.0",org.glassfish.jersey.clien
t.spi;uses:="javax.net.ssl,javax.ws.rs.client,javax.ws.rs.core,org.gl
assfish.jersey.client,org.glassfish.jersey.process";version="2.26.0"
Import-Package: javax.annotation;version="[1.2,2)",javax.inject;versio
n="[1.0,2)",javax.net.ssl,javax.ws.rs;version="[2.1,3)",javax.ws.rs.c
lient;version="[2.1,3)",javax.ws.rs.core;version="[2.1,3)",javax.ws.r
s.ext;version="[2.1,3)",org.glassfish.jersey;version="[2.26,3)",org.g
lassfish.jersey.client.spi,org.glassfish.jersey.internal;version="[2.
26,3)",org.glassfish.jersey.internal.guava;version="[2.26,3)",org.gla
ssfish.jersey.internal.inject;version="[2.26,3)",org.glassfish.jersey
.internal.l10n;version="[2.26,3)",org.glassfish.jersey.internal.spi;v
ersion="[2.26,3)",org.glassfish.jersey.internal.util;version="[2.26,3
)",org.glassfish.jersey.internal.util.collection;version="[2.26,3)",o
rg.glassfish.jersey.message;version="[2.26,3)",org.glassfish.jersey.m
essage.internal;version="[2.26,3)",org.glassfish.jersey.model.interna
l;version="[2.26,3)",org.glassfish.jersey.process;version="[2.26,3)",
org.glassfish.jersey.process.internal;version="[2.26,3)",org.glassfis
h.jersey.spi;version="[2.26,3)",org.glassfish.jersey.uri;version="[2.
26,3)"
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Tool: Bnd-3.2.0.201605172007
使用现有JAR Archives 向导中的插件是否正确将此依赖项添加到RCP项目,或者如果它已经是OSGi包,是否应该使用其他方法?
答案 0 :(得分:1)
来自现有JAR存档的插件向导旨在从未打包为OSGi包的普通JAR创建包(包括OSGi元数据)。
因此,在您的情况下,您可以按原样使用jersey-client.jar
。
通常,更有趣的问题是在哪里配置捆绑包以便可以从RCP应用程序轻松使用它。如果您正在使用目标平台定义和/或Tycho for CI构建,您可能希望能够从p2存储库中获取该捆绑包。
p2-maven-plugin可以帮助创建Jersey包以及可能的其他依赖项的p2存储库。
Eclipse Orbit项目提供了一个p2存储库,其中包含其他Eclipse项目常用的包。目录中还列出了Jersey客户端。也许这个已经适合你的需求。