Skip to content

Commit 7575df7

Browse files
committed
Replace Scalafmt default_config alias with symlink
This avoids the need for the user to use `exports_files` so `@rules_scala_toolchains//scalafmt:config` can access the config file. Essentially restores the API from before bazel-contrib#1725, but still fixes the same bug as bazel-contrib#1725.
1 parent 7722987 commit 7575df7

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

BUILD

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
exports_files([".scalafmt.conf"])

scala/extensions/deps.bzl

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ _scalafmt_attrs = {
9696
"default_config": attr.label(
9797
default = _scalafmt_defaults["default_config"],
9898
doc = "The default config file for Scalafmt targets",
99+
allow_single_file = True,
99100
),
100101
}
101102

scala/toolchains_repo.bzl

+5-4
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def _scala_toolchains_repo_impl(repository_ctx):
6868

6969
if repo_attr.scalafmt:
7070
toolchains["scalafmt"] = _SCALAFMT_TOOLCHAIN_BUILD
71-
format_args["scalafmt_default_config"] = (
72-
repo_attr.scalafmt_default_config
71+
repository_ctx.symlink(
72+
repository_ctx.path(repo_attr.scalafmt_default_config),
73+
"scalafmt/.scalafmt.conf",
7374
)
7475

7576
# Generate a root package so that the `register_toolchains` call in
@@ -187,9 +188,9 @@ load(
187188
"setup_scalafmt_toolchains",
188189
)
189190
190-
alias(
191+
filegroup(
191192
name = "config",
192-
actual = "{scalafmt_default_config}",
193+
srcs = [":.scalafmt.conf"],
193194
visibility = ["//visibility:public"],
194195
)
195196

0 commit comments

Comments
 (0)