Maven (Tycho) 无法解析 OSGi 核心包

Maven (Tycho) cannot resolve OSGi Core bundle

我的 POM 依赖于 "org.osgi:osgi.core" (7.0.0)。原因是我需要访问 "org.osgi.framework" 包。我正在使用 Maven (3.6) 和 Tycho (1.5.1) 进行构建。构建平台运行 Debian 10 和 Java 11.

我收到以下错误:

Missing requirement: osgi.core 7.0.0.201802012106 requires 'osgi.unresolvable; (&(!(must.not.resolve=*))(must.not.resolve=*))' but it could not be found

但是,如果删除依赖项,则会出现以下错误:

Missing requirement: my.bundle 0.0.0.qualifier requires 'java.package; org.osgi.framework 1.7.0' but it could not be found

出了什么问题?我该如何解决这个问题?

I get the following error:

Missing requirement: osgi.core 7.0.0.201802012106 requires 'osgi.unresolvable; (&(!(must.not.resolve=*))(must.not.resolve=*))' but it could not be found

"companion jars" 不适用于运行时,因为解析是运行时操作(即使在构建期间执行,即用于部署目的)不应包括在内(因此标有 unresolvable 要求)。

However, if I remove the dependency I get the following error:
Missing requirement: my.bundle 0.0.0.qualifier requires 'java.package; org.osgi.framework 1.7.0' but it could not be found 

这意味着您没有可用的运行时框架!添加对 equinox 框架的运行时依赖(不是故意有偏见,但由于你使用的是第谷,我假设 eclipse/equinox 景观。如果你有 Apache Felix 框架可用于 p2/tycho 然后使用它,如果你喜欢):

<dependency>
    <groupId>org.eclipse.platform</groupId>
    <artifactId>org.eclipse.osgi</artifactId>
    <version>3.x.0</version>
    <scope>runtime</scope>
</dependency>
// of course use tycho mechanism for above.