daml/bazel_tools/scala_version.bzl
Moritz Kiefer ba6ba9019f
Release Scala 2.13 artifacts (#8858)
* Release Scala 2.13 artifacts

changelog_begin
changelog_end

* Dedup default scala version

changelog_begin
changelog_end
2021-02-17 14:32:04 +01:00

43 lines
1.2 KiB
Python

# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
default_scala_version = "2.12.12"
def _impl(ctx):
# Generates an empty BUILD file, because we do not need to build anything.
ctx.file(
"BUILD",
content = """exports_files(["index.bzl"])""",
executable = False,
)
version = ctx.os.environ.get("DAML_SCALA_VERSION", default = default_scala_version)
if version == "":
version = default_scala_version
suffix = version.replace(".", "_")
major = version[:version.rfind(".")]
major_suffix = major.replace(".", "_")
ctx.file(
"index.bzl",
content =
"""
scala_version = "{version}"
scala_major_version = "{major}"
scala_version_suffix = "{suffix}"
scala_major_version_suffix = "{major_suffix}"
""".format(
version = version,
major = major,
suffix = suffix,
major_suffix = major_suffix,
),
executable = False,
)
scala_version = repository_rule(
environ = ["DAML_SCALA_VERSION"],
implementation = _impl,
attrs = {},
)