Search code examples
dependenciesosgitycho

Tycho downloads dependency but fails to resolve it


I have an odd problem with Tycho 0.15.0. There are 8 dependencies in my MANIFEST.MF but Tycho fails to resolve one of them. The output looks like this:

[INFO] 1 operation remaining.
[INFO] Fetching org.eclipse.xtext.logging_1.2.15.v201206120633.jar (4kB of 10.12kB at 0B/s) from http://my.server.com/p2-3.7.2/plugins/
[INFO] Resolving class path of MavenProject: <...my project ...> @ <...path to my project...>/pom.xml
[ERROR] Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle <...my project...> cannot be resolved
[ERROR] Resolution errors:
[ERROR] Bundle <...my project...> - Missing Constraint: Require-Bundle: org.eclipse.xtext.logging; bundle-version="1.2.15"
[ERROR] -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle <...my project...> cannot be resolved
Resolution errors:
Bundle <...my project...> - Missing Constraint: Require-Bundle: org.eclipse.xtext.logging; bundle-version="1.2.15"

What I know:

  1. The jar org.eclipse.xtext.logging_1.2.15.v201206120633.jar exists
  2. The jar isn't corrupt
  3. Tycho can download it from my p2 server (I have ~/.m2/repository/p2/osgi/bundle/org.eclipse.xtext.logging/1.2.15.v201206120633/org.eclipse.xtext.logging-1.2.15.v201206120633.jar on my computer)
  4. The MANIFEST.MF looks correct:

    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.8.2
    Bundle-Vendor: %providerName
    Bundle-Localization: fragment
    Fragment-Host: org.apache.log4j;bundle-version="[1.2.15,1.2.16)"
    Bundle-RequiredExecutionEnvironment: J2SE-1.5
    Bundle-Name: %pluginName
    Bundle-SymbolicName: org.eclipse.xtext.logging;singleton:=true
    Created-By: 1.5.0_22-b03 (Sun Microsystems Inc.)
    Bundle-Version: 1.2.15.v201206120633
    Bundle-ManifestVersion: 2
    Import-Package: org.eclipse.core.runtime,org.osgi.framework;version="1
    .5.0"
    
  5. Tycho 0.16.0 has the same problem.

Any ideas?


Solution

  • You are seeing this behaviour for the following reasons:

    • org.eclipse.xtext.logging is a fragment, not a standalone bundle (you can see that because it has Fragment-Host in the MANIFEST.MF which defines the other bundle to which this one is a fragment of).
    • The way fragments are encoded in p2, a Require-Bundle to a fragment can be resolved in p2. The p2-based dependency resolution determines which artifacts of the target platform are downloaded to the local Maven repository.
    • A Require-Bundle to a fragment will not resolve in an OSGi server. For computing the class path (hence the console output Resolving class path), Tycho uses the Equinox resolver. That resolver detects correctly that Require-Bundle to fragments is invalid.