Let's say I'm writing a Scala library L that depends on some dependency D and is consumed by a program P and another program Q. P depends on version 3.2 of D directly while Q depends on version 3.3 directly.
Between those two versions D's API was shuffled so that to get the same function I use in L, I must write different import statements in L. Likewise P relies on 3.2-specific behavior whereas Q relies on 3.3-specific behavior.
Now, normally what will happen is that the most recent version of D will be chosen when compiling P and Q, but this will cause either P to break if L depends on version 3.3 of the library or L to break when compiling Q if L depends on version 3.2 of D.
I would ideally like the same version of L to be used by both P and Q since L's public API does not change. Is this possible?
The general method that comes to mind is conditional compilation of L based on dependency resolution. This seems unachievable though in the JVM world since we don't transitively compile a project's dependencies and instead rely on precompiled artifacts.
I can do this right now with SBT if D is Scala itself (i.e. cross-compiling with different Scala versions and having version specific code live in its own directories), but this is something of a hack from the viewpoint of dependency resolution since SBT changes the names of the artifacts to allow this cross-compilation to work.