Reputation: 6102
Is there's a sbt-dependency-graph
equivalent for inter-project dependencies (ie. projectA dependsOn projectB
)? Either as an sbt plugin or using sbt internals.
Upvotes: 3
Views: 399
Reputation: 8996
Unfortunately, I don't know of a plugin to do what you need.
Here is a simple SBT task to quickly show all the dependencies in the project. This is really basic, I am sure we can do something better in the visualization/formatting of the output. Add the following in your build.sbt
file.
lazy val showInterProjectDependencies = taskKey[String]("Print inter-project dependencies")
showInterProjectDependencies := {
val pd: Seq[ModuleID] = projectDependencies.value
val str = name + " -> " + pd.map(_.name).mkString(", ")
streams.value.log.info(str)
str
}
If you have a multi-project build, then add this inside your project template:
def projectTemplate(name: String, dir: String): Project = {
Project(id = name, base = file(dir)).settings(
showInterProjectDependencies := {
val p: Seq[ModuleID] = projectDependencies.value
val str = name + " -> " + p.map(_.name).mkString(", ")
streams.value.log.info(str)
str
},
...
}
If you have a Root project that aggregates all your subproject then calling showInterProjectDependencies
will recursively call the task in all the subproject. E.g.:
lazy val projectRoot = (
projectTemplate("MyProjectRoot", ".")
aggregate(subproject1, subproject2, ...)
)
Upvotes: 3