diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index e35655c78..1bbe79a8d 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -1,14 +1,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load( "@io_bazel_rules_scala//scala:scala_cross_version.bzl", + "extract_major_version", + "extract_minor_version", + "version_suffix", _default_maven_server_urls = "default_maven_server_urls", ) load("//third_party/repositories:repositories.bzl", "repositories") load( "@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION", - "SCALA_MINOR_VERSION", - "SCALA_VERSION", + "SCALA_VERSIONS", ) def _dt_patched_compiler_impl(rctx): @@ -37,16 +39,18 @@ def _validate_scalac_srcjar(srcjar): count += 1 return count == 1 -def dt_patched_compiler_setup(scala_compiler_srcjar = None): - patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.patch" % SCALA_MAJOR_VERSION +def dt_patched_compiler_setup(scala_version, scala_compiler_srcjar = None): + scala_major_version = extract_major_version(scala_version) + scala_minor_version = extract_minor_version(scala_version) + patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.patch" % scala_major_version - minor_version = int(SCALA_MINOR_VERSION) + minor_version = int(scala_minor_version) - if SCALA_MAJOR_VERSION == "2.12": + if scala_major_version == "2.12": if minor_version >= 1 and minor_version <= 7: - patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.1.patch" % SCALA_MAJOR_VERSION + patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.1.patch" % scala_major_version elif minor_version <= 11: - patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.8.patch" % SCALA_MAJOR_VERSION + patch = "@io_bazel_rules_scala//dt_patches:dt_compiler_%s.8.patch" % scala_major_version build_file_content = "\n".join([ "package(default_visibility = [\"//visibility:public\"])", @@ -56,7 +60,7 @@ def dt_patched_compiler_setup(scala_compiler_srcjar = None): ")", ]) default_scalac_srcjar = { - "url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/%s/scala-compiler-%s-sources.jar" % (SCALA_VERSION, SCALA_VERSION), + "url": "https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/%s/scala-compiler-%s-sources.jar" % (scala_version, scala_version), } srcjar = scala_compiler_srcjar if scala_compiler_srcjar != None else default_scalac_srcjar _validate_scalac_srcjar(srcjar) or fail( @@ -65,14 +69,14 @@ def dt_patched_compiler_setup(scala_compiler_srcjar = None): ) if "label" in srcjar: dt_patched_compiler( - name = "scala_compiler_source", + name = "scala_compiler_source" + version_suffix(scala_version), build_file_content = build_file_content, patch = patch, srcjar = srcjar["label"], ) else: http_archive( - name = "scala_compiler_source", + name = "scala_compiler_source" + version_suffix(scala_version), build_file_content = build_file_content, patches = [patch], url = srcjar.get("url"), @@ -120,7 +124,8 @@ def rules_scala_setup(scala_compiler_srcjar = None): ], ) - dt_patched_compiler_setup(scala_compiler_srcjar) + for scala_version in SCALA_VERSIONS: + dt_patched_compiler_setup(scala_version, scala_compiler_srcjar) ARTIFACT_IDS = [ "io_bazel_rules_scala_scala_library", diff --git a/third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/compiler/BUILD b/third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/compiler/BUILD index 0155ca5c4..fb3b92a64 100644 --- a/third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/compiler/BUILD +++ b/third_party/dependency_analyzer/src/main/io/bazel/rulesscala/dependencyanalyzer/compiler/BUILD @@ -1,8 +1,10 @@ load("//scala:scala.bzl", "scala_library_for_plugin_bootstrapping") +load("//scala:scala_cross_version.bzl", "version_suffix") +load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSION") scala_library_for_plugin_bootstrapping( name = "dep_reporting_compiler", - srcs = ["@scala_compiler_source//:src"], + srcs = ["@scala_compiler_source%s//:src" % version_suffix(SCALA_VERSION)], scalac_jvm_flags = ["-Xmx128M"], # fixme - workaround for a failing test visibility = ["//visibility:public"], deps = ["//scala/private/toolchain_deps:scala_compile_classpath"],