问题描述
这可能是 Tycho can't resolve indirectly referenced SWT dependencies 的重复,但给出的答案对我不起作用,所以我不确定。
我的目标是将我的目标平台定义文件逐个版本从 Eclipse Luna
更新到最新的 Eclipse 版本,该版本仍然支持 Java 8。
但是我被困在从 Eclipse 2018-09
到 2018-12
的步骤中。
基于 Eclipse 2018-09
,我可以从 Eclipse 启动我的应用程序,并且可以使用 Tycho 1.7.0 构建它。
(Tycho 1.7.0 也是最新版本,仍然支持 Java 8。)
工作目标文件是:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="My Target" sequenceNumber="1622530056">
<locations>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="Installableunit">
<unit id="org.eclipse.equinox.sdk.feature.group" version="3.15.0.v20180904-1442"/>
<unit id="org.eclipse.sdk.ide" version="4.9.0.I20180906-0745"/>
<unit id="org.eclipse.jdt.feature.group" version="3.15.0.v20180906-0745"/>
<unit id="org.eclipse.e4.tools.compat" version="4.7.200.v20180821-1411"/>
<unit id="org.eclipse.e4.tools.services" version="4.8.100.v20180821-1411"/>
<repository id="eclipse-luna" location="http://download.eclipse.org/releases/2018-09"/>
</location>
</locations>
</target>
基于 Eclipse 2018-12
,我可以从 Eclipse 启动我的应用程序,但我无法使用 Tycho 1.7.0 构建它。
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?>
<!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl -->
<target name="My Target" sequenceNumber="1622530674">
<locations>
<location includeMode="planner" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="false" type="Installableunit">
<unit id="org.eclipse.equinox.sdk.feature.group" version="3.16.0.v20181130-2106"/>
<unit id="org.eclipse.sdk.ide" version="4.10.0.I20181206-0815"/>
<unit id="org.eclipse.jdt.feature.group" version="3.16.0.v20181206-1038"/>
<unit id="org.eclipse.e4.tools.compat" version="4.7.300.v20181015-0338"/>
<unit id="org.eclipse.e4.tools.services" version="4.8.200.v20181022-1512"/>
<repository id="eclipse-luna" location="https://download.eclipse.org/releases/2018-12"/>
</location>
</locations>
</target>
我得到的错误如下:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.7.0:compile (default-compile) on project com.my_plugin: Compilation failure: Compilation failure:
[ERROR] C:\path\to\my_project\my_plugin\SomeClass.java:
[ERROR] package some.package;
[ERROR] ^
[ERROR] The type org.eclipse.swt.widgets.Composite cannot be resolved. It is indirectly referenced from required .class files
我已经尝试过的事情
-
我尝试使用 Tycho 2.3.0(和 Java 11)构建项目,但出现间接引用类错误。
-
我尝试按照 Tycho can't resolve indirectly referenced SWT dependencies 的建议添加
jars.extra.classpath = platform:/plugin/org.eclipse.swt.win32.win32.x86_64
。 但后来我收到以下错误:
[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: com.my_plugin 5.0.0.qualifier
[ERROR] Missing requirement: com.my_plugin 5.0.0.qualifier requires 'org.eclipse.equinox.p2.iu; org.eclipse.swt.win32.win32.x86_64 0.0.0' but it Could not be found
- 根据 Eclipse Help,它似乎是
platform:/plugins
而不是platform:/plugin
。 但这又会导致间接引用类错误。
解决方法
问题的根源非常平凡。 我仍在为 Windows 32 位构建我的项目。
如果我删除
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>
从我的 target-platform-configuration
可以再次构建项目。
我尝试用 Vogella 的 tycho-example
复制错误并成功。
如果我将 win32_x86
环境作为 first 环境,我会收到以下错误:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.3.0:compile (default-compile) on project com.vogella.tycho.p2.ui: Compilation failure: Compilation failure:
[ERROR] C:\Users\gillesB\git\gilles\tycho-example\bundles\com.vogella.tycho.p2.ui\src\com\vogella\tycho\p2\ui\handlers\UpdateHandler.java:[1]
[ERROR] package com.vogella.tycho.p2.ui.handlers;
[ERROR] ^
[ERROR] The type org.eclipse.swt.widgets.Shell cannot be resolved. It is indirectly referenced from required .class files
[ERROR] C:\Users\gillesB\git\gilles\tycho-example\bundles\com.vogella.tycho.p2.ui\src\com\vogella\tycho\p2\ui\handlers\UpdateHandler.java:[20]
[ERROR] import org.eclipse.swt.widgets.Shell;
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] The import org.eclipse.swt.widgets.Shell cannot be resolved
[ERROR] C:\Users\gillesB\git\gilles\tycho-example\bundles\com.vogella.tycho.p2.ui\src\com\vogella\tycho\p2\ui\handlers\UpdateHandler.java:[27]
[ERROR] public void execute(final IProvisioningAgent agent,final Shell shell,final UISynchronize sync,[ERROR] ^^^^^
[ERROR] Shell cannot be resolved to a type
[ERROR] C:\Users\gillesB\git\gilles\tycho-example\bundles\com.vogella.tycho.p2.ui\src\com\vogella\tycho\p2\ui\handlers\UpdateHandler.java:[38]
[ERROR] private IStatus checkForUpdates(final IProvisioningAgent agent,[ERROR] ^^^^^
[ERROR] Shell cannot be resolved to a type
[ERROR] C:\Users\gillesB\git\gilles\tycho-example\bundles\com.vogella.tycho.p2.ui\src\com\vogella\tycho\p2\ui\handlers\UpdateHandler.java:[70]
[ERROR] private void configureProvisioningJob(ProvisioningJob provisioningJob,[ERROR] ^^^^^
[ERROR] Shell cannot be resolved to a type
[ERROR] C:\Users\gillesB\git\gilles\tycho-example\bundles\com.vogella.tycho.p2.ui\src\com\vogella\tycho\p2\ui\handlers\UpdateHandler.java:[98]
[ERROR] private void showMessage(final Shell parent,final UISynchronize sync) {
[ERROR] ^^^^^
[ERROR] Shell cannot be resolved to a type
[ERROR] 6 problems (6 errors)
所以间接引用类的错误也出现了。
我使用 Windows 10(64 位)和 Java Corretto 11(64 位)构建了 tycho-example
。
如果我将 win32_x86
环境作为 last 环境,我会收到另一条更清晰的错误消息,即无法找到 32 位依赖项。