forked from bazelbuild/rules_scala
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scala_config.bzl
37 lines (30 loc) · 1.02 KB
/
scala_config.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
load("//scala:scala_cross_version.bzl", "extract_major_version")
def _default_scala_version():
"""return the scala version for use in maven coordinates"""
return "2.12.14"
def _store_config(repository_ctx):
scala_version = repository_ctx.os.environ.get(
"SCALA_VERSION",
repository_ctx.attr.scala_version,
)
scala_major_version = extract_major_version(scala_version)
config_file_content = "\n".join([
"SCALA_VERSION='" + scala_version + "'",
"SCALA_MAJOR_VERSION='" + scala_major_version + "'",
])
repository_ctx.file("config.bzl", config_file_content)
repository_ctx.file("BUILD")
_config_repository = repository_rule(
implementation = _store_config,
attrs = {
"scala_version": attr.string(
mandatory = True,
),
},
environ = ["SCALA_VERSION"],
)
def scala_config(scala_version = _default_scala_version()):
_config_repository(
name = "io_bazel_rules_scala_config",
scala_version = scala_version,
)