Skip to content

Commit

Permalink
compatibility: Use the same Scala version as the root. (digital-asset…
Browse files Browse the repository at this point in the history
…#9502)

* compatibility: Use the same Scala version as the root.

It's confusing to get out of sync. `compatibility` was using Scala
2.12.12 while the root was on 2.12.13.

This brings them in sync to 2.12.13.

CHANGELOG_BEGIN
CHANGELOG_END

* Factor out Scala artifacts into scala_version.bzl.

* Bazel: Explicitly specify artifact hashes for Scala 2.13.

Not strictly necessary, as we _happen_ to depend on the same point
release as the Bazel Scala plugin, but this is incidental and we don't
want to bank on it.
  • Loading branch information
SamirTalwar authored Apr 26, 2021
1 parent dc2a79f commit 3db928c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 44 deletions.
23 changes: 2 additions & 21 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ load("//bazel_tools:scala_version.bzl", "scala_version_configure")

scala_version_configure(name = "scala_version")

load("@scala_version//:index.bzl", "scala_major_version", "scala_version")
load("@scala_version//:index.bzl", "scala_artifacts", "scala_major_version", "scala_major_version_suffix", "scala_version")

dadew(name = "dadew")

Expand Down Expand Up @@ -600,8 +600,6 @@ dev_env_tool(
win_tool = "nsis-3.04",
) if is_windows else None

load("@scala_version//:index.bzl", "scala_major_version_suffix")

# Scaladoc
nixpkgs_package(
name = "scala_nix",
Expand Down Expand Up @@ -721,26 +719,9 @@ load(
"scala_repositories",
)

# note some dependencies in bazel-jvm-deps.bzl (e.g. silencer_plugin) refer to the current scala version:
scala_repositories(
fetch_sources = True,
overriden_artifacts =
{
"2.12": {
"io_bazel_rules_scala_scala_compiler": {
"artifact": "org.scala-lang:scala-compiler:%s" % scala_version,
"sha256": "ea971e004e2f15d3b7569eee8b559f220e23b9993e688bbe986f97938d1dc9f9",
},
"io_bazel_rules_scala_scala_library": {
"artifact": "org.scala-lang:scala-library:%s" % scala_version,
"sha256": "1bb415cff43f792636556a1137b213b192ab0246be003680a3b006d01235dd89",
},
"io_bazel_rules_scala_scala_reflect": {
"artifact": "org.scala-lang:scala-reflect:%s" % scala_version,
"sha256": "2bd46318d87945e72eb186a7b5ea496c43cf8f0aabc6ff11b3e7962f8635e669",
},
},
}.get(scala_major_version, {}),
overriden_artifacts = scala_artifacts,
)

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
Expand Down
47 changes: 40 additions & 7 deletions bazel_tools/scala_version.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@
# Keep in sync with /nix/nixpkgs.nix and /release/src/Main.hs
default_scala_version = "2.12.13"

scala_artifacts = {
"2.12.13": {
"io_bazel_rules_scala_scala_compiler": {
"artifact": "org.scala-lang:scala-compiler:2.12.13",
"sha256": "ea971e004e2f15d3b7569eee8b559f220e23b9993e688bbe986f97938d1dc9f9",
},
"io_bazel_rules_scala_scala_library": {
"artifact": "org.scala-lang:scala-library:2.12.13",
"sha256": "1bb415cff43f792636556a1137b213b192ab0246be003680a3b006d01235dd89",
},
"io_bazel_rules_scala_scala_reflect": {
"artifact": "org.scala-lang:scala-reflect:2.12.13",
"sha256": "2bd46318d87945e72eb186a7b5ea496c43cf8f0aabc6ff11b3e7962f8635e669",
},
},
"2.13.3": {
"io_bazel_rules_scala_scala_library": {
"artifact": "org.scala-lang:scala-library:2.13.3",
"sha256": "cb0eb1a33a6056b2e652f26923bfa361348ae72a2119da7b78dc1f673d1a93b1",
},
"io_bazel_rules_scala_scala_compiler": {
"artifact": "org.scala-lang:scala-compiler:2.13.3",
"sha256": "e86e4f70d30cb3fd78e82aa6e6d82b2b3d1b46bd209a31f833a03b370ae0f32a",
},
"io_bazel_rules_scala_scala_reflect": {
"artifact": "org.scala-lang:scala-reflect:2.13.3",
"sha256": "959dc9ab8aad84e2fc7adacfb84f2ed908caee22c4c2d291dd818f0c40c6ed5b",
},
},
}

def _impl(ctx):
# Generates an empty BUILD file, because we do not need to build anything.
ctx.file(
Expand All @@ -19,20 +50,22 @@ def _impl(ctx):

major = version[:version.rfind(".")]
major_suffix = major.replace(".", "_")
artifacts = scala_artifacts.get(version) or fail("Unknown Scala version: %s" % version)
ctx.file(
"index.bzl",
content =
"""
content = """
scala_version = "{version}"
scala_major_version = "{major}"
scala_version_suffix = "{suffix}"
scala_major_version_suffix = "{major_suffix}"
scala_artifacts = {artifacts}
""".format(
version = version,
major = major,
suffix = suffix,
major_suffix = major_suffix,
),
version = version,
major = major,
suffix = suffix,
major_suffix = major_suffix,
artifacts = artifacts,
),
executable = False,
)

Expand Down
19 changes: 3 additions & 16 deletions compatibility/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,9 @@ load("@maven//:defs.bzl", "pinned_maven_install")
pinned_maven_install()

load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
load("@scala_version//:index.bzl", "scala_artifacts", "scala_version")

scala_config("2.12.12")
scala_config(scala_version)

load(
"@io_bazel_rules_scala//scala:scala.bzl",
Expand All @@ -338,21 +339,7 @@ load(

scala_repositories(
fetch_sources = True,
overriden_artifacts =
{
"io_bazel_rules_scala_scala_compiler": {
"artifact": "org.scala-lang:scala-compiler:2.12.12",
"sha256": "9dfa682ad7c2859cdcf6a31b9734c8f1ee38e7e391aeafaef91967b6ce819b6b",
},
"io_bazel_rules_scala_scala_library": {
"artifact": "org.scala-lang:scala-library:2.12.12",
"sha256": "1673ffe8792021f704caddfe92067ed1ec75229907f84380ad68fe621358c925",
},
"io_bazel_rules_scala_scala_reflect": {
"artifact": "org.scala-lang:scala-reflect:2.12.12",
"sha256": "3c502791757c0c8208f00033d8c4d778ed446efa6f49a6f89b59c6f92b347774",
},
},
overriden_artifacts = scala_artifacts,
)

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
Expand Down

0 comments on commit 3db928c

Please sign in to comment.