Reputation: 153
I have a parent project A and a child project B that inherits from A, using scala SBT build.
The parent A is dependent on a library with version "l1" that has a sub-library with version p1, but it needs a different version of a sub-library/package in it with version p2.
To achieve this I have included the sub-library version p2 in the dependencyOverrides
in the parent build.sbt
.
I need the child to be dependent on the same library l1 but also on the sub-library version p2. Currently what is happening is l1 is inherited by the child and p2 is present in the parent, but only version p1 of the sub-library originally in the library is being included in the child.
I can see that if I give the same dependency override in the child build.sbt
as in the parent, it works by including sub-library version p2 in the child also.
I want to know if there is an implicit way to inherit the dependency overrides for the parent to the child.
My sbt version is 1.8.0 and below is the child definition in parent's build.sbt
.
//child definition
lazy val child = Project("child",file("child"))
.dependsOn(parent % "provided->provided;compile->compile;test->test;runtime->runtime")
.settings(
name := "child",
assemblySettings
)
Upvotes: 1
Views: 1385
Reputation: 27535
dependencyOverride
- libraryDependencies
is enough and dependencyOverride
introduces some issues, as it was intended for an internal use,assemblySettings
libraryDependencies
in parent, subproject should inherit parent's versions as transitive dependenciesExample:
val dependencies = libraryDependencies ++= Seq(
...
)
val parent = (project in file("parent"))
.settings(dependencies)
.settings(assemblySettings)
val parent = (project in file("parent"))
.dependsOn(parent % "provided->provided;compile->compile;test-
>test;runtime->runtime")
.settings(dependencies) // actually unnecessary
.settings(assemblySettings)
Upvotes: 2