Skip to content

Commit

Permalink
Update latest Scala 2 and Scala 3 versions (#1636)
Browse files Browse the repository at this point in the history
* Update latest Scala 2 and Scala 3 versions

* Update changed versions used in tests

* Fix failing Scala 3 diagnostics tests after upgrade to 3.3.4 - this version backported propositions for missing identifiers
  • Loading branch information
WojciechMazur authored Oct 25, 2024
1 parent cf40df3 commit 487c2fa
Show file tree
Hide file tree
Showing 28 changed files with 112 additions and 97 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ scalatest_toolchain()
```

This will load the `rules_scala` repository at the commit sha
`rules_scala_version` into your Bazel project and register a [scala_toolchain](docs/scala_toolchain.md) at the default Scala version (2.12.19)
`rules_scala_version` into your Bazel project and register a [scala_toolchain](docs/scala_toolchain.md) at the default Scala version (2.12.20)

Then in your BUILD file just add the following so the rules will be available:
```starlark
Expand Down Expand Up @@ -143,13 +143,13 @@ Previous minor versions may work but are supported only on a best effort basis.
To configure Scala version you must call `scala_config(scala_version = "2.xx.xx")` and configure
dependencies by declaring [scala_toolchain](docs/scala_toolchain.md).
For a quick start you can use `scala_repositories()` and `scala_register_toolchains()`, which have
dependency providers configured for `2.11.12`, `2.12.19` and `2.13.14` versions.
dependency providers configured for `2.11.12`, `2.12.20` and `2.13.15` versions.


```starlark
# WORKSPACE
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
scala_config(scala_version = "2.13.14")
scala_config(scala_version = "2.13.15")

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
Expand Down
6 changes: 5 additions & 1 deletion dt_patches/dt_patch_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ run_test_local test_compiler_patch 2.12.16
run_test_local test_compiler_patch 2.12.17
run_test_local test_compiler_patch 2.12.18
run_test_local test_compiler_patch 2.12.19
run_test_local test_compiler_patch 2.12.20

run_test_local test_compiler_patch 2.13.0
run_test_local test_compiler_patch 2.13.1
Expand All @@ -116,6 +117,7 @@ run_test_local test_compiler_patch 2.13.10
run_test_local test_compiler_patch 2.13.11
run_test_local test_compiler_patch 2.13.12
run_test_local test_compiler_patch 2.13.14
run_test_local test_compiler_patch 2.13.15

run_test_local test_compiler_srcjar_error 2.12.11
run_test_local test_compiler_srcjar_error 2.12.12
Expand All @@ -129,7 +131,9 @@ run_test_local test_compiler_srcjar 2.12.16
run_test_local test_compiler_srcjar_nonhermetic 2.12.17
run_test_local test_compiler_srcjar_nonhermetic 2.12.18
run_test_local test_compiler_srcjar_nonhermetic 2.12.19
run_test_local test_compiler_srcjar_nonhermetic 2.12.20

run_test_local test_compiler_srcjar_nonhermetic 2.13.11
run_test_local test_compiler_srcjar_nonhermetic 2.13.12
run_test_local test_compiler_srcjar_nonhermetic 2.13.14
run_test_local test_compiler_srcjar_nonhermetic 2.13.14
run_test_local test_compiler_srcjar_nonhermetic 2.13.15
6 changes: 6 additions & 0 deletions dt_patches/test_dt_patches_user_srcjar/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ srcjars_by_version = {
"2.12.19": {
"url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.19/scala-compiler-2.12.19-sources.jar?foo",
},
"2.12.20": {
"url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.20/scala-compiler-2.12.20-sources.jar?foo",
},
"2.13.11": {
"url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.11/scala-compiler-2.13.11-sources.jar?foo",
},
Expand All @@ -114,6 +117,9 @@ srcjars_by_version = {
"2.13.14": {
"url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.14/scala-compiler-2.13.14-sources.jar?foo",
},
"2.13.15": {
"url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.15/scala-compiler-2.13.15-sources.jar?foo",
},
}

rules_scala_setup(scala_compiler_srcjar = srcjars_by_version[SCALA_VERSION])
Expand Down
2 changes: 1 addition & 1 deletion examples/crossbuild/1_single/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ scala_library(
scala_test(
name = "test213",
srcs = ["test.scala"],
scala_version = "2.13.14",
scala_version = "2.13.15",
)

# This one will be compiled by 3.3 compiler (the default one):
Expand Down
2 changes: 1 addition & 1 deletion examples/crossbuild/2_deps/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ scala_binary(
name = "bin213",
srcs = ["bin.scala"], # compiled with 2.13 (as per `scala_version`)
main_class = "C",
scala_version = "2.13.14",
scala_version = "2.13.15",
deps = [
":lib", # compiled 2.13 (as per `scala_version`)
":lib211", # compiled with 2.11 (that target overrides version)
Expand Down
4 changes: 2 additions & 2 deletions examples/crossbuild/3_select/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ scala_binary(
name = "bin2",
srcs = ["bin.scala"],
main_class = "B",
scala_version = "2.13.14",
scala_version = "2.13.15",
deps = [":lib"],
)

scala_binary(
name = "bin3",
srcs = ["bin.scala"],
main_class = "B",
scala_version = "3.3.3",
scala_version = "3.3.4",
deps = [":lib"],
)
6 changes: 3 additions & 3 deletions examples/crossbuild/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ local_repository(
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config(
scala_version = "3.3.3",
scala_version = "3.3.4",
scala_versions = [
"2.11.12",
"2.13.14",
"3.3.3",
"2.13.15",
"3.3.4",
],
)

Expand Down
2 changes: 1 addition & 1 deletion examples/scala3/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local_repository(

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

scala_config(scala_version = "3.5.0")
scala_config(scala_version = "3.5.2")

load(
"@io_bazel_rules_scala//scala:scala.bzl",
Expand Down
2 changes: 1 addition & 1 deletion examples/semanticdb/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local_repository(

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

scala_config(scala_version = "2.13.14")
scala_config(scala_version = "2.13.15")

load(
"@io_bazel_rules_scala//scala:scala.bzl",
Expand Down
2 changes: 1 addition & 1 deletion scala_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("//scala:scala_cross_version.bzl", "extract_major_version", "extract_minor_

def _default_scala_version():
"""return the scala version for use in maven coordinates"""
return "2.12.19"
return "2.12.20"

def _validate_supported_scala_version(scala_major_version, scala_minor_version):
if scala_major_version == "2.11" and int(scala_minor_version) != 12:
Expand Down
8 changes: 5 additions & 3 deletions scripts/create_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import glob
import os

root_scala_versions = ["2.11.12", "2.12.19", "2.13.14", "3.1.3", "3.2.2", "3.3.3", "3.4.3", "3.5.0"]
root_scala_versions = ["2.11.12", "2.12.20", "2.13.15", "3.1.3", "3.2.2", "3.3.4", "3.4.3", "3.5.2"]
scala_test_version = "3.2.9"
scala_fmt_version = "3.0.0"

Expand All @@ -33,7 +33,7 @@ def select_root_artifacts(scala_version) -> List[str]:
scala_major = ".".join(scala_version.split(".")[:2])
scala_test_major = "3" if scala_major >= "3.0" else scala_major
scala_fmt_major = "2.13" if scala_major >= "3.0" else scala_major
kind_projector_version = "0.13.2" if scala_major < "2.13" else "0.13.3"
kind_projector_version = "0.13.2" if scala_major < "2.12" else "0.13.3"

common_root_artifacts = [
f"org.scalatest:scalatest_{scala_test_major}:{scala_test_version}",
Expand Down Expand Up @@ -104,7 +104,9 @@ def map_to_resolved_artifacts(output) -> List[ResolvedArtifact]:

def resolve_artifacts_with_checksums_and_direct_dependencies(root_artifacts) -> List[ResolvedArtifact]:
command = f'cs resolve {' '.join(root_artifacts)}'
output = subprocess.run(command, capture_output=True, text=True, shell=True).stdout.splitlines()
proc = subprocess.run(command, capture_output=True, text=True, shell=True)
print(proc.stderr)
output = proc.stdout.splitlines()
return map_to_resolved_artifacts(output)

def to_rules_scala_compatible_dict(artifacts, version) -> Dict[str, Dict]:
Expand Down
8 changes: 5 additions & 3 deletions test/diagnostics_reporter/DiagnosticsReporterTestCases3.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class DiagnosticsReporterTestCases {
put(
"two_errors_file",
new diagnostics_reporter.VerifyDiagnosticsOutput[] {
// 'did you mean' part was introduced in to Scala 3 LTS in 3.3.4
// It was introduced in Scala Next releases somewhere beetween 3.4 and 3.5
new diagnostics_reporter.VerifyDiagnosticsOutput(
Diagnostics.Severity.ERROR, "Not found: printn"),
Diagnostics.Severity.ERROR, "Not found: printn - did you mean print? or perhaps printf or println?"),
new diagnostics_reporter.VerifyDiagnosticsOutput(
Diagnostics.Severity.ERROR, "Not found: prinf")
Diagnostics.Severity.ERROR, "Not found: prinf - did you mean print? or perhaps printf?")
});
put(
"warning_file",
Expand All @@ -37,7 +39,7 @@ class DiagnosticsReporterTestCases {
new diagnostics_reporter.VerifyDiagnosticsOutput[] {
// Scala 3 does not report unused import when errors are present
new diagnostics_reporter.VerifyDiagnosticsOutput(
Diagnostics.Severity.ERROR, "Not found: printn")
Diagnostics.Severity.ERROR, "Not found: printn - did you mean print? or perhaps printf or println?")
});
put(
"info_file",
Expand Down
4 changes: 2 additions & 2 deletions test/shell/test_coverage_equals_in_target.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. "${dir}"/test_helper.sh
runner=$(get_test_runner "${1:-local}")

# Default to 2.12.19 for `diff` tests because other versions change the output.
SCALA_VERSION="${SCALA_VERSION:-2.12.19}"
# Default to 2.12.20 for `diff` tests because other versions change the output.
SCALA_VERSION="${SCALA_VERSION:-2.12.20}"

test_coverage_target_name_contains_equals_sign() {
bazel coverage \
Expand Down
4 changes: 2 additions & 2 deletions test/shell/test_coverage_scalatest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. "${dir}"/test_helper.sh
runner=$(get_test_runner "${1:-local}")

# Default to 2.12.19 for `diff` tests because other versions change the output.
SCALA_VERSION="${SCALA_VERSION:-2.12.19}"
# Default to 2.12.20 for `diff` tests because other versions change the output.
SCALA_VERSION="${SCALA_VERSION:-2.12.20}"

test_coverage_on() {
bazel coverage \
Expand Down
4 changes: 2 additions & 2 deletions test/shell/test_coverage_scalatest_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. "${dir}"/test_helper.sh
runner=$(get_test_runner "${1:-local}")

# Default to 2.12.19 for `diff` tests because other versions change the output.
SCALA_VERSION="${SCALA_VERSION:-2.12.19}"
# Default to 2.12.20 for `diff` tests because other versions change the output.
SCALA_VERSION="${SCALA_VERSION:-2.12.20}"

test_coverage_succeeds_resource_call() {
bazel coverage \
Expand Down
4 changes: 2 additions & 2 deletions test/shell/test_coverage_specs2_with_junit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
. "${dir}"/test_helper.sh
runner=$(get_test_runner "${1:-local}")

# Default to 2.12.19 for `diff` tests because other versions change the output.
SCALA_VERSION="${SCALA_VERSION:-2.12.19}"
# Default to 2.12.20 for `diff` tests because other versions change the output.
SCALA_VERSION="${SCALA_VERSION:-2.12.20}"

test_coverage_on() {
bazel coverage \
Expand Down
4 changes: 2 additions & 2 deletions test/shell/test_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ function scala3_2_example() {
}

function scala3_3_example() {
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.3.3 //..."
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.3.4 //..."
}

function scala3_4_example() {
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.4.3 //..."
}

function scala3_5_example() {
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.5.0 //..."
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.5.2 //..."
}

function semanticdb_example() {
Expand Down
2 changes: 1 addition & 1 deletion test/shell/test_invalid_scalacopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test_logs_not_contains() {
2>&1 | grep -v "$expected"
}

for scalaVersion in 2.12.19 2.13.14 3.3.3; do
for scalaVersion in 2.12.20 2.13.15 3.3.4; do
if [[ "$scalaVersion" == 3.* ]]; then
$runner test_logs_contains $scalaVersion "not-existing is not a valid choice for -source"
else
Expand Down
4 changes: 2 additions & 2 deletions test/shell/test_scala_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ runner=$(get_test_runner "${1:-local}")

test_classpath_contains_2_12() {
bazel aquery 'mnemonic("Javac", //src/java/io/bazel/rulesscala/scalac:scalac)' \
--repo_env=SCALA_VERSION=2.12.19 \
--repo_env=SCALA_VERSION=2.12.20 \
| grep scala-library-2.12
}

test_classpath_contains_2_13() {
bazel aquery 'mnemonic("Javac", //src/java/io/bazel/rulesscala/scalac:scalac)' \
--repo_env=SCALA_VERSION=2.13.14 \
--repo_env=SCALA_VERSION=2.13.15 \
| grep scala-library-2.13
}

Expand Down
2 changes: 1 addition & 1 deletion test/shell/test_semanticdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test_produces_semanticdb(){
fi

if [ $scala_majver -eq 3 ]; then
local version_opt="--repo_env=SCALA_VERSION=3.3.3"
local version_opt="--repo_env=SCALA_VERSION=3.3.4"
fi


Expand Down
6 changes: 3 additions & 3 deletions test_cross_build/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ scala_config(
scala_version = "3.1.3",
scala_versions = [
"2.11.12",
"2.12.19",
"2.13.14",
"2.12.20",
"2.13.15",
"3.1.3",
"3.2.2",
"3.3.3",
"3.3.4",
],
)

Expand Down
16 changes: 8 additions & 8 deletions test_cross_build/scalafmt/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ scalafmt_scala_library(
srcs = ["unformatted/unformatted-library2.scala"],
config = ":scala2-conf",
format = True,
scala_version = "2.13.14",
scala_version = "2.13.15",
)

scalafmt_scala_library(
name = "formatted-library2",
srcs = ["formatted/formatted-library2.scala"],
config = ":scala2-conf",
format = True,
scala_version = "2.13.14",
scala_version = "2.13.15",
)

scalafmt_scala_library(
name = "unformatted-library3",
srcs = ["unformatted/unformatted-library3.scala"],
config = ":scala3-conf",
format = True,
scala_version = "3.3.3",
scala_version = "3.3.4",
)

scalafmt_scala_library(
name = "formatted-library3",
srcs = ["formatted/formatted-library3.scala"],
config = ":scala3-conf",
format = True,
scala_version = "3.3.3",
scala_version = "3.3.4",
)

scalafmt_scala_binary(
Expand All @@ -53,7 +53,7 @@ scalafmt_scala_binary(
config = ":scala2-conf",
format = True,
main_class = "UnformattedBinary",
scala_version = "2.12.19",
scala_version = "2.12.20",
)

scalafmt_scala_library(
Expand All @@ -62,7 +62,7 @@ scalafmt_scala_library(
config = ":scala2-conf",
format = True,
main_class = "UnformattedBinary",
scala_version = "2.12.19",
scala_version = "2.12.20",
)

scalafmt_scala_binary(
Expand All @@ -88,15 +88,15 @@ scalafmt_scala_test(
srcs = ["unformatted/unformatted-test2.scala"],
config = ":scala2-conf",
format = True,
scala_version = "2.12.19",
scala_version = "2.12.20",
)

scalafmt_scala_test(
name = "formatted-test2",
srcs = ["formatted/formatted-test2.scala"],
config = ":scala2-conf",
format = True,
scala_version = "2.12.19",
scala_version = "2.12.20",
)

#default scala version is 3.1.3
Expand Down
Loading

0 comments on commit 487c2fa

Please sign in to comment.