My host plugin declares an optional dependency to another plugin. In the build of a fragment to my host plugin, the optionally required plugin can't be found by Tycho. That means I get compile errors since the classes from the optional dependency can't be resolved.
If I remove the optional flag in host plugin, the Tycho build works fine. I'm using Maven 3.0.4 and Tycho 0.15.0.
I am undecided if this is really a bug in Tycho, or rather by design.
This is the background to the observable behaviour: Tycho aims to do its dependency resolution in the same way as p2 would do when installing your bundle. When you declare an optional dependency to a bundle, that bundle will not be installed by p2 (unless some other bundle or feature has a non-optional dependency to that bundle). So following this rule, Tycho would also not consider this optional dependency during dependency resolution and class path computation.
However, there is a switch to deviate from the default p2 behaviour (in target-platform-configuration
the configuration option dependency-resolution/optionalDependencies
):
require
, all optional dependencies of the current bundle are treated as required at compile time. Since this is what you normally want, this is the default.ignore
, all optional dependencies of the current bundle are ignored at compile time.Note that this special handling only applies to the optional dependencies of the current bundle, and not to other bundles in the dependency chain. Host bundles are currently treated as any other dependency, we may consider treating them specially when building a fragment.
You have the following options for a workaround: