Skip to content

Commit 970bc9d

Browse files
committed
Export SCALAFMT_TOOLCHAIN_TYPE constant
Reduces string duplication in `//scala/scalafmt/toolchain/*.bzl` files.
1 parent 1053f9b commit 970bc9d

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

scala/scalafmt/toolchain/setup_scalafmt_toolchain.bzl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
load("//scala/scalafmt/toolchain:toolchain.bzl", "scalafmt_toolchain")
1+
load(
2+
"//scala/scalafmt/toolchain:toolchain.bzl",
3+
"SCALAFMT_TOOLCHAIN_TYPE",
4+
"scalafmt_toolchain",
5+
)
26
load("//scala/scalafmt:scalafmt_repositories.bzl", "scalafmt_artifact_ids")
37
load("//scala:providers.bzl", "declare_deps_provider")
48
load("//scala:scala_cross_version.bzl", "version_suffix")
@@ -28,9 +32,7 @@ def setup_scalafmt_toolchain(
2832
version_suffix(scala_version),
2933
],
3034
toolchain = ":%s_impl" % name,
31-
toolchain_type = Label(
32-
"//scala/scalafmt/toolchain:scalafmt_toolchain_type",
33-
),
35+
toolchain_type = SCALAFMT_TOOLCHAIN_TYPE,
3436
visibility = visibility,
3537
)
3638

scala/scalafmt/toolchain/toolchain.bzl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
load("@io_bazel_rules_scala//scala:providers.bzl", _DepsInfo = "DepsInfo")
22
load("//scala/private/toolchain_deps:toolchain_deps.bzl", "expose_toolchain_deps")
33

4+
SCALAFMT_TOOLCHAIN_TYPE = Label(
5+
"//scala/scalafmt/toolchain:scalafmt_toolchain_type",
6+
)
7+
48
def _scalafmt_toolchain_impl(ctx):
59
toolchain = platform_common.ToolchainInfo(
610
dep_providers = ctx.attr.dep_providers,
@@ -20,10 +24,7 @@ scalafmt_toolchain = rule(
2024
)
2125

2226
def _export_scalafmt_deps_impl(ctx):
23-
return expose_toolchain_deps(
24-
ctx,
25-
"@io_bazel_rules_scala//scala/scalafmt/toolchain:scalafmt_toolchain_type",
26-
)
27+
return expose_toolchain_deps(ctx, SCALAFMT_TOOLCHAIN_TYPE)
2728

2829
export_scalafmt_deps = rule(
2930
_export_scalafmt_deps_impl,
@@ -32,6 +33,6 @@ export_scalafmt_deps = rule(
3233
mandatory = True,
3334
),
3435
},
35-
toolchains = ["@io_bazel_rules_scala//scala/scalafmt/toolchain:scalafmt_toolchain_type"],
36+
toolchains = [SCALAFMT_TOOLCHAIN_TYPE],
3637
incompatible_use_toolchain_transition = True,
3738
)

0 commit comments

Comments
 (0)