Skip to content

Commit

Permalink
Upgrade Scala 2.12 to v2.12.13. (#9280)
Browse files Browse the repository at this point in the history
* Upgrade Scala 2.12 to v2.12.13.

This is being pulled in anyway because of Maven/Gradle/etc's fun
"favor the most recent" resolution mechanism. The version of Akka we
depend upon transitively depends on Scala 2.12.13, so any downstream
consumers will see that as the Scala version required.

Bringing the Daml repo in line means no more confusion.

CHANGELOG_BEGIN
- [Scala Bindings] If you are using Daml on Scala 2.12, it now depends
  on Scala v2.12.13 (from v2.12.12).
CHANGELOG_END

* Scala 2.12.13 is the default version in our pinned version of nixpkgs.

* Upgrade Scala 2.13's Wartremover version.

* Rename `scala_version_rule` to `scala_version_configure`.

* Add a test case to ensure the Scala versions are the same everywhere.

* Add tests for the Scala JAR versions in maven_install_*.json

* gatling-utils: Change the sort order of the expected CSV in tests.

I don't know why this changed, but it seems to be stable.

* compatibility: `scala_version` -> `scala_version_configure`.

* Bazel: Disable the Scala version tests on Windows.

* compatibility: Upgrade Wartremover to Scala 2.12.13.
  • Loading branch information
SamirTalwar authored Mar 30, 2021
1 parent 4f0c72b commit 6035840
Show file tree
Hide file tree
Showing 12 changed files with 393 additions and 332 deletions.
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ alias(

exports_files([
".scalafmt.conf",
"maven_install_2.12.json",
"maven_install_2.13.json",
])

# Buildifier.
Expand Down
16 changes: 8 additions & 8 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ load("//bazel_tools:build_environment.bzl", "build_environment")

build_environment(name = "build_environment")

load("//bazel_tools:scala_version.bzl", "scala_version")
load("//bazel_tools:scala_version.bzl", "scala_version_configure")

scala_version(name = "scala_version")
scala_version_configure(name = "scala_version")

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

Expand Down Expand Up @@ -715,16 +715,16 @@ scala_repositories(
{
"2.12": {
"io_bazel_rules_scala_scala_compiler": {
"artifact": "org.scala-lang:scala-compiler:2.12.12",
"sha256": "9dfa682ad7c2859cdcf6a31b9734c8f1ee38e7e391aeafaef91967b6ce819b6b",
"artifact": "org.scala-lang:scala-compiler:%s" % scala_version,
"sha256": "ea971e004e2f15d3b7569eee8b559f220e23b9993e688bbe986f97938d1dc9f9",
},
"io_bazel_rules_scala_scala_library": {
"artifact": "org.scala-lang:scala-library:2.12.12",
"sha256": "1673ffe8792021f704caddfe92067ed1ec75229907f84380ad68fe621358c925",
"artifact": "org.scala-lang:scala-library:%s" % scala_version,
"sha256": "1bb415cff43f792636556a1137b213b192ab0246be003680a3b006d01235dd89",
},
"io_bazel_rules_scala_scala_reflect": {
"artifact": "org.scala-lang:scala-reflect:2.12.12",
"sha256": "3c502791757c0c8208f00033d8c4d778ed446efa6f49a6f89b59c6f92b347774",
"artifact": "org.scala-lang:scala-reflect:%s" % scala_version,
"sha256": "2bd46318d87945e72eb186a7b5ea496c43cf8f0aabc6ff11b3e7962f8635e669",
},
},
}.get(scala_major_version, {}),
Expand Down
2 changes: 1 addition & 1 deletion bazel-java-deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def install_java_deps():
"org.tpolecat:doobie-hikari_{}:0.9.2".format(scala_major_version),
"org.tpolecat:doobie-postgres_{}:0.9.2".format(scala_major_version),
"org.typelevel:paiges-core_{}:0.3.2".format(scala_major_version),
"org.wartremover:wartremover_{}:2.4.10".format(scala_version),
"org.wartremover:wartremover_{}:2.4.13".format(scala_version),
"org.xerial:sqlite-jdbc:3.30.1",
"com.fasterxml.jackson.core:jackson-core:2.12.0",
"com.fasterxml.jackson.core:jackson-databind:2.12.0",
Expand Down
66 changes: 66 additions & 0 deletions bazel_tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

load("//bazel_tools/sh:sh.bzl", "sh_inline_test")
load("@os_info//:os_info.bzl", "is_windows")
load("@scala_version//:index.bzl", "scala_major_version", "scala_version")

# Export Bazel sources for Bazel API docs.
exports_files(
[
Expand All @@ -16,3 +20,65 @@ exports_files(
],
visibility = ["//:__subpackages__"],
)

sh_inline_test(
name = "scala_version_test",
cmd = """
set -eu
function check {{
if [[ '{expected_version}' == "$$2" ]]; then
echo >&2 "$$1 was version {expected_version}, as expected."
return 0
else
echo >&2 "Expected $$1 to have the version {expected_version}, but got the version $$2."
return 1
fi
}}
JQ="$$(canonicalize_rlocation $(rootpath {jq}))"
SCALA_BIN="$$(canonicalize_rlocation $(rootpath {scala_bin}))"
SCALA_BIN_VERSION="$$($$SCALA_BIN -version |& sed -r 's/^Scala code runner version ([^ ]+) -- .*$$/\\1/')"
function jar_version {{
echo "$$(basename "$$1")" | sed -r 's/^.*-([0-9\\.]+)\\.jar$$/\\1/'
}}
SCALA_COMPILER_JAR_VERSION="$$(jar_version $(rootpath {scala_compiler}))"
SCALA_LIBRARY_JAR_VERSION="$$(jar_version $(rootpath {scala_library}))"
SCALA_REFLECT_JAR_VERSION="$$(jar_version $(rootpath {scala_reflect}))"
function maven_version {{
$$JQ -r --arg name "$$1" '.dependency_tree.dependencies | .[] | .coord | capture("^org\\\\.scala-lang:" + $$name + ":(?<version>[0-9\\\\.]+)$$") | .version' '$(rootpath {maven_install_json})'
}}
SCALA_COMPILER_MAVEN_VERSION="$$(maven_version 'scala-compiler')"
SCALA_LIBRARY_MAVEN_VERSION="$$(maven_version 'scala-library')"
SCALA_REFLECT_MAVEN_VERSION="$$(maven_version 'scala-reflect')"
check 'scala binary' "$$SCALA_BIN_VERSION"
check '$(rootpath {scala_compiler})' "$$SCALA_COMPILER_JAR_VERSION"
check '$(rootpath {scala_library})' "$$SCALA_LIBRARY_JAR_VERSION"
check '$(rootpath {scala_reflect})' "$$SCALA_REFLECT_JAR_VERSION"
check 'org.scala-lang:scala-compiler (in {maven_install_json})' "$$SCALA_COMPILER_MAVEN_VERSION"
check 'org.scala-lang:scala-library (in {maven_install_json})' "$$SCALA_LIBRARY_MAVEN_VERSION"
check 'org.scala-lang:scala-reflect (in {maven_install_json})' "$$SCALA_REFLECT_MAVEN_VERSION"
""".format(
expected_version = scala_version,
jq = "@jq_dev_env//:bin/jq",
maven_install_json = "//:maven_install_{}.json".format(scala_major_version),
scala_bin = "@scala_nix//:bin/scala",
scala_compiler = "@maven//:org_scala_lang_scala_compiler",
scala_library = "@maven//:org_scala_lang_scala_library",
scala_reflect = "@maven//:org_scala_lang_scala_reflect",
),
data = [
"//:maven_install_{}.json".format(scala_major_version),
"@jq_dev_env//:bin/jq",
"@maven//:org_scala_lang_scala_compiler",
"@maven//:org_scala_lang_scala_library",
"@maven//:org_scala_lang_scala_reflect",
"@scala_nix//:bin/scala",
],
) if not is_windows else None
6 changes: 3 additions & 3 deletions bazel_tools/scala_version.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Keep in sync with /release/src/Main.hs
default_scala_version = "2.12.12"
# Keep in sync with /nix/nixpkgs.nix and /release/src/Main.hs
default_scala_version = "2.12.13"

def _impl(ctx):
# Generates an empty BUILD file, because we do not need to build anything.
Expand Down Expand Up @@ -36,7 +36,7 @@ scala_major_version_suffix = "{major_suffix}"
executable = False,
)

scala_version = repository_rule(
scala_version_configure = repository_rule(
environ = ["DAML_SCALA_VERSION"],
implementation = _impl,
attrs = {},
Expand Down
6 changes: 3 additions & 3 deletions compatibility/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ load("@daml//bazel_tools:build_environment.bzl", "build_environment")

build_environment(name = "build_environment")

load("@daml//bazel_tools:scala_version.bzl", "scala_version")
load("@daml//bazel_tools:scala_version.bzl", "scala_version_configure")

scala_version(name = "scala_version")
scala_version_configure(name = "scala_version")

load("//:deps.bzl", "daml_deps")

Expand Down Expand Up @@ -313,7 +313,7 @@ maven_install(
"com.daml:ledger-api-common_2.12:{}".format(latest_stable_version),
"com.daml:lf-value-json_2.12:{}".format(latest_stable_version),
"com.github.scopt:scopt_2.12:3.7.1",
"org.wartremover:wartremover_2.12.12:2.4.10",
"org.wartremover:wartremover_2.12.13:2.4.13",
"io.spray:spray-json_2.12:1.3.3",
],
maven_install_json = "@compatibility//:maven_install.json",
Expand Down
Loading

0 comments on commit 6035840

Please sign in to comment.