Fix Scalafmt default_config
docs for WORKSPACE
#1734
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Makes it clear that
WORKSPACE
users must use a targetLabel
string with thedefault_config
option for thescalafmt
argument ofscala_toolchains
. Notes that the specified config file must exist within a package, including but not limited to having aBUILD
file in the repository root.Motivation
@gergelyfabian noticed this while building gergelyfabian/bazel-scala-example after #1730 landed.
This isn't fixable in code. With this call:
scala_toolchains
looks for the file underexternal/.scalafmt.conf
.Updating
scala_toolchains
to wrapdefault_config
in aLabel
makes it relative to@rules_scala//scala
. This becausescala_toolchains
resides in@rules_scala//scala:toolchains.bzl
.native.package_relative_label
is only available when called from aBUILD
file.Hence
default_config
values underWORKSPACE
must be valid target labels.The problem doesn't exist under Bzlmod; plain file paths will work fine, so long as a
BUILD
file exists at the repository root.