SBT Dynamic Project Dependency

55 views Asked by At

I recently need to integrate some projects as submodules, and each of them has its own build.sbt. And there are also dependencies between submodules. Therefore, I need to dynamically convert the libraryDependencies to dependsOn format.

The project structure looks like this, and root depends on A and B, while A also depends on B.

.
├── build.sbt
├── projA
│   ├── build.sbt
│   └── src
├── projB
│   ├── build.sbt
│   └── src
└── src
    └── main

Since it seems appends .setting/.denpensOn directly to a project that already has build.sbt is ineffective.

//  ./build.sbt
lazy val root = (project in file("."))
  .settings(commonSettings)
  .dependsOn(A, B)

lazy val A = (project in file("projA"))
  .settings(commonSettings)        <-- not work
  .dependsOn(B)                    <-- not work

lazy val B = (project in file("projB"))
  .settings(commonSettings)        <-- not work

So, I try this method to dynamically edit libraryDependencies, but this approach is only able to modify settings. The inter-project dependencies seem to be not controlled by the settings.

Is there any way to dynamically add dependsOn to the project? Or how to make the depensOn appended on the subproject in the root build.sbt works? Thanks.

0

There are 0 answers