首页 > 解决方案 > Maven (Tycho) 无法解析 OSGi 核心包

问题描述

我在我的 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

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

标签: mavenosgitycho

解决方案


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 框架的运行时依赖项(不是故意有偏见,但由于您使用的是 tycho,所以我假设 eclipse/equinox 环境。如果您有可用于 p2/tycho 的 Apache Felix 框架,那么如果您愿意,请使用它):

<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.

推荐阅读