这可能是对https://stackoverflow.com/questions/67104594/tycho-cant-resolve-indirectly-referenced-swt-dependencies的重复,但给出的答案对我不起作用,所以我不确定。
我的目标是将目标平台定义文件的版本从Eclipse Luna更新到最近的Eclipse,该版本仍然支持Java 8,但我仍然停留在从Eclipse2018-09到2018-12的步骤中。
基于Eclipse,我可以从2018-09启动我的应用程序,并可以使用Tycho1.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启动我的应用程序,但是我不能用Tycho1.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我已经试过的东西
jars.extra.classpath = platform:/plugin/org.eclipse.swt.win32.win32.x86_64的提议添加Tycho无法解决间接引用的SWT依赖关系。但是,我得到了以下错误:[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 foundplatform:/plugins而不是platform:/plugin。但这再次导致间接引用的类错误。发布于 2021-06-02 06:31:32
这个问题的根源是非常平凡的。我还在为Windows 32位构建我的项目。
如果我移除
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86</arch>
</environment>从我的target-platform-configuration中可以重新构建该项目。
我试图复制Vogella的tycho-example错误,并取得了成功。
如果将win32_x86环境作为第一个环境,则会得到以下错误:
[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, 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:[70]
[ERROR] private void configureProvisioningJob(ProvisioningJob provisioningJob, 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:[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)因此,间接引用的类错误也会出现。我用Windows10(64位)和Java 11 (64位)构建了tycho-example。
如果我将win32_x86环境作为最后一个环境,我会得到另一个更清晰的错误消息,即找不到32位依赖项。
https://stackoverflow.com/questions/67790165
复制相似问题