diff --git a/.bazelignore b/.bazelignore new file mode 100644 index 000000000..9bc3c9646 --- /dev/null +++ b/.bazelignore @@ -0,0 +1,5 @@ +dt_patches/test_dt_patches +dt_patches/test_dt_patches_user_srcjar +test_version +test_cross_build +examples diff --git a/.bazelversion b/.bazelversion index 798e38995..b26a34e47 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.3.0 +7.2.1 diff --git a/.gitignore b/.gitignore index 80489aaf3..030f1d9ab 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ hash2 .vscode unformatted-*.backup.scala .scala-build -test/semanticdb/tempsrc \ No newline at end of file +test/semanticdb/tempsrc +MODULE.bazel.lock diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..2f8bcf1c4 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,54 @@ +module(name = "io_bazel_rules_scala") + +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "rules_cc", version = "0.0.6") +bazel_dep(name = "rules_java", version = "7.8.0") +bazel_dep(name = "rules_proto", version = "6.0.2") +bazel_dep(name = "bazel_features", version = "1.14.0") +bazel_dep(name = "protobuf", version = "27.3", repo_name = "com_google_protobuf") +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_python", version = "0.34.0", dev_dependency = True) + +single_version_override( + module_name = "bazel_features", + version = "1.14.0", +) + +version = use_extension("@bazel_features//private:extensions.bzl", "version_extension") +use_repo(version, "bazel_features_globals", "bazel_features_version") + +bazel_dep(name = "rules_go", version = "0.39.1") + +bazel_dep(name = "buildtools", repo_name = "com_github_bazelbuild_buildtools") + +git_override( + module_name = "buildtools", + remote = "https://github.com/bazelbuild/buildtools.git", + commit = "37932ddd72301f8ca6075ee6b24e9e5d333c96a5" +) + +use_repo( + use_extension("//:extensions/scala_config_ext.bzl", "scala_config_dep"), + "io_bazel_rules_scala_config" +) + +non_module_deps = use_extension("//:extensions/non_module_deps.bzl", "non_module_deps") +use_repo(non_module_deps, "scala_compiler_source_2_12_18") +use_repo(non_module_deps, "io_bazel_rules_scala_scala_library_2_12_18") +use_repo(non_module_deps, "io_bazel_rules_scala_scala_compiler_2_12_18") +use_repo(non_module_deps, "io_bazel_rules_scala_scala_xml_2_12_18") +use_repo(non_module_deps, "io_bazel_rules_scala_scala_parser_combinators_2_12_18") +use_repo(non_module_deps, "io_bazel_rules_scala_scala_interfaces") +use_repo(non_module_deps, "io_bazel_rules_scala_scala_reflect_2_12_18") +use_repo(non_module_deps, "org_scalameta_semanticdb_scalac_2_12_18") +# use_repo(non_module_deps, "io_bazel_rules_scala_scala_tasty_core") +# use_repo(non_module_deps, "io_bazel_rules_scala_scala_asm") +# use_repo(non_module_deps, "io_bazel_rules_scala_scala_library_2") +use_repo(non_module_deps, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core") +use_repo(non_module_deps, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm") +use_repo(non_module_deps, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection") +use_repo(non_module_deps, "io_bazel_rules_scala_org_ows2_asm_asm") +use_repo(non_module_deps, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple") +use_repo(non_module_deps, "io_bazel_rules_scala_org_apache_commons_commons_math3") + +register_toolchains("@io_bazel_rules_scala//jmh:jmh_toolchain") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 000000000..59624a797 --- /dev/null +++ b/WORKSPACE.bzlmod @@ -0,0 +1,134 @@ +workspace(name = "io_bazel_rules_scala") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +load("//scala:scala_cross_version.bzl", "default_maven_server_urls") +load("//twitter_scrooge:twitter_scrooge.bzl", "twitter_scrooge") + +twitter_scrooge() + +load("//scala_proto:scala_proto.bzl", "scala_proto_repositories") + +scala_proto_repositories() + +load("//scalatest:scalatest.bzl", "scalatest_repositories") + +scalatest_repositories() + +load("//specs2:specs2_junit.bzl", "specs2_junit_repositories") + +specs2_junit_repositories() + +register_toolchains("//testing:testing_toolchain") + +load("//scala/scalafmt:scalafmt_repositories.bzl", "scalafmt_default_config", "scalafmt_repositories") + +scalafmt_default_config() + +scalafmt_repositories() + +MAVEN_SERVER_URLS = default_maven_server_urls() + +# needed for the cross repo proto test +load("//test/proto_cross_repo_boundary:repo.bzl", "proto_cross_repo_boundary_repository") + +proto_cross_repo_boundary_repository() + +new_local_repository( + name = "test_new_local_repo", + build_file_content = + """ +filegroup( + name = "data", + srcs = glob(["**/*.txt"]), + visibility = ["//visibility:public"], +) +""", + path = "third_party/test/new_local_repo", +) + +local_repository( + name = "example_external_workspace", + path = "third_party/test/example_external_workspace", +) + +load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_toolchains") + +scala_register_unused_deps_toolchains() + +register_toolchains("@io_bazel_rules_scala//test/proto:scalapb_toolchain") + +load("//scala:scala_maven_import_external.bzl", "java_import_external") + +# bazel's java_import_external has been altered in rules_scala to be a macro based on jvm_import_external +# in order to allow for other jvm-language imports (e.g. scala_import) +# the 3rd-party dependency below is using the java_import_external macro +# in order to make sure no regression with the original java_import_external +java_import_external( + name = "org_apache_commons_commons_lang_3_5_without_file", + generated_linkable_rule_name = "linkable_org_apache_commons_commons_lang_3_5_without_file", + jar_sha256 = "8ac96fc686512d777fca85e144f196cd7cfe0c0aec23127229497d1a38ff651c", + jar_urls = ["https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar"], + licenses = ["notice"], # Apache 2.0 + neverlink = True, + testonly_ = True, +) + +## Linting + +# load("//private:format.bzl", "format_repositories") +# +# format_repositories() + +load("@rules_java//java:repositories.bzl", "remote_jdk8_repos") + +# We need to select based on platform when we use these +# https://github.com/bazelbuild/bazel/issues/11655 +remote_jdk8_repos() + +http_archive( + name = "bazelci_rules", + sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e", + strip_prefix = "bazelci_rules-1.0.0", + url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz", +) + +load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig") + +rbe_preconfig( + name = "rbe_default", + toolchain = "ubuntu2004-bazel-java11", +) + +load("//third_party/repositories:repositories.bzl", "repositories") + +repositories( + fetch_sources = False, + for_artifact_ids = [ + # test adding a scala jar: + "com_twitter__scalding_date", + # test of strict deps (scalac plugin UT + E2E) + "com_google_guava_guava_21_0_with_file", + "com_github_jnr_jffi_native", + "org_apache_commons_commons_lang_3_5", + "com_google_guava_guava_21_0", + # test of import external + # scala maven import external decodes maven artifacts to its parts + # (group id, artifact id, packaging, version and classifier). To make sure + # the decoding and then the download url composition are working the artifact example + # must contain all the different parts and sha256s so the downloaded content will be + # validated against it + "org_springframework_spring_core", + "org_springframework_spring_tx", + "org_typelevel_kind_projector", + # For testing that we don't include sources jars to the classpath + "org_typelevel__cats_core", + ], + maven_servers = MAVEN_SERVER_URLS, +) + +load("//test/toolchains:jdk.bzl", "remote_jdk21_repositories", "remote_jdk21_toolchains") + +remote_jdk21_repositories() + +remote_jdk21_toolchains() \ No newline at end of file diff --git a/extensions/non_module_deps.bzl b/extensions/non_module_deps.bzl new file mode 100644 index 000000000..3ba665ce2 --- /dev/null +++ b/extensions/non_module_deps.bzl @@ -0,0 +1,75 @@ +load("//third_party/repositories:repositories.bzl", "repository") +load( + "@io_bazel_rules_scala//scala/private:macros/scala_repositories.bzl", + _dt_patched_compiler_setup = "dt_patched_compiler_setup", +) +load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_VERSION") + +def _non_module_deps_impl(ctx): + _dt_patched_compiler_setup(SCALA_VERSION) + repository( + id = "io_bazel_rules_scala_scala_library", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_scala_compiler", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_scala_xml", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_scala_parser_combinators", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_scala_interfaces", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_scala_reflect", + validate_scala_version = True, + ) + repository( + id = "org_scalameta_semanticdb_scalac", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_scala_tasty_core", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_scala_asm", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_scala_library_2", + validate_scala_version = True, + ) + repository( + id = "io_bazel_rules_scala_org_openjdk_jmh_jmh_core", + fetch_sources = False, + ) + repository( + id = "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm", + fetch_sources = False, + ) + repository( + id = "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection", + fetch_sources = False, + ) + repository( + id = "io_bazel_rules_scala_org_ows2_asm_asm", + fetch_sources = False, + ) + repository( + id = "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple", + fetch_sources = False, + ) + repository( + id = "io_bazel_rules_scala_org_apache_commons_commons_math3", + fetch_sources = False, + ) + +non_module_deps = module_extension(implementation = _non_module_deps_impl) diff --git a/extensions/scala_config_ext.bzl b/extensions/scala_config_ext.bzl new file mode 100644 index 000000000..f991448ac --- /dev/null +++ b/extensions/scala_config_ext.bzl @@ -0,0 +1,8 @@ +load("//:scala_config.bzl", "scala_config") + +def _scala_config_dep_impl(ctx): + scala_config(enable_compiler_dependency_tracking = True) + +scala_config_dep = module_extension( + implementation = _scala_config_dep_impl, +) diff --git a/scala/private/phases/phase_dependency.bzl b/scala/private/phases/phase_dependency.bzl index d8ae91e7e..a2689d362 100644 --- a/scala/private/phases/phase_dependency.bzl +++ b/scala/private/phases/phase_dependency.bzl @@ -85,11 +85,11 @@ def _get_unused_deps_mode(ctx): def _is_target_included(target, includes, excludes): for exclude in excludes: - if target.startswith(exclude): + if target.startswith(exclude) or target.startswith("@" + exclude): return False for include in includes: - if target.startswith(include): + if target.startswith(include) or target.startswith("@" + include): return True return False diff --git a/scala/private/rules/scala_repl.bzl b/scala/private/rules/scala_repl.bzl index 6d08c8b84..49586da79 100644 --- a/scala/private/rules/scala_repl.bzl +++ b/scala/private/rules/scala_repl.bzl @@ -81,7 +81,10 @@ def make_scala_repl(*extras): common_outputs, *[extra["outputs"] for extra in extras if "outputs" in extra] ), - toolchains = ["@io_bazel_rules_scala//scala:toolchain_type"], + toolchains = [ + "@io_bazel_rules_scala//scala:toolchain_type", + "@bazel_tools//tools/jdk:toolchain_type", + ], cfg = scala_version_transition, incompatible_use_toolchain_transition = True, implementation = _scala_repl_impl, diff --git a/scala/scala_maven_import_external.bzl b/scala/scala_maven_import_external.bzl index 49b9f63e1..c7a9ae68c 100644 --- a/scala/scala_maven_import_external.bzl +++ b/scala/scala_maven_import_external.bzl @@ -64,7 +64,9 @@ def _jvm_import_external(repository_ctx): if (repository_ctx.attr.generated_linkable_rule_name and not repository_ctx.attr.neverlink): fail("Only use generated_linkable_rule_name if neverlink is set") - name = repository_ctx.attr.generated_rule_name or repository_ctx.name + name = repository_ctx.attr.repo_name or repository_ctx.attr.generated_rule_name or repository_ctx.name + # HACK: remove the prefix up to the last ~ + name = name[name.rfind("~") + 1:] urls = repository_ctx.attr.jar_urls if repository_ctx.attr.jar_sha256: print("'jar_sha256' is deprecated. Please use 'artifact_sha256'") @@ -136,7 +138,7 @@ def _jvm_import_external(repository_ctx): "", "alias(", " name = \"jar\",", - " actual = \"@%s\"," % repository_ctx.name, + " actual = \"@%s\"," % (repository_ctx.attr.repo_name or repository_ctx.name), ")", "", ])) @@ -226,6 +228,7 @@ jvm_import_external = repository_rule( implementation = _jvm_import_external, attrs = { "rule_name": attr.string(mandatory = True), + "repo_name": attr.string(), "licenses": attr.string_list(mandatory = True, allow_empty = False), "jar_urls": attr.string_list(mandatory = True, allow_empty = False), "jar_sha256": attr.string(doc = "'jar_sha256' is deprecated. Please use 'artifact_sha256'"), diff --git a/test/proto_cross_repo_boundary/repo.bzl b/test/proto_cross_repo_boundary/repo.bzl index 0f19c06d2..fe3fecf04 100644 --- a/test/proto_cross_repo_boundary/repo.bzl +++ b/test/proto_cross_repo_boundary/repo.bzl @@ -2,5 +2,5 @@ def proto_cross_repo_boundary_repository(): native.new_local_repository( name = "proto_cross_repo_boundary", path = "test/proto_cross_repo_boundary/repo", - build_file = "test/proto_cross_repo_boundary/repo/BUILD.repo", + build_file = "//test/proto_cross_repo_boundary:repo/BUILD.repo", ) diff --git a/test/shell/test_scala_config.sh b/test/shell/test_scala_config.sh index 88870f8ea..2f9071035 100755 --- a/test/shell/test_scala_config.sh +++ b/test/shell/test_scala_config.sh @@ -18,7 +18,7 @@ test_classpath_contains_2_13() { test_scala_config_content() { bazel build --repo_env=SCALA_VERSION=0.0.0 @io_bazel_rules_scala_config//:all 2> /dev/null - grep "SCALA_MAJOR_VERSION='0.0'" $(bazel info output_base)/external/io_bazel_rules_scala_config/config.bzl + grep "SCALA_MAJOR_VERSION='0.0'" $(bazel info output_base)/external/*/config.bzl } $runner test_classpath_contains_2_12 diff --git a/test/shell/test_scala_library.sh b/test/shell/test_scala_library.sh index ec43e1e7d..4826f35c1 100755 --- a/test/shell/test_scala_library.sh +++ b/test/shell/test_scala_library.sh @@ -177,7 +177,7 @@ test_scala_library_expect_better_failure_with_target_label_from_stamped_jar_on_m test_scala_library_expect_better_failure_message_on_missing_transitive_dependency_labels_from_other_jvm_rules() { transitive_target='.*transitive_dependency_without_manifest.jar' - direct_target='@//test_expect_failure/missing_direct_deps/internal_deps:unstamped_direct_java_provider_dependency' + direct_target='@.*//test_expect_failure/missing_direct_deps/internal_deps:unstamped_direct_java_provider_dependency' test_target='//test_expect_failure/missing_direct_deps/internal_deps:unstamped_jar_dependent_on_some_java_provider' expected_message="Unknown label of file $transitive_target which came from $direct_target" diff --git a/test/shell/test_strict_dependency.sh b/test/shell/test_strict_dependency.sh index da6537815..c4fe4ba57 100755 --- a/test/shell/test_strict_dependency.sh +++ b/test/shell/test_strict_dependency.sh @@ -41,7 +41,7 @@ test_plus_one_ast_analyzer_strict_deps() { test_stamped_target_label_loading() { local test_target="//test_expect_failure/missing_direct_deps/external_deps:java_lib_with_a_transitive_external_dep" - local expected_message="buildozer 'add deps @io_bazel_rules_scala_guava//:io_bazel_rules_scala_guava' ${test_target}" + local expected_message="buildozer 'add deps @.*io_bazel_rules_scala_guava//:io_bazel_rules_scala_guava' ${test_target}" test_expect_failure_or_warning_on_missing_direct_deps_with_expected_message \ "${expected_message}" ${test_target} \ @@ -56,7 +56,7 @@ test_strict_deps_filter_excluded_target() { test_strict_deps_filter_included_target() { local test_target="//test_expect_failure/missing_direct_deps/filtering:b" - local expected_message="buildozer 'add deps @com_google_guava_guava_21_0//:com_google_guava_guava_21_0' ${test_target}" + local expected_message="buildozer 'add deps @.*com_google_guava_guava_21_0//:com_google_guava_guava_21_0' ${test_target}" test_expect_failure_or_warning_on_missing_direct_deps_with_expected_message \ "${expected_message}" ${test_target} \ @@ -66,7 +66,7 @@ test_strict_deps_filter_included_target() { test_demonstrate_INCORRECT_scala_proto_library_stamp() { local test_target="//test_expect_failure/missing_direct_deps/scala_proto_deps:uses_transitive_scala_proto" - local incorrectly_stamped_expected_message="buildozer 'add deps @//test_expect_failure/missing_direct_deps/scala_proto_deps:some_proto' ${test_target}" + local incorrectly_stamped_expected_message="buildozer 'add deps @.*//test_expect_failure/missing_direct_deps/scala_proto_deps:some_proto' ${test_target}" # When stamping is fixed, expected stamp is: # local correctly_stamped_expected_message="buildozer 'add deps //test_expect_failure/missing_direct_deps/scala_proto_deps:some_scala_proto' ${test_target}" @@ -79,7 +79,7 @@ test_demonstrate_INCORRECT_scala_proto_library_stamp() { test_scala_proto_library_stamp_by_convention() { local test_target="//test_expect_failure/missing_direct_deps/scala_proto_deps:uses_transitive_scala_proto" - local expected_message="buildozer 'add deps @//test_expect_failure/missing_direct_deps/scala_proto_deps:some_scala_proto' ${test_target}" + local expected_message="buildozer 'add deps @.*//test_expect_failure/missing_direct_deps/scala_proto_deps:some_scala_proto' ${test_target}" test_expect_failure_or_warning_on_missing_direct_deps_with_expected_message \ "${expected_message}" ${test_target} \ @@ -89,7 +89,7 @@ test_scala_proto_library_stamp_by_convention() { test_scala_proto_library_custom_phase_stamping() { local test_target="//test_expect_failure/missing_direct_deps/scala_proto_deps:uses_transitive_some_proto_custom_suffix" - local expected_message="buildozer 'add deps @//test_expect_failure/missing_direct_deps/scala_proto_deps:some_proto_custom_suffix' ${test_target}" + local expected_message="buildozer 'add deps .*@//test_expect_failure/missing_direct_deps/scala_proto_deps:some_proto_custom_suffix' ${test_target}" test_expect_failure_or_warning_on_missing_direct_deps_with_expected_message \ "${expected_message}" ${test_target} \ diff --git a/test_version.sh b/test_version.sh index 549e3cdaf..ebc9f8de9 100755 --- a/test_version.sh +++ b/test_version.sh @@ -44,6 +44,12 @@ run_in_test_repo() { sed \ -e "s%\${twitter_scrooge_repositories}%$TWITTER_SCROOGE_REPOSITORIES%" \ WORKSPACE.template >> $NEW_TEST_DIR/WORKSPACE + sed \ + -e "s%\${twitter_scrooge_repositories}%$TWITTER_SCROOGE_REPOSITORIES%" \ + WORKSPACE.template >> $NEW_TEST_DIR/WORKSPACE.bzlmod + sed \ + -e "s%\${twitter_scrooge_repositories}%$TWITTER_SCROOGE_REPOSITORIES%" \ + MODULE.template >> $NEW_TEST_DIR/MODULE.bazel cp ../.bazelrc $NEW_TEST_DIR/.bazelrc cd $NEW_TEST_DIR diff --git a/test_version/MODULE.template b/test_version/MODULE.template new file mode 100644 index 000000000..065b8148a --- /dev/null +++ b/test_version/MODULE.template @@ -0,0 +1 @@ +module(name = "io_bazel_rules_scala_test") diff --git a/test_version/WORKSPACE.template b/test_version/WORKSPACE.template index 34c499f2f..84869cb17 100644 --- a/test_version/WORKSPACE.template +++ b/test_version/WORKSPACE.template @@ -1,3 +1,4 @@ +# TODO(#1482) migrate to bzlmod workspace(name = "io_bazel_rules_scala_test") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") @@ -11,22 +12,6 @@ http_archive( ], ) -http_archive( - name = "rules_proto", - sha256 = "8e7d59a5b12b233be5652e3d29f42fba01c7cbab09f6b3a8d0a57ed6d1e9a0da", - strip_prefix = "rules_proto-7e4afce6fe62dbff0a4a03450143146f9f2d7488", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", - "https://github.com/bazelbuild/rules_proto/archive/7e4afce6fe62dbff0a4a03450143146f9f2d7488.tar.gz", - ], -) - -load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") - -rules_proto_dependencies() - -rules_proto_toolchains() - local_repository( name = "io_bazel_rules_scala", path = "../../" @@ -41,6 +26,12 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories") scala_repositories(fetch_sources = True) +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() + +rules_proto_toolchains() + load(":scrooge_repositories.bzl", "scrooge_repositories") ${twitter_scrooge_repositories} diff --git a/third_party/repositories/repositories.bzl b/third_party/repositories/repositories.bzl index 816751663..9028c6096 100644 --- a/third_party/repositories/repositories.bzl +++ b/third_party/repositories/repositories.bzl @@ -109,8 +109,12 @@ def repositories( def _alias_repository_impl(rctx): """ Builds a repository containing just two aliases to the Scala Maven artifacts in the `target` repository. """ + # HACK: remove the prefix up to the last ~ + name = str(rctx.name) + name = name[name.rfind("~") + 1:] + format_kwargs = { - "name": rctx.name, + "name": name, "target": rctx.attr.target, } rctx.file("BUILD", """alias( @@ -132,3 +136,46 @@ _alias_repository = repository_rule( "target": attr.string(mandatory = True), }, ) + +def repository( + id, + maven_servers = default_maven_server_urls(), + fetch_sources = True, + validate_scala_version = False): + suffix = version_suffix(SCALA_VERSION) + major_scala_version = extract_major_version(SCALA_VERSION) + default_artifacts = artifacts_by_major_scala_version[major_scala_version] + artifacts = dict(default_artifacts.items()) + + # workaround to satisfy bzlmod builds + # in a MODULE.bazel file we don't know which scala version is set, + # so we register every possible repo, even if the given version does not require it + if artifacts[id].get("dummy", False) == True: + dummy_repo(repo_name = id) + else: + _scala_maven_import_external( + name = id + suffix, + artifact = artifacts[id]["artifact"], + artifact_sha256 = artifacts[id]["sha256"], + licenses = ["notice"], + server_urls = maven_servers, + deps = [dep + suffix for dep in artifacts[id].get("deps", [])], + runtime_deps = artifacts[id].get("runtime_deps", []), + testonly_ = artifacts[id].get("testonly", False), + fetch_sources = fetch_sources, + ) + + # For backward compatibility: non-suffixed repo pointing to the suffixed one, + # See: https://github.com/bazelbuild/rules_scala/pull/1573 + # Hopefully we can deprecate and remove it one day. + _alias_repository(name = id, target = id + suffix) + +def _dummy_repo_impl(repository_ctx): + repository_ctx.file("BUILD") + +_dummy_repo = repository_rule( + implementation = _dummy_repo_impl, +) + +def dummy_repo(repo_name): + _dummy_repo(name = repo_name) diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 06431a6bc..01149a262 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -514,4 +514,16 @@ artifacts = { "artifact": "org.typelevel:kind-projector_%s:0.13.2" % scala_version, "sha256": "8f7287973f7f8fc9372b59d36120e3fac5839344f65c8f640351794e8907145c", }, + "io_bazel_rules_scala_scala_interfaces": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_tasty_core": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_asm": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_library_2": { + "dummy": True, + }, } diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index bf72fa488..1aac165ac 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -511,4 +511,16 @@ artifacts = { "artifact": "org.typelevel:kind-projector_%s:0.13.2" % scala_version, "sha256": "7d4e821b86647c65546c1e3667348e8168c5907e9d4b277cc2badedcd479be44", }, + "io_bazel_rules_scala_scala_interfaces": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_tasty_core": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_asm": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_library_2": { + "dummy": True, + }, } diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index 1864c5241..0f3d9f941 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -516,4 +516,16 @@ artifacts = { "artifact": "org.typelevel:kind-projector_%s:0.13.2" % scala_version, "sha256": "4bd985e53ac950a1f130981f7ec9a2c5dffe4c2f588fc695180c6105f4a9557f", }, + "io_bazel_rules_scala_scala_interfaces": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_tasty_core": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_asm": { + "dummy": True, + }, + "io_bazel_rules_scala_scala_library_2": { + "dummy": True, + }, } diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index 765f1f196..98c62a21f 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -526,4 +526,10 @@ artifacts = { "artifact": "org.typelevel:kind-projector_2.13.12:0.13.2", "sha256": "4bd985e53ac950a1f130981f7ec9a2c5dffe4c2f588fc695180c6105f4a9557f", }, + "io_bazel_rules_scala_scala_reflect": { + "dummy": True, + }, + "org_scalameta_semanticdb_scalac": { + "dummy": True, + }, } diff --git a/third_party/repositories/scala_3_2.bzl b/third_party/repositories/scala_3_2.bzl index d0ae2dc3f..852108d91 100644 --- a/third_party/repositories/scala_3_2.bzl +++ b/third_party/repositories/scala_3_2.bzl @@ -526,4 +526,10 @@ artifacts = { "artifact": "org.typelevel:kind-projector_2.13.12:0.13.2", "sha256": "4bd985e53ac950a1f130981f7ec9a2c5dffe4c2f588fc695180c6105f4a9557f", }, + "io_bazel_rules_scala_scala_reflect": { + "dummy": True, + }, + "org_scalameta_semanticdb_scalac": { + "dummy": True, + }, } diff --git a/third_party/repositories/scala_3_3.bzl b/third_party/repositories/scala_3_3.bzl index 7d5105955..0390e0de0 100644 --- a/third_party/repositories/scala_3_3.bzl +++ b/third_party/repositories/scala_3_3.bzl @@ -524,4 +524,10 @@ artifacts = { "artifact": "org.typelevel:kind-projector_2.13.12:0.13.2", "sha256": "4bd985e53ac950a1f130981f7ec9a2c5dffe4c2f588fc695180c6105f4a9557f", }, + "io_bazel_rules_scala_scala_reflect": { + "dummy": True, + }, + "org_scalameta_semanticdb_scalac": { + "dummy": True, + }, }