Skip to content

Commit

Permalink
Merge branch 'master' into michal-lenart/scala-3.4.2-support
Browse files Browse the repository at this point in the history
  • Loading branch information
lm1nrt authored Aug 26, 2024
2 parents 450b5bf + ac4181c commit b5f8a8f
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ tasks:
platform: ubuntu2004
shell_commands:
# Install xmllint
- sudo apt update && sudo apt install -y libxml2-utils
- sudo apt update && sudo apt install --reinstall libxml2-utils -y
- "./test_rules_scala.sh"
test_rules_scala_linux_last_green:
name: "./test_rules_scala (Bazel green head)"
platform: ubuntu2004
bazel: last_green
shell_commands:
# Install xmllint
- sudo apt update && sudo apt install -y libxml2-utils
- sudo apt update && sudo apt install --reinstall libxml2-utils -y
- "./test_rules_scala.sh || buildkite-agent annotate --style 'warning' \"Optional build with latest Bazel version failed, [see here](${BUILDKITE_BUILD_URL}#${BUILDKITE_JOB_ID}) (It is not mandatory but worth checking)\""
test_rules_scala_macos:
name: "./test_rules_scala"
Expand Down
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.18)
`rules_scala_version` into your Bazel project and register a [scala_toolchain](docs/scala_toolchain.md) at the default Scala version (2.12.19)

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.18` and `2.13.12` versions.
dependency providers configured for `2.11.12`, `2.12.19` and `2.13.14` versions.


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

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 @@ -101,6 +101,7 @@ run_test_local test_compiler_patch 2.12.15
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.13.0
run_test_local test_compiler_patch 2.13.1
Expand All @@ -114,6 +115,7 @@ run_test_local test_compiler_patch 2.13.8
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_srcjar_error 2.12.11
run_test_local test_compiler_srcjar_error 2.12.12
Expand All @@ -126,6 +128,8 @@ run_test_local test_compiler_srcjar 2.12.15
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.13.11
run_test_local test_compiler_srcjar_nonhermetic 2.13.12
run_test_local test_compiler_srcjar_nonhermetic 2.13.12
run_test_local test_compiler_srcjar_nonhermetic 2.13.14
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 @@ -91,12 +91,18 @@ srcjars_by_version = {
"2.12.18": {
"url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.12.18/scala-compiler-2.12.18-sources.jar?foo",
},
"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.13.11": {
"url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.11/scala-compiler-2.13.11-sources.jar?foo",
},
"2.13.12": {
"url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.13.12/scala-compiler-2.13.12-sources.jar?foo",
},
"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",
},
}

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.12",
scala_version = "2.13.14",
)

# 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.12",
scala_version = "2.13.14",
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.12",
scala_version = "2.13.14",
deps = [":lib"],
)

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

scala_config(
scala_version = "3.3.1",
scala_version = "3.3.3",
scala_versions = [
"2.11.12",
"2.13.12",
"3.3.1",
"2.13.14",
"3.3.3",
],
)

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

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

scala_config(scala_version = "2.13.12")
scala_config(scala_version = "2.13.14")

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.18"
return "2.12.19"

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: 6 additions & 2 deletions src/java/io/bazel/rulesscala/scala_test/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -48,7 +49,9 @@ private static String[] extendFromFileArgs(String[] args) throws IOException {
if (workspace == null || workspace.trim().isEmpty())
throw new IllegalArgumentException(RULES_SCALA_MAIN_WS_NAME + " is null or empty.");

String runnerArgsFilePath = Runfiles.create().rlocation(workspace + "/" + runnerArgsFileKey);

Path runnerArgsUnresolvedFileLocation = Paths.get(workspace + "/" + runnerArgsFileKey).normalize();
String runnerArgsFilePath = Runfiles.create().rlocation(runnerArgsUnresolvedFileLocation.toString());
if (runnerArgsFilePath == null)
throw new IllegalArgumentException("rlocation value is null for key: " + runnerArgsFileKey);

Expand Down Expand Up @@ -90,7 +93,8 @@ private static void rlocateRunpathValue(String rulesWorkspace, List<String> runn
String[] runpathElements = runnerArgs.get(runpathFlag + 1).split(File.pathSeparator);
Runfiles runfiles = Runfiles.create();
for (int i = 0; i < runpathElements.length; i++) {
runpathElements[i] = runfiles.rlocation(rulesWorkspace + "/" + runpathElements[i]);
Path runPathElementPath = Paths.get(rulesWorkspace + "/" + runpathElements[i]).normalize();
runpathElements[i] = runfiles.rlocation(runPathElementPath.toString());
}
String runpath = String.join(File.separator, runpathElements);
runnerArgs.set(runpathFlag + 1, runpath);
Expand Down
6 changes: 3 additions & 3 deletions test/shell/test_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function multi_framework_toolchain_example() {
}

function scala3_1_example() {
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.1.0 //..."
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.1.3 //..."
}

function scala3_2_example() {
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.2.1 //..."
test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.2.2 //..."
}

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

function scala3_4_example() {
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.18 \
--repo_env=SCALA_VERSION=2.12.19 \
| 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.12 \
--repo_env=SCALA_VERSION=2.13.14 \
| 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.1"
local version_opt="--repo_env=SCALA_VERSION=3.3.3"
fi


Expand Down
12 changes: 6 additions & 6 deletions test_cross_build/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ local_repository(
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config(
scala_version = "3.1.0",
scala_version = "3.1.3",
scala_versions = [
"2.11.12",
"2.12.18",
"2.13.12",
"3.1.0",
"3.2.1",
"3.3.1",
"2.12.19",
"2.13.14",
"3.1.3",
"3.2.2",
"3.3.3",
],
)

Expand Down
22 changes: 11 additions & 11 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.12",
scala_version = "2.13.14",
)

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

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

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

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

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

scalafmt_scala_binary(
Expand All @@ -71,7 +71,7 @@ scalafmt_scala_binary(
config = ":scala3-conf",
format = True,
main_class = "UnformattedBinary",
scala_version = "3.2.1",
scala_version = "3.2.2",
)

scalafmt_scala_library(
Expand All @@ -80,26 +80,26 @@ scalafmt_scala_library(
config = ":scala3-conf",
format = True,
main_class = "UnformattedBinary",
scala_version = "3.2.1",
scala_version = "3.2.2",
)

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

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

#default scala version is 3.1.0
#default scala version is 3.1.3
scalafmt_scala_test(
name = "unformatted-test3",
srcs = ["unformatted/unformatted-test3.scala"],
Expand Down
Loading

0 comments on commit b5f8a8f

Please sign in to comment.