我想在我的Eclipse插件中使用logback.slf4j,所以我将它作为一个要求添加到我的MANIFEST.MF文件中:
Require-Bundle: org.eclipse.equinox.app,
org.eclipse.equinox.launcher,
...,
ch.qos.logback.slf4j;bundle-version="1.0.7"
然后我使用额外的调试(mvn clean package -X
)启动构建,在输出中我可以看到logback.slf4j与其依赖项一起正确下载:
[INFO] Fetching 201705151400&countryCode=us&timeZone=1&format=xml from http://www.eclipse.org/downloads/download.php?format=xml&file=/releases/neon/
[INFO] Fetching ch.qos.logback.classic_1.0.7.v20121108-1250.jar.pack.gz from http://download.eclipse.org/releases/neon/201705151400/plugins/ (79,74kB)
[INFO] Fetching ch.qos.logback.classic_1.0.7.v20121108-1250.jar.pack.gz from http://download.eclipse.org/releases/neon/201705151400/plugins/ (79,74kB)
[INFO] Fetching ch.qos.logback.core_1.0.7.v20121108-1250.jar.pack.gz from http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/releases/neon/201705151400/plugins/ (112,71kB)
[INFO] Fetching ch.qos.logback.core_1.0.7.v20121108-1250.jar.pack.gz from http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/releases/neon/201705151400/plugins/ (112,71kB)
[INFO] Fetching org.slf4j.api_1.7.2.v20121108-1250.jar.pack.gz from http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/releases/neon/201705151400/plugins/ (16,96kB)
[INFO] Fetching org.slf4j.api_1.7.2.v20121108-1250.jar.pack.gz from http://ftp-stud.fht-esslingen.de/pub/Mirrors/eclipse/releases/neon/201705151400/plugins/ (16,96kB)
[INFO] Fetching ch.qos.logback.slf4j_1.0.7.v201505121915.jar.pack.gz from http://mirror.tspu.ru/eclipse/releases/neon/201705151400/plugins/ (7,59kB)
[INFO] Fetching ch.qos.logback.slf4j_1.0.7.v201505121915.jar.pack.gz from http://mirror.tspu.ru/eclipse/releases/neon/201705151400/plugins/ (7,59kB)
[INFO] Resolving class path of MavenProject: com.example.myplugin:com.example.myplugin:0.0.1 @ ~\Desktop\tycho_example\bundles\com.example.myplugin\.polyglot.build.properties
然后Tycho打印已解决的捆绑包列表,这也确认新下载的插件已正确解析:
[DEBUG] Equinox resolver state:
Resolved OSGi state
RESOLVED org.eclipse.osgi_3.11.3.v20170209-1843 : ~\.m2\repository\p2\osgi\bundle\org.eclipse.osgi\3.11.3.v20170209-1843\org.eclipse.osgi-3.11.3.v20170209-1843.jar
RESOLVED ch.qos.logback.classic_1.0.7.v20121108-1250 : ~\.m2\repository\p2\osgi\bundle\ch.qos.logback.classic\1.0.7.v20121108-1250\ch.qos.logback.classic-1.0.7.v20121108-1250.jar
RESOLVED ch.qos.logback.core_1.0.7.v20121108-1250 : ~\.m2\repository\p2\osgi\bundle\ch.qos.logback.core\1.0.7.v20121108-1250\ch.qos.logback.core-1.0.7.v20121108-1250.jar
RESOLVED org.slf4j.api_1.7.2.v20121108-1250 : ~\.m2\repository\p2\osgi\bundle\org.slf4j.api\1.7.2.v20121108-1250\org.slf4j.api-1.7.2.v20121108-1250.jar
RESOLVED ch.qos.logback.slf4j_1.0.7.v201505121915 : ~\.m2\repository\p2\osgi\bundle\ch.qos.logback.slf4j\1.0.7.v201505121915\ch.qos.logback.slf4j-1.0.7.v201505121915.jar
RESOLVED org.eclipse.equinox.app_1.3.400.v20150715-1528 : ~\.m2\repository\p2\osgi\bundle\org.eclipse.equinox.app\1.3.400.v20150715-1528\org.eclipse.equinox.app-1.3.400.v20150715-1528.jar
...
但是,最后我得到以下内容:
NOT RESOLVED com.example.myplugin_0.0.1 : ~\Desktop\tycho_example\bundles\com.example.myplugin
Missing Constraint: Require-Bundle: ch.qos.logback.slf4j; bundle-version="1.0.7"
[ERROR] Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle com.example.myplugin cannot be resolved
[ERROR] Resolution errors:
[ERROR] Bundle com.example.myplugin - Missing Constraint: Require-Bundle: ch.qos.logback.slf4j; bundle-version="1.0.7"
[ERROR] -> [Help 1]
有没有人见过类似的问题?
答案 0 :(得分:0)
如https://stackoverflow.com/a/45190630/301049
中所述我设法通过以下pom.xml
插件配置在target-platform-configuration
中显式地添加了对测试插件片段的依赖性:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<configuration>
<dependency-resolution>
<extraRequirements>
<requirement>
<type>eclipse-plugin</type>
<id>org.acme.module.fragment</id>
<versionRange>0.0.0</versionRange>
</requirement>
</extraRequirements>
</dependency-resolution>
</configuration>
</plugin>