0

I have an SBT (v0.13) project with multiple subprojects with the following dependencies. root -> projectA -> projectB -> projectC. Like so:

lazy val projectA = (project in file("projectA")).enablePlugins(PlayScala).dependsOn(projectB)
lazy val projectB = (project in file("projectB")).enablePlugins(PlayScala).dependsOn(projectC)
lazy val projectC = (project in file("projectC")).enablePlugins(PlayScala)

As I have it now, projectA can reference an API in projectC because of transitive dependency. How can I declare a dependency on projectB without pulling projectC classes into the classpath?

I have come across solutions using notTransitive() in libraryDependencies. Like so:

libraryDependencies ++= Seq(
  "groupId" %% "artifactId" % "version" notTransitive()
)

Even if I do get to declare each one of projectC's dependencies this way (yuck!!!) projectC's APIs themselves are still available to projectA.

Appreciate any ideas on how I could do something like this (pseudo code)?

lazy val projectA = (project in file("projectA")).enablePlugins(PlayScala).dependsOn(projectB).notTransitive() // pseudo-code
Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66
Ram
  • 865
  • 1
  • 8
  • 20

1 Answers1

1

Not sure this is possible. What you can do is remove the dependsOn(projectC) from projectB and add projectC as a library dependency. You should then be able to use notTransitive().

That being said, I'd recommend evaluating why you feel the need to exclude projectC. If projectC is providing libraries which are required upstream, consider breaking those out into their own project which projectB and projectC could both depend on.

Shane Perry
  • 980
  • 7
  • 12