简体   繁体   English

第谷无法解析片段对其他片段的依赖

[英]Tycho cannot resolve fragment dependency on other fragment

I want to create an extension for org.eclipse.swt as a fragment.我想为org.eclipse.swt创建一个扩展作为片段。 I have created a bundle swt.extension with the following MANIFEST.MF:我使用以下 MANIFEST.MF 创建了一个包swt.extension

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Extension
Bundle-SymbolicName: swt.extension
Bundle-Version: 1.0.0.qualifier
Fragment-Host: org.eclipse.swt;bundle-version="3.102.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

Also, I have created an interface which extends an interface from SWT:另外,我创建了一个接口,它扩展了 SWT 的接口:

public interface IExtendedStyleTextContent extends org.eclipse.swt.custom.StyledTextContent {
}

When I build my project with tycho ( mvn clean install ) the following error occurs:当我使用 tycho ( mvn clean install ) 构建我的项目时,会发生以下错误:

1. ERROR in C:\<path>\tycho-fragment-to-fragment-dependency\swt.extension\src\org\example\tycho_example\IExtendedStyleTextContent.java (at line 3)

public interface IExtendedStyleTextContent extends org.eclipse.swt.custom.StyledTextContent {

                                                   ^^^^^^^^^^^

org.eclipse cannot be resolved to a type

It seems that tycho resolves only org.eclipse.swt jar.似乎第谷只解析 org.eclipse.swt jar。 This is a host bundle and it contains no classes.这是一个主机包,它不包含任何类。 The actual implementation is in org.eclipse.swt.win32.win32.x86_64 fragment bundle.实际实现在 org.eclipse.swt.win32.win32.x86_64 片段包中。 And it looks like this bundle is not on classpath when tycho-compiler-plugin compiles the project.当 tycho-compiler-plugin 编译项目时,看起来这个包不在类路径上。

Is this a bug of Tycho?这是第谷的bug吗? Are their any workarounds?他们有什么解决方法吗?

I have put all sources on GitHub: https://github.com/orionll/tycho-fragment-to-fragment-dependency我已将所有来源放在 GitHub 上: https : //github.com/orionll/tycho-fragment-to-fragment-dependency

I use maven 3.1.0我使用 Maven 3.1.0

So, a workaround for this issue was found in mailing lists: http://dev.eclipse.org/mhonarc/lists/tycho-user/msg03277.html因此,在邮件列表中找到了解决此问题的方法: http : //dev.eclipse.org/mhonarc/lists/tycho-user/msg03277.html

To solve the issue one should add the following sections to POM and build.properties:为了解决这个问题,应该在 POM 和 build.properties 中添加以下部分:

<build>
  <plugins>
    <plugin>
      <groupId>org.eclipse.tycho</groupId>
      <artifactId>target-platform-configuration</artifactId>
      <version>${tycho-version}</version>
      <configuration>
        <dependency-resolution>
          <extraRequirements>
            <requirement>
              <type>eclipse-plugin</type>
              <id>org.eclipse.swt.win32.win32.x86_64</id>
              <versionRange>[3.0.0,4.0.0)</versionRange>
            </requirement>
          </extraRequirements>
        </dependency-resolution>
      </configuration>
    </plugin>
  </plugins>
</build>

build.properties: build.properties:

extra.. = platform:/fragment/org.eclipse.swt.win32.win32.x86_64

I have also updated the GitHub repository我还更新了 GitHub 存储库

This is not so much a bug, but a fundamental issue with the design of PDE/Tycho: the build dependencies are kept as close as possible to the runtime dependencies.这与其说是一个错误,不如说是 PDE/Tycho 设计的一个基本问题:构建依赖项尽可能地接近运行时依赖项。 In this case you need to add a build dependency that doesn't have a corresponding dependency in the runtime, therefore cannot be declared through the OSGi manifest.在这种情况下,您需要添加一个在运行时没有相应依赖项的构建依赖项,因此无法通过 OSGi 清单声明。

The following mailing list message appears to offer a workaround for exactly this issue: http://dev.eclipse.org/mhonarc/lists/tycho-user/msg03277.html以下邮件列表消息似乎提供了解决此问题的方法: http : //dev.eclipse.org/mhonarc/lists/tycho-user/msg03277.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 getLayoutInflater()无法解析为片段 - getLayoutInflater() cannot resolve in fragment 导入无法通过使用Tycho的测试插件片段解决,但可以在Eclipse中使用 - Import cannot be resolved by test plugin fragment using Tycho but works in Eclipse “无法解析片段中的 findviewbyid”错误 - "cannot resolve findviewbyid in fragment" error 无法解析片段中的 onItemClickListener 方法 - Cannot resolve method onItemClickListener in fragment 使用Tycho构建片段时出错:“ xyz.fragment无法安装在此环境中,因为它的过滤器不适用” - Error when building fragment with Tycho: “xyz.fragment cannot be installed in this environment because its filter is not applicable” setFragment 不能应用于其他片段 - setFragment cannot be applied to other fragment 无法解析@Nullable片段中的方法&#39;findViewById(int)&#39; - Cannot resolve method 'findViewById(int)' in @Nullable fragment 在滑动菜单片段中无法解析符号'TabLayout' - Cannot resolve symbol 'TabLayout' in sliding menu fragment TimePickerDialogFragment:“无法解析方法.add(片段,字符串) - TimePickerDialogFragment: "Cannot resolve method .add(fragment, string) 无法为片段中的微调适配器解析构造函数 - cannot resolve constructor for spinner adapter in fragment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM