我想在我的Eclipse插件中使用logback.slf4j,所以我把它作为要求添加到我的清单中。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 @ ~Desktoptycho_examplebundlescom.example.myplugin.polyglot.build.properties
然后 Tycho 打印已解析的捆绑包列表,这也确认新下载的插件已正确解析:
[DEBUG] Equinox resolver state:
Resolved OSGi state
RESOLVED org.eclipse.osgi_3.11.3.v20170209-1843 : ~.m2repositoryp2osgibundleorg.eclipse.osgi3.11.3.v20170209-1843org.eclipse.osgi-3.11.3.v20170209-1843.jar
RESOLVED ch.qos.logback.classic_1.0.7.v20121108-1250 : ~.m2repositoryp2osgibundlech.qos.logback.classic1.0.7.v20121108-1250ch.qos.logback.classic-1.0.7.v20121108-1250.jar
RESOLVED ch.qos.logback.core_1.0.7.v20121108-1250 : ~.m2repositoryp2osgibundlech.qos.logback.core1.0.7.v20121108-1250ch.qos.logback.core-1.0.7.v20121108-1250.jar
RESOLVED org.slf4j.api_1.7.2.v20121108-1250 : ~.m2repositoryp2osgibundleorg.slf4j.api1.7.2.v20121108-1250org.slf4j.api-1.7.2.v20121108-1250.jar
RESOLVED ch.qos.logback.slf4j_1.0.7.v201505121915 : ~.m2repositoryp2osgibundlech.qos.logback.slf4j1.0.7.v201505121915ch.qos.logback.slf4j-1.0.7.v201505121915.jar
RESOLVED org.eclipse.equinox.app_1.3.400.v20150715-1528 : ~.m2repositoryp2osgibundleorg.eclipse.equinox.app1.3.400.v20150715-1528org.eclipse.equinox.app-1.3.400.v20150715-1528.jar
...
但是,最终我得到以下结果:
NOT RESOLVED com.example.myplugin_0.0.1 : ~Desktoptycho_examplebundlescom.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]
有没有人看到类似的问题?
如 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>