Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running sbt command on the meta-build level

Tags:

sbt

sbt-plugin

sbt allows us to run sbt commands on the root project level.

How can I run commands on the meta-build level? (that is defined in root/project/project dir)

my use case is that some of my sbt plugins have different versions of the same dependency, and the older dependencies are evicted. I would like to investigate using sbt-dependency-graph

like image 455
lev Avatar asked Jan 30 '23 00:01

lev


1 Answers

You can use reload plugins from the main project sbt session to switch into context of the build project:

sbt:root> reload plugins
[snip noise]

sbt:project> show libraryDependencies
[shows your sbt plugins from root/plugins.sbt along with their deps]

sbt:project> reload return
[back to the main project]

sbt:root>

As Jorge noted, you can install sbt-dependency-graph in the meta-build of root/project/project/plugins.sbt to make it available to the build project context of reload plugins. As always, recall that sbt is recursive—from the build project you can do reload plugins again to reach the meta-build level. From there show libraryDependencies would show only sbt-dependency-graph from root/project/project, for example.

This is a quirky aspect of sbt UX in my opinion, because it's not exactly intuitive that the reload command would be the path to this feature, but as long as you can remember that part, help reload gives a good summary for recalling the subcommands.

I don't know if this is the "wrong" way in any regard, but I find it more convenient than changing directories since I don't need to start another sbt session, and can move back and forth or recurse further without restarting.

like image 125
ches Avatar answered May 11 '23 06:05

ches