Here’s our problem: we have a big library com.example.big-library:X
that bundles com.example.small-library:Y
, and declares it as a capability in the Gradle metadata. We have consumers using small-library
alone and consumers using both big-library
and small-library
.
We would like to enforce that consumers of big-library
declare a dependency onsmall-library
that matches the exact version provided by big-library
(there is some native code involved and using a mismatched version can cause troubles).
E.g. if big-library comes with small-library:3.1
then we want to fail the build if there’s a dependency in the same project to small-library:3.2
Right now we have this resolutionStrategy:
resolutionStrategy.capabilitiesResolution.withCapability("com.example.small-library") {
def toBeSelected = candidates.find { it.id instanceof ModuleComponentIdentifier && it.id.module.contains('big-library') }
if (toBeSelected != null) {
select(toBeSelected)
}
because 'use small-library from big-library instead of standalone'
}
Is there a way to update this resolutionStrategy to only resolve if the capabilities are of the same version? I cannot find a way to do that (but it feels like there should be one).
The actual bug is here for the curious: Incompatible glean versions · Issue #11276 · mozilla-mobile/android-components · GitHub