sbt: How to show the file/directory with 'doc' and 'package' commands

When you use sbt to build Scala projects — at least with version 1.4.4 in November, 2020 — if you use commands like doc, package, packageDoc, and probably assembly, sbt doesn’t show the directory where your output JAR files are written.

SBT: How to show file output locations

I don’t know why it doesn’t show those output locations — maybe people who use sbt all the time don’t want to see those things, such as if they have sbt doc or sbt package commands in a shell script — but if you want to see the directory and name of the files that sbt creates, use the show command before other commands like doc and package, like this:

sbt> show doc
sbt> show package

Here’s what the output of those commands looks like when using sbt 1.4.4 and Scala 3.0.0-M2:

sbt> show doc
target/scala-3.0.0-M2/api

sbt> show package
target/scala-3.0.0-M2/stringutils_3.0.0-M2-1.0.jar

So that’s a solution for when you need to see those sbt output files and directories.

You can also use this with other directives. For example, when you use SBT Assembly, you can use a show assembly command.

Also, when I asked this question on the gitter.im/sbt channel, a Github/Gitter user with the handle @nigredo-tori also suggested this:

see Compile / packageBin / artifactPath and Compile / packageDoc / artifactPath settings

Another possible solution: sbt logging levels

Another possible solution is to set the sbt logging level to debug before running commands like doc, package, packageDoc, and assembly. You do this by typing the debug command at the sbt shell prompt:

sbt> debug

While I’m in this neighborhood, here are the commands for setting sbt log levels:

error
warn
info
debug

In summary, if you wanted to know how to see the locations of the files and directories that are created by those sbt commands, I hope these examples are helpful.