Dependent modules & plugin classpath issues

I'm having an issue similar to My plugin module (A) depends on another module (B) in my project and on an existing plugin (C).  Both the dependent module B and the dependent plugin C require another library D (in this case, scala-library.jar).  As recommended in the other thread, I switched C to be a "Provided" dependency in A.  But I can't switch library D to be Provided in Module B, since it needs that library for its own run configurations. So it's:

  • Plugin module A
    • Module B (module dependency, Compile, not exported)
      • Library D (project library, Compile, not exported)
    • Existing plugin C (project library, Provided, not exported)
      • Library D (included in the plugin C project library)

I was seeing classloader problems when A passed a class from B that referenced D into a method in C.  C had a conflict with its own version of D.  As you suggested in, I switched C to be a "Provided" dependency in A.  But because of the A->B->D dependency, it still copies library D to my plugin lib folder unless I also switch D to be "Provided" inside Module B.  I didn't expect that to be a problem since it's not marked as Exported.

Any ideas how to resolve this?  For now, I have to keep switching my Module B setup to make D Provided every time I run the plugin, then switch it back to Compile when I want to run the apps in B.