Skip to content
Advertisement

Tycho cannot resolve fragment dependency on other fragment

I want to create an extension for org.eclipse.swt as a fragment. I have created a bundle swt.extension with the following MANIFEST.MF:

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:

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

When I build my project with tycho (mvn clean install) the following error occurs:

1. ERROR in C:<path>tycho-fragment-to-fragment-dependencyswt.extensionsrcorgexampletycho_exampleIExtendedStyleTextContent.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. This is a host bundle and it contains no classes. The actual implementation is in org.eclipse.swt.win32.win32.x86_64 fragment bundle. And it looks like this bundle is not on classpath when tycho-compiler-plugin compiles the project.

Is this a bug of Tycho? Are their any workarounds?

I have put all sources on GitHub: https://github.com/orionll/tycho-fragment-to-fragment-dependency

I use maven 3.1.0

Advertisement

Answer

So, a workaround for this issue was found in mailing lists: 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:

<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:

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

I have also updated the GitHub repository

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement