Scala SBT: How to limit the number of errors that are shown/printed

If you’re ever at the SBT command line and want to limit the number of compiler errors shown by the compile task, this command sets the maximum number of errors outputted to 5:

set compile / maxErrors := 5

If you want to do that for all tasks, and not just compile, use this instead:

set maxErrors := 5

In the build.sbt file, I think this is the correct syntax to use:

compile / maxErrors := 5