Dependency Resolution Troubleshooting
This guide helps you troubleshoot common dependency resolution issues in Tycho builds.
Common Dependency Resolution Problems
When Tycho cannot resolve project dependencies, you'll see an error message like:
[ERROR] Cannot resolve project dependencies:
Below are common causes and solutions for dependency resolution issues.
Missing Dependencies
Problem
Your build fails with messages indicating that certain bundles, features, or packages cannot be found.
Solution
- Check your target platform definition: Ensure all required p2 repositories are included in your target platform configuration
- Verify repository URLs: Make sure all repository URLs in your target platform are accessible
- Check bundle/feature IDs: Verify that the IDs of dependencies match exactly (case-sensitive)
- Version ranges: Ensure version ranges in your dependencies are correct and match available versions
Version Conflicts
Problem
Multiple versions of the same bundle are available, causing conflicts or resolution failures.
Solution
- Use explicit versions: In your target platform, specify exact versions instead of version ranges when possible
- Review bundle imports: Check
MANIFEST.MFfor conflicting Import-Package or Require-Bundle declarations - Enable dependency resolution debugging: Add
-Xto your Maven command to see detailed resolution logs
Missing or Invalid Metadata
Problem
Tycho complains about missing or invalid p2 metadata.
Solution
- Check repository metadata: Verify that p2 repositories contain valid
content.xmlandartifacts.xmlfiles - Update site refresh: If using local repositories, ensure they are properly generated
- Clear local cache: Remove
~/.m2/repository/p2to force re-download of metadata
Platform-Specific Dependencies
Problem
Build fails when trying to resolve platform-specific fragments or bundles.
Solution
-
Configure target environments: In your
target-platform-configuration, specify all target environments:<plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <environments> <environment> <os>linux</os> <ws>gtk</ws> <arch>x86_64</arch> </environment> <environment> <os>win32</os> <ws>win32</ws> <arch>x86_64</arch> </environment> <environment> <os>macosx</os> <ws>cocoa</ws> <arch>x86_64</arch> </environment> </environments> </configuration> </plugin> -
Use platform filters: Check if your dependencies have platform-specific requirements
Dependency on Maven Artifacts
Problem
Your OSGi bundle depends on plain Maven artifacts that aren't available in p2 repositories.
Solution
-
Use pomDependencies: Configure
target-platform-configurationto consider pom dependencies:<plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>target-platform-configuration</artifactId> <version>${tycho-version}</version> <configuration> <pomDependencies>consider</pomDependencies> </configuration> </plugin> -
Wrap Maven artifacts: Use tools like
bndortycho-extrasto wrap Maven artifacts as OSGi bundles
Circular Dependencies
Problem
Tycho reports circular dependencies between bundles.
Solution
- Review bundle dependencies: Check your
MANIFEST.MFfiles for circular Require-Bundle declarations - Use Import-Package: Prefer
Import-PackageoverRequire-Bundleto reduce coupling - Split packages: Avoid split packages (same package in multiple bundles)
- Refactor: Consider refactoring to break circular dependencies
Target Platform Configuration Issues
Problem
Target platform is not being picked up correctly.
Solution
- Verify target file location: Ensure the path to your
.targetfile is correct - Check target file syntax: Validate your
.targetfile is well-formed XML - Activation: Make sure the target definition is activated (has
<activation>true</activation>)
Debug Tips
Enable Verbose Logging
Run Maven with -X or -Ddebug to get detailed dependency resolution information:
mvn clean install -X
List Resolved Dependencies
Use the list-dependencies goal to see what Tycho has resolved:
mvn org.eclipse.tycho:tycho-maven-plugin:list-dependencies
Dependency Tree
View the dependency tree for your project:
mvn dependency:tree
Additional Resources
Getting Help
If you're still experiencing issues after trying these solutions:
- Check the Tycho issue tracker for similar problems
- Ask questions on the Tycho discussions forum
- Provide detailed information when reporting issues:
- Full error message and stack trace
- Your
pom.xmlconfiguration - Target platform definition
- Tycho version
- Maven and Java versions
