From 5257a5e688a00ed227a7c305562bdb6ccf3771dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Fri, 7 Jan 2022 10:30:20 +0100 Subject: [PATCH 01/36] Add SemanticDB support --- WORKSPACE | 3 +++ .../testing/scalatest_repositories/WORKSPACE | 4 ++++ scala/BUILD | 7 +++++++ scala/private/common_attributes.bzl | 5 +++++ scala/private/dependency.bzl | 1 + scala/private/rule_impls.bzl | 2 ++ scala/private/toolchain_deps/BUILD | 6 ++++++ scala/scala_toolchain.bzl | 1 + scala/semanticdb/BUILD | 0 scala/semanticdb/semanticdb_repositories.bzl | 16 ++++++++++++++++ third_party/repositories/scala_2_11.bzl | 4 ++++ third_party/repositories/scala_2_12.bzl | 4 ++++ third_party/repositories/scala_2_13.bzl | 4 ++++ 13 files changed, 57 insertions(+) create mode 100644 scala/semanticdb/BUILD create mode 100644 scala/semanticdb/semanticdb_repositories.bzl diff --git a/WORKSPACE b/WORKSPACE index 11c1a01c8..015b53642 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -61,11 +61,14 @@ specs2_junit_repositories() register_toolchains("//testing:testing_toolchain") load("//scala/scalafmt:scalafmt_repositories.bzl", "scalafmt_default_config", "scalafmt_repositories") +load("//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") scalafmt_default_config() scalafmt_repositories() +semanticdb_repositories() + MAVEN_SERVER_URLS = default_maven_server_urls() # needed for the cross repo proto test diff --git a/examples/testing/scalatest_repositories/WORKSPACE b/examples/testing/scalatest_repositories/WORKSPACE index 5289a417a..0b04f2036 100644 --- a/examples/testing/scalatest_repositories/WORKSPACE +++ b/examples/testing/scalatest_repositories/WORKSPACE @@ -39,3 +39,7 @@ load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", " scalatest_repositories() scalatest_toolchain() + +load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") + +semanticdb_repositories() diff --git a/scala/BUILD b/scala/BUILD index fd85870d9..03687fadf 100644 --- a/scala/BUILD +++ b/scala/BUILD @@ -112,3 +112,10 @@ declare_deps_provider( visibility = ["//visibility:public"], deps = ["@io_bazel_rules_scala_scala_parser_combinators"], ) + +declare_deps_provider( + name = "semanticdb_scalac_provider", + deps_id = "semanticdb_scalac", + visibility = ["//visibility:public"], + deps = ["@org_scalameta_semanticdb_scalac"], +) diff --git a/scala/private/common_attributes.bzl b/scala/private/common_attributes.bzl index ed5f8ebb3..fa0a849e6 100644 --- a/scala/private/common_attributes.bzl +++ b/scala/private/common_attributes.bzl @@ -58,6 +58,11 @@ common_attrs.update({ "_dependency_analyzer_plugin": attr.label( default = Label( "@io_bazel_rules_scala//third_party/dependency_analyzer/src/main:dependency_analyzer", + ), allow_files = [".jar"], mandatory = False, + ), + "_semanticdb_scalac_plugin": attr.label( + default = Label( + "@io_bazel_rules_scala//scala/private/toolchain_deps:semanticdb_scalac", ), allow_files = [".jar"], mandatory = False, diff --git a/scala/private/dependency.bzl b/scala/private/dependency.bzl index 7c9a8032d..95cef39e3 100644 --- a/scala/private/dependency.bzl +++ b/scala/private/dependency.bzl @@ -23,6 +23,7 @@ def new_dependency_info( unused_deps_mode = unused_deps_mode, strict_deps_mode = strict_deps_mode, use_analyzer = is_strict_deps_on or is_unused_deps_on, + use_semanticdb_scalac = True, ) # TODO(https://github.com/bazelbuild/rules_scala/issues/987): Clariy the situation diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index a18c10676..20fb6163f 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -61,6 +61,8 @@ def compile_scala( plugins = _collect_plugin_paths(plugins) if dependency_info.use_analyzer: plugins = depset(transitive = [plugins, ctx.attr._dependency_analyzer_plugin.files]) + if dependency_info.use_semanticdb_scalac and False: + plugins = depset(transitive = [plugins, ctx.attr._semanticdb_scalac_plugin.files]) toolchain = ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"] compiler_classpath_jars = cjars if dependency_info.dependency_mode == "direct" else transitive_compile_jars diff --git a/scala/private/toolchain_deps/BUILD b/scala/private/toolchain_deps/BUILD index a5bc109d5..467a87765 100644 --- a/scala/private/toolchain_deps/BUILD +++ b/scala/private/toolchain_deps/BUILD @@ -23,3 +23,9 @@ common_toolchain_deps( deps_id = "parser_combinators", visibility = ["//visibility:public"], ) + +common_toolchain_deps( + name = "semanticdb_scalac", + deps_id = "semanticdb_scalac", + visibility = ["//visibility:public"], +) diff --git a/scala/scala_toolchain.bzl b/scala/scala_toolchain.bzl index 5514a3de0..f02014bc8 100644 --- a/scala/scala_toolchain.bzl +++ b/scala/scala_toolchain.bzl @@ -93,6 +93,7 @@ scala_toolchain = rule( "scalacopts": attr.string_list(), "dep_providers": attr.label_list( default = [ + "@io_bazel_rules_scala//scala:semanticdb_scalac_provider", "@io_bazel_rules_scala//scala:scala_xml_provider", "@io_bazel_rules_scala//scala:parser_combinators_provider", "@io_bazel_rules_scala//scala:scala_compile_classpath_provider", diff --git a/scala/semanticdb/BUILD b/scala/semanticdb/BUILD new file mode 100644 index 000000000..e69de29bb diff --git a/scala/semanticdb/semanticdb_repositories.bzl b/scala/semanticdb/semanticdb_repositories.bzl new file mode 100644 index 000000000..37924441d --- /dev/null +++ b/scala/semanticdb/semanticdb_repositories.bzl @@ -0,0 +1,16 @@ +load( + "//scala:scala_cross_version.bzl", + _default_maven_server_urls = "default_maven_server_urls", +) +load("//third_party/repositories:repositories.bzl", "repositories") + + +def semanticdb_repositories( + maven_servers = _default_maven_server_urls(), + overriden_artifacts = {}): + repositories( + for_artifact_ids = ["org_scalameta_semanticdb_scalac"], + maven_servers = maven_servers, + fetch_sources = False, + overriden_artifacts = overriden_artifacts, + ) diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 910f83933..1c5d48425 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -75,6 +75,10 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_2.11.12:4.4.31", + "sha256": "d61eb07ff182173c8b30b7caa4bba2bd04fd2c921552ad1c550073f1f0262ed7", + }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.11:1.0.1", "sha256": "49ecc30a4b47efc0038099da0c97515cf8f754ea631ea9f9935b36ca7d41b733", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index ae6bed951..8ef6c6497 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -75,6 +75,10 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_2.12.14:4.4.31", + "sha256": "8a6d71f1611ede0fdc435a851fdd67ccb64c68b80b2153fce4a389eb33ed7416", + }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.12:1.0.1", "sha256": "387ced762e93915c5f87fed59d8453e404273f49f812d413405696ce20273aa5", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index a6fdda4e3..fdaa00f8f 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -79,6 +79,10 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_2.13.6:4.4.31", + "sha256": "09f270c275701cfba93620ddd5c0b287a5c123cf528e837c518d5b5dd85efff0", + }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.13:1.0.1", "sha256": "b43b99244d5b51948daf1467083b3850dc2727c604de98dc426dec14244fd18e", From 85c72b270e29d4cb1aecf70521093d32f22751e7 Mon Sep 17 00:00:00 2001 From: Matt Peterson Date: Thu, 18 Aug 2022 17:46:46 -0600 Subject: [PATCH 02/36] Semanticdb output works --- scala/private/common_attributes.bzl | 2 +- scala/private/dependency.bzl | 1 - scala/private/rule_impls.bzl | 19 +++++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/scala/private/common_attributes.bzl b/scala/private/common_attributes.bzl index fa0a849e6..2ce3f6376 100644 --- a/scala/private/common_attributes.bzl +++ b/scala/private/common_attributes.bzl @@ -64,7 +64,7 @@ common_attrs.update({ default = Label( "@io_bazel_rules_scala//scala/private/toolchain_deps:semanticdb_scalac", ), - allow_files = [".jar"], + providers = [[JavaInfo]], mandatory = False, ), "unused_dependency_checker_mode": attr.string( diff --git a/scala/private/dependency.bzl b/scala/private/dependency.bzl index 95cef39e3..7c9a8032d 100644 --- a/scala/private/dependency.bzl +++ b/scala/private/dependency.bzl @@ -23,7 +23,6 @@ def new_dependency_info( unused_deps_mode = unused_deps_mode, strict_deps_mode = strict_deps_mode, use_analyzer = is_strict_deps_on or is_unused_deps_on, - use_semanticdb_scalac = True, ) # TODO(https://github.com/bazelbuild/rules_scala/issues/987): Clariy the situation diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index 20fb6163f..1f802772e 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -56,13 +56,16 @@ def compile_scala( dependency_info, unused_dependency_checker_ignored_targets, stamp_target_label = None): + + outs = [output, statsfile, diagnosticsfile] + # look for any plugins: input_plugins = plugins + if hasattr(ctx.attr, "_semanticdb_scalac_plugin"): + plugins = plugins + [ctx.attr._semanticdb_scalac_plugin] plugins = _collect_plugin_paths(plugins) if dependency_info.use_analyzer: plugins = depset(transitive = [plugins, ctx.attr._dependency_analyzer_plugin.files]) - if dependency_info.use_semanticdb_scalac and False: - plugins = depset(transitive = [plugins, ctx.attr._semanticdb_scalac_plugin.files]) toolchain = ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"] compiler_classpath_jars = cjars if dependency_info.dependency_mode == "direct" else transitive_compile_jars @@ -72,6 +75,16 @@ def compile_scala( enable_stats_file = toolchain.enable_stats_file enable_diagnostics_report = toolchain.enable_diagnostics_report + if hasattr(ctx.attr, "_semanticdb_scalac_plugin"): + semanticdb_dir = ctx.actions.declare_directory("{}.semanticdb".format(ctx.label.name)) + outs.append(semanticdb_dir) + scalacopts = scalacopts + [ + "-Yrangepos", + "-P:semanticdb:failures:error", + "-P:semanticdb:targetroot:{}/{}/{}.semanticdb".format(ctx.bin_dir.path, ctx.label.package, ctx.label.name), + "-Xplugin-require:semanticdb", + ] + args = ctx.actions.args() args.set_param_file_format("multiline") args.use_param_file(param_file_arg = "@%s", use_always = True) @@ -111,8 +124,6 @@ def compile_scala( if dependency_info.unused_deps_mode != "off": args.add_all("--UnusedDepsIgnoredTargets", unused_dependency_checker_ignored_targets) - outs = [output, statsfile, diagnosticsfile] - ins = depset( direct = [manifest] + sources + classpath_resources + resources + resource_jars, transitive = [compiler_classpath_jars, all_srcjars, plugins], From cdff7ffccd0538edb9b2472e6e801a81c7da35be Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 15 Jan 2023 00:25:24 +0000 Subject: [PATCH 03/36] fixup to make work with scalaopt phase --- scala/private/rule_impls.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index a55ac0615..bcae371f2 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -78,7 +78,7 @@ def compile_scala( if hasattr(ctx.attr, "_semanticdb_scalac_plugin"): semanticdb_dir = ctx.actions.declare_directory("{}.semanticdb".format(ctx.label.name)) outs.append(semanticdb_dir) - scalacopts = scalacopts + [ + scalacopts_expanded = scalacopts_expanded + [ "-Yrangepos", "-P:semanticdb:failures:error", "-P:semanticdb:targetroot:{}/{}/{}.semanticdb".format(ctx.bin_dir.path, ctx.label.package, ctx.label.name), From 83ffcc737f7cd8064e66dedcf844a43db093865c Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 29 Jan 2023 03:08:42 +0000 Subject: [PATCH 04/36] fixed tests --- WORKSPACE | 5 +++-- examples/testing/multi_frameworks_toolchain/WORKSPACE | 4 ++++ examples/testing/specs2_junit_repositories/WORKSPACE | 4 ++++ scala/BUILD | 2 +- scala/private/macros/scala_repositories.bzl | 1 + scala/private/macros/setup_scala_toolchain.bzl | 10 ++++++++++ test_version/WORKSPACE.template | 4 ++++ third_party/repositories/scala_2_11.bzl | 4 ++-- third_party/repositories/scala_2_12.bzl | 4 ++-- third_party/repositories/scala_2_13.bzl | 4 ++-- twitter_scrooge/BUILD | 7 +++++++ 11 files changed, 40 insertions(+), 9 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index daea1b64d..1b9268a8f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -24,6 +24,9 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config") scala_config() +load("//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") +semanticdb_repositories() + load("//scala:scala.bzl", "rules_scala_setup", "rules_scala_toolchain_deps_repositories") rules_scala_setup() @@ -63,13 +66,11 @@ specs2_junit_repositories() register_toolchains("//testing:testing_toolchain") load("//scala/scalafmt:scalafmt_repositories.bzl", "scalafmt_default_config", "scalafmt_repositories") -load("//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") scalafmt_default_config() scalafmt_repositories() -semanticdb_repositories() MAVEN_SERVER_URLS = default_maven_server_urls() diff --git a/examples/testing/multi_frameworks_toolchain/WORKSPACE b/examples/testing/multi_frameworks_toolchain/WORKSPACE index 09699cf97..3ca407a9a 100644 --- a/examples/testing/multi_frameworks_toolchain/WORKSPACE +++ b/examples/testing/multi_frameworks_toolchain/WORKSPACE @@ -51,3 +51,7 @@ junit_repositories() specs2_junit_repositories() register_toolchains(":testing_toolchain") + +load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") + +semanticdb_repositories() diff --git a/examples/testing/specs2_junit_repositories/WORKSPACE b/examples/testing/specs2_junit_repositories/WORKSPACE index 31055155a..2bd486508 100644 --- a/examples/testing/specs2_junit_repositories/WORKSPACE +++ b/examples/testing/specs2_junit_repositories/WORKSPACE @@ -45,3 +45,7 @@ load("@io_bazel_rules_scala//testing:specs2_junit.bzl", "specs2_junit_repositori specs2_junit_repositories() specs2_junit_toolchain() + +load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") + +semanticdb_repositories() diff --git a/scala/BUILD b/scala/BUILD index 2a1563f52..064f653d5 100644 --- a/scala/BUILD +++ b/scala/BUILD @@ -113,4 +113,4 @@ declare_deps_provider( deps_id = "semanticdb_scalac", visibility = ["//visibility:public"], deps = ["@org_scalameta_semanticdb_scalac"], -) +) \ No newline at end of file diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index f4c923005..b5cd6e226 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -57,6 +57,7 @@ ARTIFACT_IDS = [ "io_bazel_rules_scala_scala_xml", "io_bazel_rules_scala_scala_parser_combinators", "io_bazel_rules_scala_scala_library_2", + "org_scalameta_semanticdb_scalac", ] def rules_scala_toolchain_deps_repositories( diff --git a/scala/private/macros/setup_scala_toolchain.bzl b/scala/private/macros/setup_scala_toolchain.bzl index 93f2dac80..1036a0448 100644 --- a/scala/private/macros/setup_scala_toolchain.bzl +++ b/scala/private/macros/setup_scala_toolchain.bzl @@ -15,6 +15,7 @@ def setup_scala_toolchain( scala_compile_classpath_provider = "%s_scala_compile_classpath_provider" % name scala_library_classpath_provider = "%s_scala_library_classpath_provider" % name scala_macro_classpath_provider = "%s_scala_macro_classpath_provider" % name + semanticdb_scalac_provider = "%s_scala_semanticdb_scalac_provider" % name declare_deps_provider( name = scala_compile_classpath_provider, @@ -57,9 +58,18 @@ def setup_scala_toolchain( else: parser_combinators_provider = "@io_bazel_rules_scala//scala:parser_combinators_provider" + + declare_deps_provider( + name = semanticdb_scalac_provider, + deps_id = "semanticdb_scalac", + visibility = visibility, + deps = ["@org_scalameta_semanticdb_scalac"], + ) + scala_toolchain( name = "%s_impl" % name, dep_providers = [ + semanticdb_scalac_provider, scala_xml_provider, parser_combinators_provider, scala_compile_classpath_provider, diff --git a/test_version/WORKSPACE.template b/test_version/WORKSPACE.template index 20a89ec9e..107ed929b 100644 --- a/test_version/WORKSPACE.template +++ b/test_version/WORKSPACE.template @@ -68,3 +68,7 @@ register_toolchains("@io_bazel_rules_scala//testing:testing_toolchain") load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_toolchains") scala_register_unused_deps_toolchains() + +load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") + +semanticdb_repositories() \ No newline at end of file diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 11843f1ec..947568f0b 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -78,8 +78,8 @@ artifacts = { ], }, "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.11.12:4.4.31", - "sha256": "d61eb07ff182173c8b30b7caa4bba2bd04fd2c921552ad1c550073f1f0262ed7", + "artifact": "org.scalameta:semanticdb-scalac_2.11.12:4.7.3", + "sha256": "0db52fc6639f73b15c3fb9fc1cb441704399f0d8dee8352ca1cf359630e7ca0f", }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.11:1.0.1", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index a0091402a..9cec6dc8d 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -78,8 +78,8 @@ artifacts = { ], }, "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.12.14:4.4.31", - "sha256": "8a6d71f1611ede0fdc435a851fdd67ccb64c68b80b2153fce4a389eb33ed7416", + "artifact": "org.scalameta:semanticdb-scalac_2.12.14:4.7.3", + "sha256": "e5e31e1b48aedd3c7c2c2731d5053fd3429a3b37f076d95e8214acfa551c226a", }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.12:1.0.1", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index 7754e27e6..a11f02b81 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -82,8 +82,8 @@ artifacts = { ], }, "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.13.6:4.4.31", - "sha256": "09f270c275701cfba93620ddd5c0b287a5c123cf528e837c518d5b5dd85efff0", + "artifact": "org.scalameta:semanticdb-scalac_2.13.6:4.7.3", + "sha256": "fbc7703b3ac407a4695d6055197cf9ea520260e0757dec488992b498a86ed656", }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.13:1.0.1", diff --git a/twitter_scrooge/BUILD b/twitter_scrooge/BUILD index f65df7c15..9afed8288 100644 --- a/twitter_scrooge/BUILD +++ b/twitter_scrooge/BUILD @@ -13,6 +13,13 @@ toolchain( visibility = ["//visibility:public"], ) +declare_deps_provider( + name = "semanticdb_scalac_provider", + deps_id = "semanticdb_scalac", + visibility = ["//visibility:public"], + deps = ["@org_scalameta_semanticdb_scalac"], +) + declare_deps_provider( name = "aspect_compile_classpath_provider", deps_id = "aspect_compile_classpath", From a2e9d401436032e49415801240ffd8d680f69e5b Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 29 Jan 2023 06:51:38 +0000 Subject: [PATCH 05/36] added tests --- scala/private/common.bzl | 2 +- scala/private/rule_impls.bzl | 28 ++++++++----- scala/scala_toolchain.bzl | 6 +++ .../rulesscala/scalac/CompileOptions.java | 27 ++++++++++-- .../bazel/rulesscala/scalac/ScalacWorker.java | 19 ++++++++- test/semanticdb/A.scala | 1 + test/semanticdb/B.scala | 1 + test/semanticdb/BUILD | 20 +++++++++ test/shell/test_semanticdb.sh | 41 +++++++++++++++++++ test_rules_scala.sh | 1 + 10 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 test/semanticdb/A.scala create mode 100644 test/semanticdb/B.scala create mode 100644 test/semanticdb/BUILD create mode 100755 test/shell/test_semanticdb.sh diff --git a/scala/private/common.bzl b/scala/private/common.bzl index d22cf86e0..a8626f5f0 100644 --- a/scala/private/common.bzl +++ b/scala/private/common.bzl @@ -64,7 +64,7 @@ def collect_plugin_paths(plugins): if hasattr(p, "path"): paths.append(p) elif JavaInfo in p: - paths.extend([j.class_jar for j in p[JavaInfo].outputs.jars]) + paths.extend([j.class_jar.path for j in p[JavaInfo].outputs.jars]) # support http_file pointed at a jar. http_jar uses ijar, # which breaks scala macros diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index bcae371f2..4088dd5f9 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -61,8 +61,6 @@ def compile_scala( # look for any plugins: input_plugins = plugins - if hasattr(ctx.attr, "_semanticdb_scalac_plugin"): - plugins = plugins + [ctx.attr._semanticdb_scalac_plugin] plugins = _collect_plugin_paths(plugins) if dependency_info.use_analyzer: plugins = depset(transitive = [plugins, ctx.attr._dependency_analyzer_plugin.files]) @@ -75,15 +73,12 @@ def compile_scala( enable_stats_file = toolchain.enable_stats_file enable_diagnostics_report = toolchain.enable_diagnostics_report - if hasattr(ctx.attr, "_semanticdb_scalac_plugin"): - semanticdb_dir = ctx.actions.declare_directory("{}.semanticdb".format(ctx.label.name)) - outs.append(semanticdb_dir) - scalacopts_expanded = scalacopts_expanded + [ - "-Yrangepos", - "-P:semanticdb:failures:error", - "-P:semanticdb:targetroot:{}/{}/{}.semanticdb".format(ctx.bin_dir.path, ctx.label.package, ctx.label.name), - "-Xplugin-require:semanticdb", - ] + enable_semanticdb = toolchain.enable_semanticdb + semanticdb_dir = "{}.semanticdb".format(ctx.label.name) + + if enable_semanticdb and hasattr(ctx.attr, "_semanticdb_scalac_plugin"): + semanticdb_out = ctx.actions.declare_directory(semanticdb_dir) + outs.append(semanticdb_out) args = ctx.actions.args() args.set_param_file_format("multiline") @@ -111,6 +106,17 @@ def compile_scala( args.add_all("--ScalacOpts", scalacopts_expanded) args.add_all("--SourceJars", all_srcjars) + args.add("--EnableSemanticDb", enable_semanticdb) + + if enable_semanticdb and hasattr(ctx.attr, "_semanticdb_scalac_plugin"): + target = "{}/{}/{}".format(ctx.bin_dir.path, ctx.label.package, semanticdb_dir) + # jar = ",".join(ctx.attr._semanticdb_scalac_plugin.files.to_list()) + + jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] + + args.add("--SemanticDbTarget", target) + args.add("--SemanticDbJar", jar) + if dependency_info.need_direct_info: if dependency_info.need_direct_jars: args.add_all("--DirectJars", cjars) diff --git a/scala/scala_toolchain.bzl b/scala/scala_toolchain.bzl index bb8023560..429f4fa49 100644 --- a/scala/scala_toolchain.bzl +++ b/scala/scala_toolchain.bzl @@ -61,6 +61,7 @@ def _scala_toolchain_impl(ctx): enable_stats_file = ctx.attr.enable_stats_file enable_diagnostics_report = ctx.attr.enable_diagnostics_report + enable_semanticdb = ctx.attr.enable_semanticdb all_strict_deps_patterns = ctx.attr.dependency_tracking_strict_deps_patterns strict_deps_includes, strict_deps_excludes = _partition_patterns(all_strict_deps_patterns) @@ -84,6 +85,7 @@ def _scala_toolchain_impl(ctx): enable_diagnostics_report = enable_diagnostics_report, jacocorunner = ctx.attr.jacocorunner, enable_stats_file = enable_stats_file, + enable_semanticdb = enable_semanticdb, use_argument_file_in_runner = ctx.attr.use_argument_file_in_runner, ) return [toolchain] @@ -139,6 +141,10 @@ scala_toolchain = rule( default = True, doc = "Enable writing of statsfile", ), + "enable_semanticdb": attr.bool( + default = False, + doc = "Enable SemanticDb", + ), "use_argument_file_in_runner": attr.bool( default = False, doc = "Changes java binaries scripts (including tests) to use argument files and not classpath jars to improve performance, requires java > 8", diff --git a/src/java/io/bazel/rulesscala/scalac/CompileOptions.java b/src/java/io/bazel/rulesscala/scalac/CompileOptions.java index 06284ea3c..921d8458c 100644 --- a/src/java/io/bazel/rulesscala/scalac/CompileOptions.java +++ b/src/java/io/bazel/rulesscala/scalac/CompileOptions.java @@ -3,6 +3,7 @@ import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Optional; public class CompileOptions { public final String outputName; @@ -34,6 +35,10 @@ public class CompileOptions { public final String diagnosticsFile; public final boolean enableDiagnosticsReport; + public final boolean enableSemanticDb; + public final Optional semanticDbTarget; + public final Optional semanticDbJar; + public CompileOptions(String[] lines) { Args args = new Args(lines); @@ -68,9 +73,13 @@ public CompileOptions(String[] lines) { statsfile = args.getSingleOrError("StatsfileOutput"); enableStatsFile = Boolean.parseBoolean(args.getSingleOrError("EnableStatsFile")); - enableDiagnosticsReport = - Boolean.parseBoolean(args.getSingleOrError("EnableDiagnosticsReport")); + enableDiagnosticsReport = Boolean.parseBoolean(args.getSingleOrError("EnableDiagnosticsReport")); diagnosticsFile = args.getSingleOrError("DiagnosticsFile"); + + enableSemanticDb = Boolean.parseBoolean(args.getSingleOrError("EnableSemanticDb")); + semanticDbTarget = args.getSingleOptional("SemanticDbTarget"); + semanticDbJar = args.getSingleOptional("SemanticDbJar"); + } static final class Args { @@ -93,17 +102,27 @@ String[] getOrEmpty(String k) { } String getSingleOrError(String k) { + Optional opt = getSingleOptional(k); + if (opt.isPresent()) { + return opt.get(); + } else { + throw new RuntimeException("Missing required arg " + k); + } + } + + Optional getSingleOptional(String k) { if (index.containsKey(k)) { String[] v = index.get(k); if (v.length == 1) { - return v[0]; + return Optional.of(v[0]); } else { throw new RuntimeException( k + " expected to contain single value but got " + Arrays.toString(v)); } } else { - throw new RuntimeException("Missing required arg " + k); + return Optional.empty(); } } + } } diff --git a/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java b/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java index d9d124732..8cec21416 100644 --- a/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java +++ b/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java @@ -232,6 +232,18 @@ private static String[] getPluginParamsFrom(CompileOptions ops) { "-P:dependency-analyzer:unused-deps-ignored-targets:" + String.join(":", ignoredTargets)); } + } + + if (ops.enableSemanticDb) { + + String[] params = { + "-Yrangepos", + "-P:semanticdb:failures:error", + "-P:semanticdb:targetroot:" + ops.semanticDbTarget.get(), + "-Xplugin-require:semanticdb" + }; + + pluginParams.addAll(Arrays.asList(params)); } return pluginParams.toArray(new String[pluginParams.size()]); @@ -240,7 +252,12 @@ private static String[] getPluginParamsFrom(CompileOptions ops) { private static void compileScalaSources(CompileOptions ops, String[] scalaSources, Path classes) throws IllegalAccessException, IOException { - String[] pluginArgs = buildPluginArgs(ops.plugins); + List plugins = new ArrayList(Arrays.asList(ops.plugins)); + if (ops.enableSemanticDb) { + plugins.add(ops.semanticDbJar.get()); + } + + String[] pluginArgs = buildPluginArgs(plugins.toArray(new String[0])); String[] pluginParams = getPluginParamsFrom(ops); String[] constParams = { diff --git a/test/semanticdb/A.scala b/test/semanticdb/A.scala new file mode 100644 index 000000000..a869c2849 --- /dev/null +++ b/test/semanticdb/A.scala @@ -0,0 +1 @@ +class A {} diff --git a/test/semanticdb/B.scala b/test/semanticdb/B.scala new file mode 100644 index 000000000..3a43d09b4 --- /dev/null +++ b/test/semanticdb/B.scala @@ -0,0 +1 @@ +class B {} diff --git a/test/semanticdb/BUILD b/test/semanticdb/BUILD new file mode 100644 index 000000000..807a91ec6 --- /dev/null +++ b/test/semanticdb/BUILD @@ -0,0 +1,20 @@ +load("//scala:scala_toolchain.bzl", "scala_toolchain") +load("//scala:scala.bzl", "scala_library") + +scala_toolchain( + name = "semanticdb_toolchain_impl", + enable_semanticdb = True, + visibility = ["//visibility:public"], +) + +toolchain( + name = "semanticdb_toolchain", + toolchain = "semanticdb_toolchain_impl", + toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", + visibility = ["//visibility:public"], +) + +scala_library( + name = "all", + srcs = glob(["**/*.scala"]) +) diff --git a/test/shell/test_semanticdb.sh b/test/shell/test_semanticdb.sh new file mode 100755 index 000000000..077fb4247 --- /dev/null +++ b/test/shell/test_semanticdb.sh @@ -0,0 +1,41 @@ +# shellcheck source=./test_runner.sh + +dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +. "${dir}"/test_runner.sh +. "${dir}"/test_helper.sh +runner=$(get_test_runner "${1:-local}") + +test_produces_semanticdb() { + bazel build \ + --extra_toolchains=//test/semanticdb:semanticdb_toolchain \ + //test/semanticdb/... + + local OUT_DIR="$(bazel info bazel-bin)/test/semanticdb/all.semanticdb" + + if [ ! -d "$OUT_DIR" ]; then + echo "No SemanticDB out directory" + exit 1 + fi + + local SIZE=$(du -s $OUT_DIR | cut -f1) + if (( SIZE < 8 )); then + echo "No SemanticDb files produced" + exit 1 + fi +} + +test_no_semanticdb() { + bazel clean + bazel build \ + //test/semanticdb/... + + local OUT_DIR="$(bazel info bazel-bin)/test/semanticdb/all.semanticdb" + + if [ -d "$OUT_DIR" ]; then + echo "Got SemanticDB out directory, but wasn't expecting it" + exit 1 + fi +} + +$runner test_produces_semanticdb +$runner test_no_semanticdb diff --git a/test_rules_scala.sh b/test_rules_scala.sh index a0254dd9b..c6b8d86dd 100755 --- a/test_rules_scala.sh +++ b/test_rules_scala.sh @@ -54,3 +54,4 @@ $runner bazel build //test_statsfile:SimpleNoStatsFile_statsfile --extra_toolcha . "${test_dir}"/test_unused_dependency.sh . "${test_dir}"/test_twitter_scrooge.sh . "${test_dir}"/test_inherited_environment.sh +# . "${test_dir}"/test_semanticdb.sh From 74b1ab0bf640035258aee67be6cccd44b22b3900 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 29 Jan 2023 07:05:04 +0000 Subject: [PATCH 06/36] fix --- scala/private/common.bzl | 2 +- test_rules_scala.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scala/private/common.bzl b/scala/private/common.bzl index a8626f5f0..d22cf86e0 100644 --- a/scala/private/common.bzl +++ b/scala/private/common.bzl @@ -64,7 +64,7 @@ def collect_plugin_paths(plugins): if hasattr(p, "path"): paths.append(p) elif JavaInfo in p: - paths.extend([j.class_jar.path for j in p[JavaInfo].outputs.jars]) + paths.extend([j.class_jar for j in p[JavaInfo].outputs.jars]) # support http_file pointed at a jar. http_jar uses ijar, # which breaks scala macros diff --git a/test_rules_scala.sh b/test_rules_scala.sh index c6b8d86dd..ec2634b79 100755 --- a/test_rules_scala.sh +++ b/test_rules_scala.sh @@ -54,4 +54,4 @@ $runner bazel build //test_statsfile:SimpleNoStatsFile_statsfile --extra_toolcha . "${test_dir}"/test_unused_dependency.sh . "${test_dir}"/test_twitter_scrooge.sh . "${test_dir}"/test_inherited_environment.sh -# . "${test_dir}"/test_semanticdb.sh +. "${test_dir}"/test_semanticdb.sh From 72173bef549567cca6314fa735dbe167a8e2ef1f Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 29 Jan 2023 23:43:44 +0000 Subject: [PATCH 07/36] Add Scalac3 semanticdb options --- src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java b/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java index 370be2904..d1d94b1c7 100644 --- a/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java +++ b/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java @@ -239,6 +239,11 @@ private static String[] getPluginParamsFrom(CompileOptions ops) { } } + if (ops.enableSemanticDb) { + pluginParams.add("-Xsemanticdb") + pluginParams.add("-semanticdb-target:" + ops.semanticDbTarget.get()) + } + return pluginParams.toArray(new String[pluginParams.size()]); } From 2cef51f1c48a9b457d0d0ac83d81058160f3e51c Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Mon, 30 Jan 2023 00:49:26 +0000 Subject: [PATCH 08/36] Fix scala3 failures --- scala/private/common_attributes.bzl | 18 +++++++++++------ scala/private/macros/scala_repositories.bzl | 2 +- .../private/macros/setup_scala_toolchain.bzl | 20 +++++++++++-------- .../rulesscala/scalac/ScalacWorker3.java | 4 ++-- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/scala/private/common_attributes.bzl b/scala/private/common_attributes.bzl index ad331a24f..2208bd299 100644 --- a/scala/private/common_attributes.bzl +++ b/scala/private/common_attributes.bzl @@ -8,6 +8,7 @@ load( "@io_bazel_rules_scala//scala:plusone.bzl", _collect_plus_one_deps_aspect = "collect_plus_one_deps_aspect", ) +load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") common_attrs_for_plugin_bootstrapping = { "srcs": attr.label_list(allow_files = [ @@ -54,12 +55,7 @@ common_attrs = {} common_attrs.update(common_attrs_for_plugin_bootstrapping) -common_attrs.update({ - "_dependency_analyzer_plugin": attr.label( - default = Label( - "@io_bazel_rules_scala//third_party/dependency_analyzer/src/main:dependency_analyzer", - ), allow_files = [".jar"], mandatory = False, - ), +semanticdb_attrs = { "_semanticdb_scalac_plugin": attr.label( default = Label( "@io_bazel_rules_scala//scala/private/toolchain_deps:semanticdb_scalac", @@ -67,6 +63,16 @@ common_attrs.update({ providers = [[JavaInfo]], mandatory = False, ), +} if SCALA_MAJOR_VERSION.startswith("2") else {} + +common_attrs.update(semanticdb_attrs) + +common_attrs.update({ + "_dependency_analyzer_plugin": attr.label( + default = Label( + "@io_bazel_rules_scala//third_party/dependency_analyzer/src/main:dependency_analyzer", + ), allow_files = [".jar"], mandatory = False, + ), "unused_dependency_checker_mode": attr.string( values = [ "warn", diff --git a/scala/private/macros/scala_repositories.bzl b/scala/private/macros/scala_repositories.bzl index b5cd6e226..deb361bc7 100644 --- a/scala/private/macros/scala_repositories.bzl +++ b/scala/private/macros/scala_repositories.bzl @@ -48,6 +48,7 @@ ARTIFACT_IDS = [ "io_bazel_rules_scala_scala_reflect", "io_bazel_rules_scala_scala_xml", "io_bazel_rules_scala_scala_parser_combinators", + "org_scalameta_semanticdb_scalac", ] if SCALA_MAJOR_VERSION.startswith("2") else [ "io_bazel_rules_scala_scala_library", "io_bazel_rules_scala_scala_compiler", @@ -57,7 +58,6 @@ ARTIFACT_IDS = [ "io_bazel_rules_scala_scala_xml", "io_bazel_rules_scala_scala_parser_combinators", "io_bazel_rules_scala_scala_library_2", - "org_scalameta_semanticdb_scalac", ] def rules_scala_toolchain_deps_repositories( diff --git a/scala/private/macros/setup_scala_toolchain.bzl b/scala/private/macros/setup_scala_toolchain.bzl index 1036a0448..c4516cbcd 100644 --- a/scala/private/macros/setup_scala_toolchain.bzl +++ b/scala/private/macros/setup_scala_toolchain.bzl @@ -1,5 +1,6 @@ load("//scala:scala_toolchain.bzl", "scala_toolchain") load("//scala:providers.bzl", "declare_deps_provider") +load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") def setup_scala_toolchain( name, @@ -66,16 +67,19 @@ def setup_scala_toolchain( deps = ["@org_scalameta_semanticdb_scalac"], ) + dep_providers = [ + scala_xml_provider, + parser_combinators_provider, + scala_compile_classpath_provider, + scala_library_classpath_provider, + scala_macro_classpath_provider + ] + if SCALA_MAJOR_VERSION.startswith("2"): + dep_providers.append(semanticdb_scalac_provider) + scala_toolchain( name = "%s_impl" % name, - dep_providers = [ - semanticdb_scalac_provider, - scala_xml_provider, - parser_combinators_provider, - scala_compile_classpath_provider, - scala_library_classpath_provider, - scala_macro_classpath_provider, - ], + dep_providers = dep_providers, visibility = visibility, **kwargs ) diff --git a/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java b/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java index d1d94b1c7..c296b542b 100644 --- a/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java +++ b/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java @@ -240,8 +240,8 @@ private static String[] getPluginParamsFrom(CompileOptions ops) { } if (ops.enableSemanticDb) { - pluginParams.add("-Xsemanticdb") - pluginParams.add("-semanticdb-target:" + ops.semanticDbTarget.get()) + pluginParams.add("-Xsemanticdb"); + pluginParams.add("-semanticdb-target:" + ops.semanticDbTarget.get()); } return pluginParams.toArray(new String[pluginParams.size()]); From 6f32c73e722de07c4cd063a97dbaa7f74772fe32 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Mon, 30 Jan 2023 00:52:54 +0000 Subject: [PATCH 09/36] fix formating --- WORKSPACE | 2 +- scala/BUILD | 2 +- scala/private/common_attributes.bzl | 4 +++- scala/private/macros/setup_scala_toolchain.bzl | 5 ++--- scala/private/rule_impls.bzl | 7 +++---- scala/semanticdb/semanticdb_repositories.bzl | 1 - test/semanticdb/BUILD | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 1b9268a8f..11177cdf5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -25,6 +25,7 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config") scala_config() load("//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") + semanticdb_repositories() load("//scala:scala.bzl", "rules_scala_setup", "rules_scala_toolchain_deps_repositories") @@ -71,7 +72,6 @@ scalafmt_default_config() scalafmt_repositories() - MAVEN_SERVER_URLS = default_maven_server_urls() # needed for the cross repo proto test diff --git a/scala/BUILD b/scala/BUILD index 064f653d5..2a1563f52 100644 --- a/scala/BUILD +++ b/scala/BUILD @@ -113,4 +113,4 @@ declare_deps_provider( deps_id = "semanticdb_scalac", visibility = ["//visibility:public"], deps = ["@org_scalameta_semanticdb_scalac"], -) \ No newline at end of file +) diff --git a/scala/private/common_attributes.bzl b/scala/private/common_attributes.bzl index 2208bd299..3487562b8 100644 --- a/scala/private/common_attributes.bzl +++ b/scala/private/common_attributes.bzl @@ -71,7 +71,9 @@ common_attrs.update({ "_dependency_analyzer_plugin": attr.label( default = Label( "@io_bazel_rules_scala//third_party/dependency_analyzer/src/main:dependency_analyzer", - ), allow_files = [".jar"], mandatory = False, + ), + allow_files = [".jar"], + mandatory = False, ), "unused_dependency_checker_mode": attr.string( values = [ diff --git a/scala/private/macros/setup_scala_toolchain.bzl b/scala/private/macros/setup_scala_toolchain.bzl index c4516cbcd..ed226a954 100644 --- a/scala/private/macros/setup_scala_toolchain.bzl +++ b/scala/private/macros/setup_scala_toolchain.bzl @@ -59,7 +59,6 @@ def setup_scala_toolchain( else: parser_combinators_provider = "@io_bazel_rules_scala//scala:parser_combinators_provider" - declare_deps_provider( name = semanticdb_scalac_provider, deps_id = "semanticdb_scalac", @@ -72,8 +71,8 @@ def setup_scala_toolchain( parser_combinators_provider, scala_compile_classpath_provider, scala_library_classpath_provider, - scala_macro_classpath_provider - ] + scala_macro_classpath_provider, + ] if SCALA_MAJOR_VERSION.startswith("2"): dep_providers.append(semanticdb_scalac_provider) diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index 4088dd5f9..98b0e10bd 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -56,7 +56,6 @@ def compile_scala( dependency_info, unused_dependency_checker_ignored_targets, stamp_target_label = None): - outs = [output, statsfile, diagnosticsfile] # look for any plugins: @@ -74,7 +73,7 @@ def compile_scala( enable_diagnostics_report = toolchain.enable_diagnostics_report enable_semanticdb = toolchain.enable_semanticdb - semanticdb_dir = "{}.semanticdb".format(ctx.label.name) + semanticdb_dir = "{}.semanticdb".format(ctx.label.name) if enable_semanticdb and hasattr(ctx.attr, "_semanticdb_scalac_plugin"): semanticdb_out = ctx.actions.declare_directory(semanticdb_dir) @@ -107,11 +106,11 @@ def compile_scala( args.add_all("--SourceJars", all_srcjars) args.add("--EnableSemanticDb", enable_semanticdb) - + if enable_semanticdb and hasattr(ctx.attr, "_semanticdb_scalac_plugin"): target = "{}/{}/{}".format(ctx.bin_dir.path, ctx.label.package, semanticdb_dir) # jar = ",".join(ctx.attr._semanticdb_scalac_plugin.files.to_list()) - + jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] args.add("--SemanticDbTarget", target) diff --git a/scala/semanticdb/semanticdb_repositories.bzl b/scala/semanticdb/semanticdb_repositories.bzl index 37924441d..bfe1141c7 100644 --- a/scala/semanticdb/semanticdb_repositories.bzl +++ b/scala/semanticdb/semanticdb_repositories.bzl @@ -4,7 +4,6 @@ load( ) load("//third_party/repositories:repositories.bzl", "repositories") - def semanticdb_repositories( maven_servers = _default_maven_server_urls(), overriden_artifacts = {}): diff --git a/test/semanticdb/BUILD b/test/semanticdb/BUILD index 807a91ec6..f3b51b7f8 100644 --- a/test/semanticdb/BUILD +++ b/test/semanticdb/BUILD @@ -16,5 +16,5 @@ toolchain( scala_library( name = "all", - srcs = glob(["**/*.scala"]) + srcs = glob(["**/*.scala"]), ) From e010a812cb4155e570d13961cfae3a3d9353cebb Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Tue, 31 Jan 2023 02:11:57 +0000 Subject: [PATCH 10/36] fix scala3 support; add scala3 test --- examples/testing/semanticdb_scala3/BUILD | 26 ++++++++++++ examples/testing/semanticdb_scala3/Foo.scala | 3 ++ examples/testing/semanticdb_scala3/Main.scala | 4 ++ examples/testing/semanticdb_scala3/WORKSPACE | 41 +++++++++++++++++++ scala/private/rule_impls.bzl | 13 +++--- scala/scala_toolchain.bzl | 22 ++++++---- test/shell/test_examples.sh | 21 ++++++++++ test/shell/test_semanticdb.sh | 22 +++++++++- 8 files changed, 136 insertions(+), 16 deletions(-) create mode 100644 examples/testing/semanticdb_scala3/BUILD create mode 100644 examples/testing/semanticdb_scala3/Foo.scala create mode 100644 examples/testing/semanticdb_scala3/Main.scala create mode 100644 examples/testing/semanticdb_scala3/WORKSPACE diff --git a/examples/testing/semanticdb_scala3/BUILD b/examples/testing/semanticdb_scala3/BUILD new file mode 100644 index 000000000..e89ceb35b --- /dev/null +++ b/examples/testing/semanticdb_scala3/BUILD @@ -0,0 +1,26 @@ +load("@io_bazel_rules_scala//scala:scala_toolchain.bzl", "scala_toolchain") +load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary", "scala_library") + +scala_toolchain( + name = "semanticdb_toolchain_impl", + enable_semanticdb = True, + visibility = ["//visibility:public"], +) + +toolchain( + name = "semanticdb_toolchain", + toolchain = "semanticdb_toolchain_impl", + toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", + visibility = ["//visibility:public"], +) + +scala_library( + name = "all", + srcs = glob(["**/*.scala"]), +) + +scala_binary( + name = "run", + main_class = "main", + deps = [":all"], +) diff --git a/examples/testing/semanticdb_scala3/Foo.scala b/examples/testing/semanticdb_scala3/Foo.scala new file mode 100644 index 000000000..d82710638 --- /dev/null +++ b/examples/testing/semanticdb_scala3/Foo.scala @@ -0,0 +1,3 @@ +class Foo: + def sayHello: String = "Hello Scala 3 !!" + diff --git a/examples/testing/semanticdb_scala3/Main.scala b/examples/testing/semanticdb_scala3/Main.scala new file mode 100644 index 000000000..c1af540be --- /dev/null +++ b/examples/testing/semanticdb_scala3/Main.scala @@ -0,0 +1,4 @@ + +@main def main: Unit = + val foo = new Foo() + println(foo.sayHello) \ No newline at end of file diff --git a/examples/testing/semanticdb_scala3/WORKSPACE b/examples/testing/semanticdb_scala3/WORKSPACE new file mode 100644 index 000000000..6ccd1cf5c --- /dev/null +++ b/examples/testing/semanticdb_scala3/WORKSPACE @@ -0,0 +1,41 @@ +workspace(name = "specs2_junit_repositories") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +skylib_version = "1.0.3" + +http_archive( + name = "bazel_skylib", + sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", + type = "tar.gz", + url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version), +) + +local_repository( + name = "io_bazel_rules_scala", + path = "../../..", +) + +load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config") + +scala_config(scala_version = "3.1.0") + +load( + "@io_bazel_rules_scala//scala:scala.bzl", + "rules_scala_setup", + "rules_scala_toolchain_deps_repositories", +) + +rules_scala_setup() + +rules_scala_toolchain_deps_repositories(fetch_sources = True) + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") + +rules_proto_dependencies() + +rules_proto_toolchains() + +load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains") + +scala_register_toolchains() diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index 98b0e10bd..3c84908af 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -75,7 +75,7 @@ def compile_scala( enable_semanticdb = toolchain.enable_semanticdb semanticdb_dir = "{}.semanticdb".format(ctx.label.name) - if enable_semanticdb and hasattr(ctx.attr, "_semanticdb_scalac_plugin"): + if enable_semanticdb: semanticdb_out = ctx.actions.declare_directory(semanticdb_dir) outs.append(semanticdb_out) @@ -107,14 +107,13 @@ def compile_scala( args.add("--EnableSemanticDb", enable_semanticdb) - if enable_semanticdb and hasattr(ctx.attr, "_semanticdb_scalac_plugin"): + if enable_semanticdb: target = "{}/{}/{}".format(ctx.bin_dir.path, ctx.label.package, semanticdb_dir) - # jar = ",".join(ctx.attr._semanticdb_scalac_plugin.files.to_list()) - - jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] - args.add("--SemanticDbTarget", target) - args.add("--SemanticDbJar", jar) + + if hasattr(ctx.attr, "_semanticdb_scalac_plugin"): + jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] + args.add("--SemanticDbJar", jar) if dependency_info.need_direct_info: if dependency_info.need_direct_jars: diff --git a/scala/scala_toolchain.bzl b/scala/scala_toolchain.bzl index 429f4fa49..a28b00107 100644 --- a/scala/scala_toolchain.bzl +++ b/scala/scala_toolchain.bzl @@ -2,6 +2,7 @@ load( "@io_bazel_rules_scala//scala:providers.bzl", _DepsInfo = "DepsInfo", ) +load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") def _compute_strict_deps_mode(input_strict_deps_mode, dependency_mode): if dependency_mode == "direct": @@ -90,19 +91,24 @@ def _scala_toolchain_impl(ctx): ) return [toolchain] +def _default_dep_providers(): + dep_providers = [ + "@io_bazel_rules_scala//scala:scala_xml_provider", + "@io_bazel_rules_scala//scala:parser_combinators_provider", + "@io_bazel_rules_scala//scala:scala_compile_classpath_provider", + "@io_bazel_rules_scala//scala:scala_library_classpath_provider", + "@io_bazel_rules_scala//scala:scala_macro_classpath_provider", + ] + if SCALA_MAJOR_VERSION.startswith("2"): + dep_providers.append("@io_bazel_rules_scala//scala:semanticdb_scalac_provider") + return dep_providers + scala_toolchain = rule( _scala_toolchain_impl, attrs = { "scalacopts": attr.string_list(), "dep_providers": attr.label_list( - default = [ - "@io_bazel_rules_scala//scala:semanticdb_scalac_provider", - "@io_bazel_rules_scala//scala:scala_xml_provider", - "@io_bazel_rules_scala//scala:parser_combinators_provider", - "@io_bazel_rules_scala//scala:scala_compile_classpath_provider", - "@io_bazel_rules_scala//scala:scala_library_classpath_provider", - "@io_bazel_rules_scala//scala:scala_macro_classpath_provider", - ], + default = _default_dep_providers(), providers = [_DepsInfo], ), "dependency_mode": attr.string( diff --git a/test/shell/test_examples.sh b/test/shell/test_examples.sh index c38f7d4cf..f47cb7e48 100755 --- a/test/shell/test_examples.sh +++ b/test/shell/test_examples.sh @@ -20,7 +20,28 @@ function scala3_example() { (cd examples/scala3; bazel build //...) } +function test_produces_semanticdb_scala3() { + # NB: In subshell, so CD doesn't change local CWD + ( + cd examples/testing/semanticdb_scala3 + bazel run --extra_toolchains=//:semanticdb_toolchain //:run + + local OUT_DIR="$(bazel info bazel-bin)/all.semanticdb" + if [ ! -d "$OUT_DIR" ]; then + echo "No SemanticDB out directory" + exit 1 + fi + + local SIZE=$(du -s $OUT_DIR | cut -f1) + if (( SIZE < 8 )); then + echo "No SemanticDb files produced" + exit 1 + fi + ) +} + $runner scalatest_repositories_example $runner specs2_junit_repositories_example $runner multi_framework_toolchain_example $runner scala3_example +$runner test_produces_semanticdb_scala3 diff --git a/test/shell/test_semanticdb.sh b/test/shell/test_semanticdb.sh index 077fb4247..20fdbbd3c 100755 --- a/test/shell/test_semanticdb.sh +++ b/test/shell/test_semanticdb.sh @@ -37,5 +37,25 @@ test_no_semanticdb() { fi } +test_produces_semanticdb_scala3() { + # NB: In subshell, so CD doesn't change local CWD + ( + cd test/semanticdb/scala3 + bazel run --extra_toolchains=//:semanticdb_toolchain //:run + + local OUT_DIR="$(bazel info bazel-bin)/all.semanticdb" + if [ ! -d "$OUT_DIR" ]; then + echo "No SemanticDB out directory" + exit 1 + fi + + local SIZE=$(du -s $OUT_DIR | cut -f1) + if (( SIZE < 8 )); then + echo "No SemanticDb files produced" + exit 1 + fi + ) +} + $runner test_produces_semanticdb -$runner test_no_semanticdb +$runner test_no_semanticdb \ No newline at end of file From 779e5fa4f9add7a5dd3abea4f67371b43c7402f5 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Tue, 31 Jan 2023 02:46:12 +0000 Subject: [PATCH 11/36] clean up dead code --- test/shell/test_examples.sh | 2 +- test/shell/test_semanticdb.sh | 20 -------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/test/shell/test_examples.sh b/test/shell/test_examples.sh index f47cb7e48..f37810e35 100755 --- a/test/shell/test_examples.sh +++ b/test/shell/test_examples.sh @@ -21,7 +21,7 @@ function scala3_example() { } function test_produces_semanticdb_scala3() { - # NB: In subshell, so CD doesn't change local CWD + # NB: In subshell, so "cd" doesn't change local CWD ( cd examples/testing/semanticdb_scala3 bazel run --extra_toolchains=//:semanticdb_toolchain //:run diff --git a/test/shell/test_semanticdb.sh b/test/shell/test_semanticdb.sh index 20fdbbd3c..77798f76c 100755 --- a/test/shell/test_semanticdb.sh +++ b/test/shell/test_semanticdb.sh @@ -37,25 +37,5 @@ test_no_semanticdb() { fi } -test_produces_semanticdb_scala3() { - # NB: In subshell, so CD doesn't change local CWD - ( - cd test/semanticdb/scala3 - bazel run --extra_toolchains=//:semanticdb_toolchain //:run - - local OUT_DIR="$(bazel info bazel-bin)/all.semanticdb" - if [ ! -d "$OUT_DIR" ]; then - echo "No SemanticDB out directory" - exit 1 - fi - - local SIZE=$(du -s $OUT_DIR | cut -f1) - if (( SIZE < 8 )); then - echo "No SemanticDb files produced" - exit 1 - fi - ) -} - $runner test_produces_semanticdb $runner test_no_semanticdb \ No newline at end of file From 110442d8d00d168d9f39e2672fe181b6833121ee Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Tue, 31 Jan 2023 20:18:08 +0000 Subject: [PATCH 12/36] bump, to retrigger PR checks --- examples/testing/semanticdb_scala3/Foo.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/testing/semanticdb_scala3/Foo.scala b/examples/testing/semanticdb_scala3/Foo.scala index d82710638..e246581ab 100644 --- a/examples/testing/semanticdb_scala3/Foo.scala +++ b/examples/testing/semanticdb_scala3/Foo.scala @@ -1,3 +1,3 @@ class Foo: - def sayHello: String = "Hello Scala 3 !!" + def sayHello: String = "Hello from Scala 3!!" From 8fcbbc9afb04991a713f931ced843f01095a433e Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 20:33:17 +0000 Subject: [PATCH 13/36] bump scalameta; refactor version string --- third_party/repositories/scala_2_11.bzl | 53 +++++++++++++------------ third_party/repositories/scala_2_12.bzl | 45 +++++++++++---------- third_party/repositories/scala_2_13.bzl | 45 +++++++++++---------- 3 files changed, 73 insertions(+), 70 deletions(-) diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 947568f0b..be11fb679 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -1,4 +1,5 @@ scala_version = "2.11.12" +scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library": { @@ -69,18 +70,6 @@ artifacts = { "artifact": "org.scala-lang.modules:scala-parser-combinators_2.11:1.1.2", "sha256": "3e0889e95f5324da6420461f7147cb508241ed957ac5cfedc25eef19c5448f26", }, - "org_scalameta_common": { - "artifact": "org.scalameta:common_2.11:4.3.0", - "sha256": "6330798bcbd78d14d371202749f32efda0465c3be5fd057a6055a67e21335ba0", - "deps": [ - "@com_lihaoyi_sourcecode", - "@io_bazel_rules_scala_scala_library", - ], - }, - "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.11.12:4.7.3", - "sha256": "0db52fc6639f73b15c3fb9fc1cb441704399f0d8dee8352ca1cf359630e7ca0f", - }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.11:1.0.1", "sha256": "49ecc30a4b47efc0038099da0c97515cf8f754ea631ea9f9935b36ca7d41b733", @@ -105,28 +94,28 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, - "org_scalameta_parsers": { - "artifact": "org.scalameta:parsers_2.11:4.3.0", - "sha256": "724382abfac27b32dec6c21210562bc7e1b09b5268ccb704abe66dcc8844beeb", + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_{}:{}".format(scala_version, scalameta_version), + "sha256": "0db52fc6639f73b15c3fb9fc1cb441704399f0d8dee8352ca1cf359630e7ca0f", + }, + "org_scalameta_common": { + "artifact": "org.scalameta:common_2.11:{}".format(scalameta_version), + "sha256": "6330798bcbd78d14d371202749f32efda0465c3be5fd057a6055a67e21335ba0", "deps": [ + "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", - "@org_scalameta_trees", ], }, - "org_scalameta_scalafmt_core": { - "artifact": "org.scalameta:scalafmt-core_2.11:2.3.2", - "sha256": "6bf391e0e1d7369fda83ddaf7be4d267bf4cbccdf2cc31ff941999a78c30e67f", + "org_scalameta_parsers": { + "artifact": "org.scalameta:parsers_2.11:{}".format(scalameta_version), + "sha256": "724382abfac27b32dec6c21210562bc7e1b09b5268ccb704abe66dcc8844beeb", "deps": [ - "@com_geirsson_metaconfig_core", - "@com_geirsson_metaconfig_typesafe_config", "@io_bazel_rules_scala_scala_library", - "@io_bazel_rules_scala_scala_reflect", - "@org_scalameta_scalameta", - "@org_scala_lang_modules_scala_collection_compat", + "@org_scalameta_trees", ], }, "org_scalameta_scalameta": { - "artifact": "org.scalameta:scalameta_2.11:4.3.0", + "artifact": "org.scalameta:scalameta_2.11:{}".format(scalameta_version), "sha256": "94fe739295447cd3ae877c279ccde1def06baea02d9c76a504dda23de1d90516", "deps": [ "@io_bazel_rules_scala_scala_library", @@ -135,7 +124,7 @@ artifacts = { ], }, "org_scalameta_trees": { - "artifact": "org.scalameta:trees_2.11:4.3.0", + "artifact": "org.scalameta:trees_2.11:{}".format(scalameta_version), "sha256": "d24d5d63d8deafe646d455c822593a66adc6fdf17c8373754a3834a6e92a8a72", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", @@ -144,6 +133,18 @@ artifacts = { "@org_scalameta_fastparse", ], }, + "org_scalameta_scalafmt_core": { + "artifact": "org.scalameta:scalafmt-core_2.11:2.3.2", + "sha256": "6bf391e0e1d7369fda83ddaf7be4d267bf4cbccdf2cc31ff941999a78c30e67f", + "deps": [ + "@com_geirsson_metaconfig_core", + "@com_geirsson_metaconfig_typesafe_config", + "@io_bazel_rules_scala_scala_library", + "@io_bazel_rules_scala_scala_reflect", + "@org_scalameta_scalameta", + "@org_scala_lang_modules_scala_collection_compat", + ], + }, "org_typelevel_paiges_core": { "artifact": "org.typelevel:paiges-core_2.11:0.2.4", "sha256": "aa66fbe0457ca5cb5b9e522d4cb873623bb376a2e1ff58c464b5194c1d87c241", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index 9cec6dc8d..08a974b80 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -1,4 +1,5 @@ scala_version = "2.12.14" +scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library": { @@ -69,18 +70,6 @@ artifacts = { "artifact": "org.scala-lang.modules:scala-parser-combinators_2.12:1.1.2", "sha256": "24985eb43e295a9dd77905ada307a850ca25acf819cdb579c093fc6987b0dbc2", }, - "org_scalameta_common": { - "artifact": "org.scalameta:common_2.12:4.3.0", - "sha256": "3bdb2ff71d3e86f94b4d31d2c40442f533655860749a92fd17e1f29b8deb8baa", - "deps": [ - "@com_lihaoyi_sourcecode", - "@io_bazel_rules_scala_scala_library", - ], - }, - "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.12.14:4.7.3", - "sha256": "e5e31e1b48aedd3c7c2c2731d5053fd3429a3b37f076d95e8214acfa551c226a", - }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.12:1.0.1", "sha256": "387ced762e93915c5f87fed59d8453e404273f49f812d413405696ce20273aa5", @@ -105,14 +94,6 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, - "org_scalameta_parsers": { - "artifact": "org.scalameta:parsers_2.12:4.3.0", - "sha256": "d9f87d03b6b5e942f263db6dab75937493bfcb0fe7cfe2cda6567bf30f23ff3a", - "deps": [ - "@io_bazel_rules_scala_scala_library", - "@org_scalameta_trees", - ], - }, "org_scalameta_scalafmt_core": { "artifact": "org.scalameta:scalafmt-core_2.12:2.3.2", "sha256": "4788e2045e99f4624162d3182016a05032a7ab1324c4a28af433aa070f916773", @@ -125,8 +106,28 @@ artifacts = { "@org_scala_lang_modules_scala_collection_compat", ], }, + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_{}:{}".format(scala_version, scalameta_version), + "sha256": "e5e31e1b48aedd3c7c2c2731d5053fd3429a3b37f076d95e8214acfa551c226a", + }, + "org_scalameta_common": { + "artifact": "org.scalameta:common_2.12:{}".format(scalameta_version), + "sha256": "3bdb2ff71d3e86f94b4d31d2c40442f533655860749a92fd17e1f29b8deb8baa", + "deps": [ + "@com_lihaoyi_sourcecode", + "@io_bazel_rules_scala_scala_library", + ], + }, + "org_scalameta_parsers": { + "artifact": "org.scalameta:parsers_2.12:{}".format(scalameta_version), + "sha256": "d9f87d03b6b5e942f263db6dab75937493bfcb0fe7cfe2cda6567bf30f23ff3a", + "deps": [ + "@io_bazel_rules_scala_scala_library", + "@org_scalameta_trees", + ], + }, "org_scalameta_scalameta": { - "artifact": "org.scalameta:scalameta_2.12:4.3.0", + "artifact": "org.scalameta:scalameta_2.12:{}".format(scalameta_version), "sha256": "4d9487b434cbe9d89033824a4fc902dc7c782eea94961e8575df91ae96b10d6a", "deps": [ "@io_bazel_rules_scala_scala_library", @@ -135,7 +136,7 @@ artifacts = { ], }, "org_scalameta_trees": { - "artifact": "org.scalameta:trees_2.12:4.3.0", + "artifact": "org.scalameta:trees_2.12:{}".format(scalameta_version), "sha256": "020b53681dd8e148d74ffa282276994bcb0f06c3425fb9a4bb9f8d161e22187a", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index a11f02b81..ac7638767 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -1,4 +1,5 @@ scala_version = "2.13.6" +scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library": { @@ -73,18 +74,6 @@ artifacts = { "artifact": "org.scala-lang.modules:scala-parser-combinators_2.13:1.1.2", "sha256": "5c285b72e6dc0a98e99ae0a1ceeb4027dab9adfa441844046bd3f19e0efdcb54", }, - "org_scalameta_common": { - "artifact": "org.scalameta:common_2.13:4.3.24", - "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", - "deps": [ - "@com_lihaoyi_sourcecode", - "@io_bazel_rules_scala_scala_library", - ], - }, - "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.13.6:4.7.3", - "sha256": "fbc7703b3ac407a4695d6055197cf9ea520260e0757dec488992b498a86ed656", - }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.13:1.0.1", "sha256": "b43b99244d5b51948daf1467083b3850dc2727c604de98dc426dec14244fd18e", @@ -109,14 +98,6 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, - "org_scalameta_parsers": { - "artifact": "org.scalameta:parsers_2.13:4.3.24", - "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", - "deps": [ - "@io_bazel_rules_scala_scala_library", - "@org_scalameta_trees", - ], - }, "org_scalameta_scalafmt_core": { "artifact": "org.scalameta:scalafmt-core_2.13:2.7.4", "sha256": "873d98275f75b67c1e01094a24bafb29a588b7d05fdc508d3b1ba02f08d0c0d8", @@ -130,8 +111,28 @@ artifacts = { "@io_bazel_rules_scala_scala_parallel_collections", ], }, + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_{}:{}".format(scala_version, scalameta_version), + "sha256": "fbc7703b3ac407a4695d6055197cf9ea520260e0757dec488992b498a86ed656", + }, + "org_scalameta_common": { + "artifact": "org.scalameta:common_2.13:{}".format(scalameta_version), + "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", + "deps": [ + "@com_lihaoyi_sourcecode", + "@io_bazel_rules_scala_scala_library", + ], + }, + "org_scalameta_parsers": { + "artifact": "org.scalameta:parsers_2.13:{}".format(scalameta_version), + "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", + "deps": [ + "@io_bazel_rules_scala_scala_library", + "@org_scalameta_trees", + ], + }, "org_scalameta_scalameta": { - "artifact": "org.scalameta:scalameta_2.13:4.3.24", + "artifact": "org.scalameta:scalameta_2.13:{}".format(scalameta_version), "sha256": "d73eaf491eb588a2bd78aeba443e62bc95f1a368051d9e81607192c88fa4c61c", "deps": [ "@io_bazel_rules_scala_scala_library", @@ -140,7 +141,7 @@ artifacts = { ], }, "org_scalameta_trees": { - "artifact": "org.scalameta:trees_2.13:4.3.24", + "artifact": "org.scalameta:trees_2.13:{}".format(scalameta_version), "sha256": "d49d2b085ae62e9317dd2a4e8b14be5b1ecbec2db392fa81cab86ad2bd7c2c68", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", From 166c1f0e805043af11c07fb2315746d5af9f0664 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 20:37:41 +0000 Subject: [PATCH 14/36] more scala 3.1, refactor version string --- third_party/repositories/scala_3_1.bzl | 37 +++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index 49d17e9d6..4a319bf4f 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -1,4 +1,5 @@ scala_version = "3.1.0" +scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library_2": { @@ -91,14 +92,6 @@ artifacts = { "artifact": "org.scala-lang.modules:scala-parser-combinators_2.13:1.1.2", "sha256": "5c285b72e6dc0a98e99ae0a1ceeb4027dab9adfa441844046bd3f19e0efdcb54", }, - "org_scalameta_common": { - "artifact": "org.scalameta:common_2.13:4.3.24", - "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", - "deps": [ - "@com_lihaoyi_sourcecode", - "@io_bazel_rules_scala_scala_library", - ], - }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.13:1.0.1", "sha256": "b43b99244d5b51948daf1467083b3850dc2727c604de98dc426dec14244fd18e", @@ -123,14 +116,6 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, - "org_scalameta_parsers": { - "artifact": "org.scalameta:parsers_2.13:4.3.24", - "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", - "deps": [ - "@io_bazel_rules_scala_scala_library", - "@org_scalameta_trees", - ], - }, "org_scalameta_scalafmt_core": { "artifact": "org.scalameta:scalafmt-core_2.13:2.7.4", "sha256": "873d98275f75b67c1e01094a24bafb29a588b7d05fdc508d3b1ba02f08d0c0d8", @@ -142,8 +127,24 @@ artifacts = { "@io_bazel_rules_scala_scala_parallel_collections", ], }, + "org_scalameta_common": { + "artifact": "org.scalameta:common_2.13:{}".format(scalameta_version), + "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", + "deps": [ + "@com_lihaoyi_sourcecode", + "@io_bazel_rules_scala_scala_library", + ], + }, + "org_scalameta_parsers": { + "artifact": "org.scalameta:parsers_2.13:{}".format(scalameta_version), + "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", + "deps": [ + "@io_bazel_rules_scala_scala_library", + "@org_scalameta_trees", + ], + }, "org_scalameta_scalameta": { - "artifact": "org.scalameta:scalameta_2.13:4.3.24", + "artifact": "org.scalameta:scalameta_2.13:{}".format(scalameta_version), "sha256": "d73eaf491eb588a2bd78aeba443e62bc95f1a368051d9e81607192c88fa4c61c", "deps": [ "@io_bazel_rules_scala_scala_library", @@ -152,7 +153,7 @@ artifacts = { ], }, "org_scalameta_trees": { - "artifact": "org.scalameta:trees_2.13:4.3.24", + "artifact": "org.scalameta:trees_2.13:{}".format(scalameta_version), "sha256": "d49d2b085ae62e9317dd2a4e8b14be5b1ecbec2db392fa81cab86ad2bd7c2c68", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", From 993aa30d32552146b4636cf579ec7f91252e045d Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:12:46 +0000 Subject: [PATCH 15/36] update hashes --- third_party/repositories/scala_2_11.bzl | 8 ++++---- third_party/repositories/scala_2_12.bzl | 8 ++++---- third_party/repositories/scala_2_13.bzl | 8 ++++---- third_party/repositories/scala_3_1.bzl | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 98cb38e9e..5c233cb5c 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -100,7 +100,7 @@ artifacts = { }, "org_scalameta_common": { "artifact": "org.scalameta:common_2.11:{}".format(scalameta_version), - "sha256": "6330798bcbd78d14d371202749f32efda0465c3be5fd057a6055a67e21335ba0", + "sha256": "f0cd72562ec19d41f878f9c01338870c5311c8929a2238823ba3e04bce504acf", "deps": [ "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", @@ -108,7 +108,7 @@ artifacts = { }, "org_scalameta_parsers": { "artifact": "org.scalameta:parsers_2.11:{}".format(scalameta_version), - "sha256": "724382abfac27b32dec6c21210562bc7e1b09b5268ccb704abe66dcc8844beeb", + "sha256": "bc9868b54a8b8be90068513f13ae74d1c9bf70606f71b17e99018fab4c107d1a", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scalameta_trees", @@ -116,7 +116,7 @@ artifacts = { }, "org_scalameta_scalameta": { "artifact": "org.scalameta:scalameta_2.11:{}".format(scalameta_version), - "sha256": "94fe739295447cd3ae877c279ccde1def06baea02d9c76a504dda23de1d90516", + "sha256": "51534025b55c62c6334e131fdda83604e1bd42e36abde288b154539cf0ea2b18", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scala_lang_scalap", @@ -125,7 +125,7 @@ artifacts = { }, "org_scalameta_trees": { "artifact": "org.scalameta:trees_2.11:{}".format(scalameta_version), - "sha256": "d24d5d63d8deafe646d455c822593a66adc6fdf17c8373754a3834a6e92a8a72", + "sha256": "a97cffd0cf8d057d67630c7ee4adaaf75b8915efdd7448e5bc9d0c8e19176047", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", "@io_bazel_rules_scala_scala_library", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index 25e9b1898..96017eda3 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -112,7 +112,7 @@ artifacts = { }, "org_scalameta_common": { "artifact": "org.scalameta:common_2.12:{}".format(scalameta_version), - "sha256": "3bdb2ff71d3e86f94b4d31d2c40442f533655860749a92fd17e1f29b8deb8baa", + "sha256": "ee629e79071f422d097fc0656311d859cf8b42e8c3aae243d147c38da6f99e61", "deps": [ "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", @@ -120,7 +120,7 @@ artifacts = { }, "org_scalameta_parsers": { "artifact": "org.scalameta:parsers_2.12:{}".format(scalameta_version), - "sha256": "d9f87d03b6b5e942f263db6dab75937493bfcb0fe7cfe2cda6567bf30f23ff3a", + "sha256": "f597802f7162da06a90fa1d16469b39cff61a25d71274d90c1e38274afd75ae6", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scalameta_trees", @@ -128,7 +128,7 @@ artifacts = { }, "org_scalameta_scalameta": { "artifact": "org.scalameta:scalameta_2.12:{}".format(scalameta_version), - "sha256": "4d9487b434cbe9d89033824a4fc902dc7c782eea94961e8575df91ae96b10d6a", + "sha256": "1a92a211f3ea47754315344a2d262082c61d3346e0519e8279d5dee36e820d08", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scala_lang_scalap", @@ -137,7 +137,7 @@ artifacts = { }, "org_scalameta_trees": { "artifact": "org.scalameta:trees_2.12:{}".format(scalameta_version), - "sha256": "020b53681dd8e148d74ffa282276994bcb0f06c3425fb9a4bb9f8d161e22187a", + "sha256": "009d083d83cec430adf79e4a5a4101a0e51914f806205444741fb16e6bffc4fa", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", "@io_bazel_rules_scala_scala_library", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index b6c653edb..b52ee8d7b 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -117,7 +117,7 @@ artifacts = { }, "org_scalameta_common": { "artifact": "org.scalameta:common_2.13:{}".format(scalameta_version), - "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", + "sha256": "4ba6ab1928b43b33c6078011930bf8db5fadadf7f762d0519215b66e1641775e", "deps": [ "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", @@ -125,7 +125,7 @@ artifacts = { }, "org_scalameta_parsers": { "artifact": "org.scalameta:parsers_2.13:{}".format(scalameta_version), - "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", + "sha256": "051065222ebb847eadabe840a10adfbb9c447e798c4b25aa4bbdf7595a174709", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scalameta_trees", @@ -133,7 +133,7 @@ artifacts = { }, "org_scalameta_scalameta": { "artifact": "org.scalameta:scalameta_2.13:{}".format(scalameta_version), - "sha256": "d73eaf491eb588a2bd78aeba443e62bc95f1a368051d9e81607192c88fa4c61c", + "sha256": "b6de9376f57c3a1d47ea59f698f24608b03872991c8fab9345d44f101df91d0f", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scala_lang_scalap", @@ -142,7 +142,7 @@ artifacts = { }, "org_scalameta_trees": { "artifact": "org.scalameta:trees_2.13:{}".format(scalameta_version), - "sha256": "d49d2b085ae62e9317dd2a4e8b14be5b1ecbec2db392fa81cab86ad2bd7c2c68", + "sha256": "d0cac6d5947cb1c53d5c904f03087a4f2db69bdca93c7593a33444ed8f379ed9", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", "@io_bazel_rules_scala_scala_library", diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index daa6cb36d..b067717b7 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -129,7 +129,7 @@ artifacts = { }, "org_scalameta_common": { "artifact": "org.scalameta:common_2.13:{}".format(scalameta_version), - "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", + "sha256": "4ba6ab1928b43b33c6078011930bf8db5fadadf7f762d0519215b66e1641775e", "deps": [ "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", @@ -137,7 +137,7 @@ artifacts = { }, "org_scalameta_parsers": { "artifact": "org.scalameta:parsers_2.13:{}".format(scalameta_version), - "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", + "sha256": "051065222ebb847eadabe840a10adfbb9c447e798c4b25aa4bbdf7595a174709", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scalameta_trees", @@ -145,7 +145,7 @@ artifacts = { }, "org_scalameta_scalameta": { "artifact": "org.scalameta:scalameta_2.13:{}".format(scalameta_version), - "sha256": "d73eaf491eb588a2bd78aeba443e62bc95f1a368051d9e81607192c88fa4c61c", + "sha256": "b6de9376f57c3a1d47ea59f698f24608b03872991c8fab9345d44f101df91d0f", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scala_lang_scalap", @@ -154,7 +154,7 @@ artifacts = { }, "org_scalameta_trees": { "artifact": "org.scalameta:trees_2.13:{}".format(scalameta_version), - "sha256": "d49d2b085ae62e9317dd2a4e8b14be5b1ecbec2db392fa81cab86ad2bd7c2c68", + "sha256": "d0cac6d5947cb1c53d5c904f03087a4f2db69bdca93c7593a33444ed8f379ed9", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", "@io_bazel_rules_scala_scala_library", From cb07f1593ee52606f0eec025c96e0ccdbc685413 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:20:35 +0000 Subject: [PATCH 16/36] bump scalafmt --- third_party/repositories/scala_2_12.bzl | 4 ++-- third_party/repositories/scala_2_13.bzl | 6 +++--- third_party/repositories/scala_3_1.bzl | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index 96017eda3..afedfe8c9 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -95,8 +95,8 @@ artifacts = { ], }, "org_scalameta_scalafmt_core": { - "artifact": "org.scalameta:scalafmt-core_2.12:2.3.2", - "sha256": "4788e2045e99f4624162d3182016a05032a7ab1324c4a28af433aa070f916773", + "artifact": "org.scalameta:scalafmt-core_2.12:3.7.1", + "sha256": "ddb2150d935dee20746a2578ccf9bdfea7857d2d5be2e7153ccd6f1ee731ab32", "deps": [ "@com_geirsson_metaconfig_core", "@com_geirsson_metaconfig_typesafe_config", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index b52ee8d7b..c65fcab51 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -1,5 +1,5 @@ scala_version = "2.13.6" -scalameta_version = "4.7.3" +scalameta_version = "4.3.22" artifacts = { "io_bazel_rules_scala_scala_library": { @@ -99,8 +99,8 @@ artifacts = { ], }, "org_scalameta_scalafmt_core": { - "artifact": "org.scalameta:scalafmt-core_2.13:2.7.4", - "sha256": "873d98275f75b67c1e01094a24bafb29a588b7d05fdc508d3b1ba02f08d0c0d8", + "artifact": "org.scalameta:scalafmt-core_2.13:3.7.1", + "sha256": "d9cd90c7186c62a1e960d8ba9228a2e7c894b05cdbda7d1b102e595bc31f0cbe", "deps": [ "@com_geirsson_metaconfig_core", "@com_geirsson_metaconfig_typesafe_config", diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index b067717b7..7684a39f2 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -117,8 +117,8 @@ artifacts = { ], }, "org_scalameta_scalafmt_core": { - "artifact": "org.scalameta:scalafmt-core_2.13:2.7.4", - "sha256": "873d98275f75b67c1e01094a24bafb29a588b7d05fdc508d3b1ba02f08d0c0d8", + "artifact": "org.scalameta:scalafmt-core_2.13:3.7.1", + "sha256": "d9cd90c7186c62a1e960d8ba9228a2e7c894b05cdbda7d1b102e595bc31f0cbe", "deps": [ "@com_geirsson_metaconfig_core", "@com_geirsson_metaconfig_typesafe_config", From 39b10b291a2dd2337f753f6149eca2c1a6c242c3 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:25:01 +0000 Subject: [PATCH 17/36] Revert "bump, to retrigger PR checks" This reverts commit 110442d8d00d168d9f39e2672fe181b6833121ee. --- examples/testing/semanticdb_scala3/Foo.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/testing/semanticdb_scala3/Foo.scala b/examples/testing/semanticdb_scala3/Foo.scala index e246581ab..d82710638 100644 --- a/examples/testing/semanticdb_scala3/Foo.scala +++ b/examples/testing/semanticdb_scala3/Foo.scala @@ -1,3 +1,3 @@ class Foo: - def sayHello: String = "Hello from Scala 3!!" + def sayHello: String = "Hello Scala 3 !!" From f9bf0859eed0d892a3c90465c6c49a6bc2d5f9a5 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:31:05 +0000 Subject: [PATCH 18/36] Revert "Revert "bump, to retrigger PR checks"" This reverts commit 39b10b291a2dd2337f753f6149eca2c1a6c242c3. --- examples/testing/semanticdb_scala3/Foo.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/testing/semanticdb_scala3/Foo.scala b/examples/testing/semanticdb_scala3/Foo.scala index d82710638..e246581ab 100644 --- a/examples/testing/semanticdb_scala3/Foo.scala +++ b/examples/testing/semanticdb_scala3/Foo.scala @@ -1,3 +1,3 @@ class Foo: - def sayHello: String = "Hello Scala 3 !!" + def sayHello: String = "Hello from Scala 3!!" From 3f9cf08998b9e32d0f19ea087e5d3316f2a2e192 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:31:08 +0000 Subject: [PATCH 19/36] Revert "bump scalafmt" This reverts commit cb07f1593ee52606f0eec025c96e0ccdbc685413. --- third_party/repositories/scala_2_12.bzl | 4 ++-- third_party/repositories/scala_2_13.bzl | 6 +++--- third_party/repositories/scala_3_1.bzl | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index afedfe8c9..96017eda3 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -95,8 +95,8 @@ artifacts = { ], }, "org_scalameta_scalafmt_core": { - "artifact": "org.scalameta:scalafmt-core_2.12:3.7.1", - "sha256": "ddb2150d935dee20746a2578ccf9bdfea7857d2d5be2e7153ccd6f1ee731ab32", + "artifact": "org.scalameta:scalafmt-core_2.12:2.3.2", + "sha256": "4788e2045e99f4624162d3182016a05032a7ab1324c4a28af433aa070f916773", "deps": [ "@com_geirsson_metaconfig_core", "@com_geirsson_metaconfig_typesafe_config", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index c65fcab51..b52ee8d7b 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -1,5 +1,5 @@ scala_version = "2.13.6" -scalameta_version = "4.3.22" +scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library": { @@ -99,8 +99,8 @@ artifacts = { ], }, "org_scalameta_scalafmt_core": { - "artifact": "org.scalameta:scalafmt-core_2.13:3.7.1", - "sha256": "d9cd90c7186c62a1e960d8ba9228a2e7c894b05cdbda7d1b102e595bc31f0cbe", + "artifact": "org.scalameta:scalafmt-core_2.13:2.7.4", + "sha256": "873d98275f75b67c1e01094a24bafb29a588b7d05fdc508d3b1ba02f08d0c0d8", "deps": [ "@com_geirsson_metaconfig_core", "@com_geirsson_metaconfig_typesafe_config", diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index 7684a39f2..b067717b7 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -117,8 +117,8 @@ artifacts = { ], }, "org_scalameta_scalafmt_core": { - "artifact": "org.scalameta:scalafmt-core_2.13:3.7.1", - "sha256": "d9cd90c7186c62a1e960d8ba9228a2e7c894b05cdbda7d1b102e595bc31f0cbe", + "artifact": "org.scalameta:scalafmt-core_2.13:2.7.4", + "sha256": "873d98275f75b67c1e01094a24bafb29a588b7d05fdc508d3b1ba02f08d0c0d8", "deps": [ "@com_geirsson_metaconfig_core", "@com_geirsson_metaconfig_typesafe_config", From c8b5a7e315d750dc776f4a5a9c2e372d158a6dcb Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:31:10 +0000 Subject: [PATCH 20/36] Revert "update hashes" This reverts commit 993aa30d32552146b4636cf579ec7f91252e045d. --- third_party/repositories/scala_2_11.bzl | 8 ++++---- third_party/repositories/scala_2_12.bzl | 8 ++++---- third_party/repositories/scala_2_13.bzl | 8 ++++---- third_party/repositories/scala_3_1.bzl | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 5c233cb5c..98cb38e9e 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -100,7 +100,7 @@ artifacts = { }, "org_scalameta_common": { "artifact": "org.scalameta:common_2.11:{}".format(scalameta_version), - "sha256": "f0cd72562ec19d41f878f9c01338870c5311c8929a2238823ba3e04bce504acf", + "sha256": "6330798bcbd78d14d371202749f32efda0465c3be5fd057a6055a67e21335ba0", "deps": [ "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", @@ -108,7 +108,7 @@ artifacts = { }, "org_scalameta_parsers": { "artifact": "org.scalameta:parsers_2.11:{}".format(scalameta_version), - "sha256": "bc9868b54a8b8be90068513f13ae74d1c9bf70606f71b17e99018fab4c107d1a", + "sha256": "724382abfac27b32dec6c21210562bc7e1b09b5268ccb704abe66dcc8844beeb", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scalameta_trees", @@ -116,7 +116,7 @@ artifacts = { }, "org_scalameta_scalameta": { "artifact": "org.scalameta:scalameta_2.11:{}".format(scalameta_version), - "sha256": "51534025b55c62c6334e131fdda83604e1bd42e36abde288b154539cf0ea2b18", + "sha256": "94fe739295447cd3ae877c279ccde1def06baea02d9c76a504dda23de1d90516", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scala_lang_scalap", @@ -125,7 +125,7 @@ artifacts = { }, "org_scalameta_trees": { "artifact": "org.scalameta:trees_2.11:{}".format(scalameta_version), - "sha256": "a97cffd0cf8d057d67630c7ee4adaaf75b8915efdd7448e5bc9d0c8e19176047", + "sha256": "d24d5d63d8deafe646d455c822593a66adc6fdf17c8373754a3834a6e92a8a72", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", "@io_bazel_rules_scala_scala_library", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index 96017eda3..25e9b1898 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -112,7 +112,7 @@ artifacts = { }, "org_scalameta_common": { "artifact": "org.scalameta:common_2.12:{}".format(scalameta_version), - "sha256": "ee629e79071f422d097fc0656311d859cf8b42e8c3aae243d147c38da6f99e61", + "sha256": "3bdb2ff71d3e86f94b4d31d2c40442f533655860749a92fd17e1f29b8deb8baa", "deps": [ "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", @@ -120,7 +120,7 @@ artifacts = { }, "org_scalameta_parsers": { "artifact": "org.scalameta:parsers_2.12:{}".format(scalameta_version), - "sha256": "f597802f7162da06a90fa1d16469b39cff61a25d71274d90c1e38274afd75ae6", + "sha256": "d9f87d03b6b5e942f263db6dab75937493bfcb0fe7cfe2cda6567bf30f23ff3a", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scalameta_trees", @@ -128,7 +128,7 @@ artifacts = { }, "org_scalameta_scalameta": { "artifact": "org.scalameta:scalameta_2.12:{}".format(scalameta_version), - "sha256": "1a92a211f3ea47754315344a2d262082c61d3346e0519e8279d5dee36e820d08", + "sha256": "4d9487b434cbe9d89033824a4fc902dc7c782eea94961e8575df91ae96b10d6a", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scala_lang_scalap", @@ -137,7 +137,7 @@ artifacts = { }, "org_scalameta_trees": { "artifact": "org.scalameta:trees_2.12:{}".format(scalameta_version), - "sha256": "009d083d83cec430adf79e4a5a4101a0e51914f806205444741fb16e6bffc4fa", + "sha256": "020b53681dd8e148d74ffa282276994bcb0f06c3425fb9a4bb9f8d161e22187a", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", "@io_bazel_rules_scala_scala_library", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index b52ee8d7b..b6c653edb 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -117,7 +117,7 @@ artifacts = { }, "org_scalameta_common": { "artifact": "org.scalameta:common_2.13:{}".format(scalameta_version), - "sha256": "4ba6ab1928b43b33c6078011930bf8db5fadadf7f762d0519215b66e1641775e", + "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", "deps": [ "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", @@ -125,7 +125,7 @@ artifacts = { }, "org_scalameta_parsers": { "artifact": "org.scalameta:parsers_2.13:{}".format(scalameta_version), - "sha256": "051065222ebb847eadabe840a10adfbb9c447e798c4b25aa4bbdf7595a174709", + "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scalameta_trees", @@ -133,7 +133,7 @@ artifacts = { }, "org_scalameta_scalameta": { "artifact": "org.scalameta:scalameta_2.13:{}".format(scalameta_version), - "sha256": "b6de9376f57c3a1d47ea59f698f24608b03872991c8fab9345d44f101df91d0f", + "sha256": "d73eaf491eb588a2bd78aeba443e62bc95f1a368051d9e81607192c88fa4c61c", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scala_lang_scalap", @@ -142,7 +142,7 @@ artifacts = { }, "org_scalameta_trees": { "artifact": "org.scalameta:trees_2.13:{}".format(scalameta_version), - "sha256": "d0cac6d5947cb1c53d5c904f03087a4f2db69bdca93c7593a33444ed8f379ed9", + "sha256": "d49d2b085ae62e9317dd2a4e8b14be5b1ecbec2db392fa81cab86ad2bd7c2c68", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", "@io_bazel_rules_scala_scala_library", diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index b067717b7..daa6cb36d 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -129,7 +129,7 @@ artifacts = { }, "org_scalameta_common": { "artifact": "org.scalameta:common_2.13:{}".format(scalameta_version), - "sha256": "4ba6ab1928b43b33c6078011930bf8db5fadadf7f762d0519215b66e1641775e", + "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", "deps": [ "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", @@ -137,7 +137,7 @@ artifacts = { }, "org_scalameta_parsers": { "artifact": "org.scalameta:parsers_2.13:{}".format(scalameta_version), - "sha256": "051065222ebb847eadabe840a10adfbb9c447e798c4b25aa4bbdf7595a174709", + "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scalameta_trees", @@ -145,7 +145,7 @@ artifacts = { }, "org_scalameta_scalameta": { "artifact": "org.scalameta:scalameta_2.13:{}".format(scalameta_version), - "sha256": "b6de9376f57c3a1d47ea59f698f24608b03872991c8fab9345d44f101df91d0f", + "sha256": "d73eaf491eb588a2bd78aeba443e62bc95f1a368051d9e81607192c88fa4c61c", "deps": [ "@io_bazel_rules_scala_scala_library", "@org_scala_lang_scalap", @@ -154,7 +154,7 @@ artifacts = { }, "org_scalameta_trees": { "artifact": "org.scalameta:trees_2.13:{}".format(scalameta_version), - "sha256": "d0cac6d5947cb1c53d5c904f03087a4f2db69bdca93c7593a33444ed8f379ed9", + "sha256": "d49d2b085ae62e9317dd2a4e8b14be5b1ecbec2db392fa81cab86ad2bd7c2c68", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", "@io_bazel_rules_scala_scala_library", From b33b7511b4522a27907e16ca6a0a6c3b5563152d Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:31:21 +0000 Subject: [PATCH 21/36] Revert "more scala 3.1, refactor version string" This reverts commit 166c1f0e805043af11c07fb2315746d5af9f0664. --- third_party/repositories/scala_3_1.bzl | 37 +++++++++++++------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index daa6cb36d..49217d90f 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -1,5 +1,4 @@ scala_version = "3.1.0" -scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library_2": { @@ -92,6 +91,14 @@ artifacts = { "artifact": "org.scala-lang.modules:scala-parser-combinators_2.13:1.1.2", "sha256": "5c285b72e6dc0a98e99ae0a1ceeb4027dab9adfa441844046bd3f19e0efdcb54", }, + "org_scalameta_common": { + "artifact": "org.scalameta:common_2.13:4.3.24", + "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", + "deps": [ + "@com_lihaoyi_sourcecode", + "@io_bazel_rules_scala_scala_library", + ], + }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.13:1.0.1", "sha256": "b43b99244d5b51948daf1467083b3850dc2727c604de98dc426dec14244fd18e", @@ -116,6 +123,14 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, + "org_scalameta_parsers": { + "artifact": "org.scalameta:parsers_2.13:4.3.24", + "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", + "deps": [ + "@io_bazel_rules_scala_scala_library", + "@org_scalameta_trees", + ], + }, "org_scalameta_scalafmt_core": { "artifact": "org.scalameta:scalafmt-core_2.13:2.7.4", "sha256": "873d98275f75b67c1e01094a24bafb29a588b7d05fdc508d3b1ba02f08d0c0d8", @@ -127,24 +142,8 @@ artifacts = { "@io_bazel_rules_scala_scala_parallel_collections", ], }, - "org_scalameta_common": { - "artifact": "org.scalameta:common_2.13:{}".format(scalameta_version), - "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", - "deps": [ - "@com_lihaoyi_sourcecode", - "@io_bazel_rules_scala_scala_library", - ], - }, - "org_scalameta_parsers": { - "artifact": "org.scalameta:parsers_2.13:{}".format(scalameta_version), - "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", - "deps": [ - "@io_bazel_rules_scala_scala_library", - "@org_scalameta_trees", - ], - }, "org_scalameta_scalameta": { - "artifact": "org.scalameta:scalameta_2.13:{}".format(scalameta_version), + "artifact": "org.scalameta:scalameta_2.13:4.3.24", "sha256": "d73eaf491eb588a2bd78aeba443e62bc95f1a368051d9e81607192c88fa4c61c", "deps": [ "@io_bazel_rules_scala_scala_library", @@ -153,7 +152,7 @@ artifacts = { ], }, "org_scalameta_trees": { - "artifact": "org.scalameta:trees_2.13:{}".format(scalameta_version), + "artifact": "org.scalameta:trees_2.13:4.3.24", "sha256": "d49d2b085ae62e9317dd2a4e8b14be5b1ecbec2db392fa81cab86ad2bd7c2c68", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", From 73bdbce4d5f95fbee550c31736e037f01072643b Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:31:24 +0000 Subject: [PATCH 22/36] Revert "bump scalameta; refactor version string" This reverts commit 8fcbbc9afb04991a713f931ced843f01095a433e. --- third_party/repositories/scala_2_11.bzl | 53 ++++++++++++------------- third_party/repositories/scala_2_12.bzl | 45 ++++++++++----------- third_party/repositories/scala_2_13.bzl | 45 ++++++++++----------- 3 files changed, 70 insertions(+), 73 deletions(-) diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 98cb38e9e..956299818 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -1,5 +1,4 @@ scala_version = "2.11.12" -scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library": { @@ -70,6 +69,18 @@ artifacts = { "artifact": "org.scala-lang.modules:scala-parser-combinators_2.11:1.1.2", "sha256": "3e0889e95f5324da6420461f7147cb508241ed957ac5cfedc25eef19c5448f26", }, + "org_scalameta_common": { + "artifact": "org.scalameta:common_2.11:4.3.0", + "sha256": "6330798bcbd78d14d371202749f32efda0465c3be5fd057a6055a67e21335ba0", + "deps": [ + "@com_lihaoyi_sourcecode", + "@io_bazel_rules_scala_scala_library", + ], + }, + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_2.11.12:4.7.3", + "sha256": "0db52fc6639f73b15c3fb9fc1cb441704399f0d8dee8352ca1cf359630e7ca0f", + }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.11:1.0.1", "sha256": "49ecc30a4b47efc0038099da0c97515cf8f754ea631ea9f9935b36ca7d41b733", @@ -94,28 +105,28 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, - "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_{}:{}".format(scala_version, scalameta_version), - "sha256": "0db52fc6639f73b15c3fb9fc1cb441704399f0d8dee8352ca1cf359630e7ca0f", - }, - "org_scalameta_common": { - "artifact": "org.scalameta:common_2.11:{}".format(scalameta_version), - "sha256": "6330798bcbd78d14d371202749f32efda0465c3be5fd057a6055a67e21335ba0", + "org_scalameta_parsers": { + "artifact": "org.scalameta:parsers_2.11:4.3.0", + "sha256": "724382abfac27b32dec6c21210562bc7e1b09b5268ccb704abe66dcc8844beeb", "deps": [ - "@com_lihaoyi_sourcecode", "@io_bazel_rules_scala_scala_library", + "@org_scalameta_trees", ], }, - "org_scalameta_parsers": { - "artifact": "org.scalameta:parsers_2.11:{}".format(scalameta_version), - "sha256": "724382abfac27b32dec6c21210562bc7e1b09b5268ccb704abe66dcc8844beeb", + "org_scalameta_scalafmt_core": { + "artifact": "org.scalameta:scalafmt-core_2.11:2.3.2", + "sha256": "6bf391e0e1d7369fda83ddaf7be4d267bf4cbccdf2cc31ff941999a78c30e67f", "deps": [ + "@com_geirsson_metaconfig_core", + "@com_geirsson_metaconfig_typesafe_config", "@io_bazel_rules_scala_scala_library", - "@org_scalameta_trees", + "@io_bazel_rules_scala_scala_reflect", + "@org_scalameta_scalameta", + "@org_scala_lang_modules_scala_collection_compat", ], }, "org_scalameta_scalameta": { - "artifact": "org.scalameta:scalameta_2.11:{}".format(scalameta_version), + "artifact": "org.scalameta:scalameta_2.11:4.3.0", "sha256": "94fe739295447cd3ae877c279ccde1def06baea02d9c76a504dda23de1d90516", "deps": [ "@io_bazel_rules_scala_scala_library", @@ -124,7 +135,7 @@ artifacts = { ], }, "org_scalameta_trees": { - "artifact": "org.scalameta:trees_2.11:{}".format(scalameta_version), + "artifact": "org.scalameta:trees_2.11:4.3.0", "sha256": "d24d5d63d8deafe646d455c822593a66adc6fdf17c8373754a3834a6e92a8a72", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", @@ -133,18 +144,6 @@ artifacts = { "@org_scalameta_fastparse", ], }, - "org_scalameta_scalafmt_core": { - "artifact": "org.scalameta:scalafmt-core_2.11:2.3.2", - "sha256": "6bf391e0e1d7369fda83ddaf7be4d267bf4cbccdf2cc31ff941999a78c30e67f", - "deps": [ - "@com_geirsson_metaconfig_core", - "@com_geirsson_metaconfig_typesafe_config", - "@io_bazel_rules_scala_scala_library", - "@io_bazel_rules_scala_scala_reflect", - "@org_scalameta_scalameta", - "@org_scala_lang_modules_scala_collection_compat", - ], - }, "org_typelevel_paiges_core": { "artifact": "org.typelevel:paiges-core_2.11:0.2.4", "sha256": "aa66fbe0457ca5cb5b9e522d4cb873623bb376a2e1ff58c464b5194c1d87c241", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index 25e9b1898..98c61b9c6 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -1,5 +1,4 @@ scala_version = "2.12.14" -scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library": { @@ -70,6 +69,18 @@ artifacts = { "artifact": "org.scala-lang.modules:scala-parser-combinators_2.12:1.1.2", "sha256": "24985eb43e295a9dd77905ada307a850ca25acf819cdb579c093fc6987b0dbc2", }, + "org_scalameta_common": { + "artifact": "org.scalameta:common_2.12:4.3.0", + "sha256": "3bdb2ff71d3e86f94b4d31d2c40442f533655860749a92fd17e1f29b8deb8baa", + "deps": [ + "@com_lihaoyi_sourcecode", + "@io_bazel_rules_scala_scala_library", + ], + }, + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_2.12.14:4.7.3", + "sha256": "e5e31e1b48aedd3c7c2c2731d5053fd3429a3b37f076d95e8214acfa551c226a", + }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.12:1.0.1", "sha256": "387ced762e93915c5f87fed59d8453e404273f49f812d413405696ce20273aa5", @@ -94,6 +105,14 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, + "org_scalameta_parsers": { + "artifact": "org.scalameta:parsers_2.12:4.3.0", + "sha256": "d9f87d03b6b5e942f263db6dab75937493bfcb0fe7cfe2cda6567bf30f23ff3a", + "deps": [ + "@io_bazel_rules_scala_scala_library", + "@org_scalameta_trees", + ], + }, "org_scalameta_scalafmt_core": { "artifact": "org.scalameta:scalafmt-core_2.12:2.3.2", "sha256": "4788e2045e99f4624162d3182016a05032a7ab1324c4a28af433aa070f916773", @@ -106,28 +125,8 @@ artifacts = { "@org_scala_lang_modules_scala_collection_compat", ], }, - "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_{}:{}".format(scala_version, scalameta_version), - "sha256": "e5e31e1b48aedd3c7c2c2731d5053fd3429a3b37f076d95e8214acfa551c226a", - }, - "org_scalameta_common": { - "artifact": "org.scalameta:common_2.12:{}".format(scalameta_version), - "sha256": "3bdb2ff71d3e86f94b4d31d2c40442f533655860749a92fd17e1f29b8deb8baa", - "deps": [ - "@com_lihaoyi_sourcecode", - "@io_bazel_rules_scala_scala_library", - ], - }, - "org_scalameta_parsers": { - "artifact": "org.scalameta:parsers_2.12:{}".format(scalameta_version), - "sha256": "d9f87d03b6b5e942f263db6dab75937493bfcb0fe7cfe2cda6567bf30f23ff3a", - "deps": [ - "@io_bazel_rules_scala_scala_library", - "@org_scalameta_trees", - ], - }, "org_scalameta_scalameta": { - "artifact": "org.scalameta:scalameta_2.12:{}".format(scalameta_version), + "artifact": "org.scalameta:scalameta_2.12:4.3.0", "sha256": "4d9487b434cbe9d89033824a4fc902dc7c782eea94961e8575df91ae96b10d6a", "deps": [ "@io_bazel_rules_scala_scala_library", @@ -136,7 +135,7 @@ artifacts = { ], }, "org_scalameta_trees": { - "artifact": "org.scalameta:trees_2.12:{}".format(scalameta_version), + "artifact": "org.scalameta:trees_2.12:4.3.0", "sha256": "020b53681dd8e148d74ffa282276994bcb0f06c3425fb9a4bb9f8d161e22187a", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index b6c653edb..df4bcf62d 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -1,5 +1,4 @@ scala_version = "2.13.6" -scalameta_version = "4.7.3" artifacts = { "io_bazel_rules_scala_scala_library": { @@ -74,6 +73,18 @@ artifacts = { "artifact": "org.scala-lang.modules:scala-parser-combinators_2.13:1.1.2", "sha256": "5c285b72e6dc0a98e99ae0a1ceeb4027dab9adfa441844046bd3f19e0efdcb54", }, + "org_scalameta_common": { + "artifact": "org.scalameta:common_2.13:4.3.24", + "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", + "deps": [ + "@com_lihaoyi_sourcecode", + "@io_bazel_rules_scala_scala_library", + ], + }, + "org_scalameta_semanticdb_scalac": { + "artifact": "org.scalameta:semanticdb-scalac_2.13.6:4.7.3", + "sha256": "fbc7703b3ac407a4695d6055197cf9ea520260e0757dec488992b498a86ed656", + }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.13:1.0.1", "sha256": "b43b99244d5b51948daf1467083b3850dc2727c604de98dc426dec14244fd18e", @@ -98,6 +109,14 @@ artifacts = { "@io_bazel_rules_scala_scala_library", ], }, + "org_scalameta_parsers": { + "artifact": "org.scalameta:parsers_2.13:4.3.24", + "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", + "deps": [ + "@io_bazel_rules_scala_scala_library", + "@org_scalameta_trees", + ], + }, "org_scalameta_scalafmt_core": { "artifact": "org.scalameta:scalafmt-core_2.13:2.7.4", "sha256": "873d98275f75b67c1e01094a24bafb29a588b7d05fdc508d3b1ba02f08d0c0d8", @@ -111,28 +130,8 @@ artifacts = { "@io_bazel_rules_scala_scala_parallel_collections", ], }, - "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_{}:{}".format(scala_version, scalameta_version), - "sha256": "fbc7703b3ac407a4695d6055197cf9ea520260e0757dec488992b498a86ed656", - }, - "org_scalameta_common": { - "artifact": "org.scalameta:common_2.13:{}".format(scalameta_version), - "sha256": "bb8ffbca69b42417aa5d3c73d4434b73dbbeb66748abc44a024090ff3aa38bd3", - "deps": [ - "@com_lihaoyi_sourcecode", - "@io_bazel_rules_scala_scala_library", - ], - }, - "org_scalameta_parsers": { - "artifact": "org.scalameta:parsers_2.13:{}".format(scalameta_version), - "sha256": "5faebb22a064f38a4be19fdadb288dc771c1e362d0c4d2f46546f08e4f43c091", - "deps": [ - "@io_bazel_rules_scala_scala_library", - "@org_scalameta_trees", - ], - }, "org_scalameta_scalameta": { - "artifact": "org.scalameta:scalameta_2.13:{}".format(scalameta_version), + "artifact": "org.scalameta:scalameta_2.13:4.3.24", "sha256": "d73eaf491eb588a2bd78aeba443e62bc95f1a368051d9e81607192c88fa4c61c", "deps": [ "@io_bazel_rules_scala_scala_library", @@ -141,7 +140,7 @@ artifacts = { ], }, "org_scalameta_trees": { - "artifact": "org.scalameta:trees_2.13:{}".format(scalameta_version), + "artifact": "org.scalameta:trees_2.13:4.3.24", "sha256": "d49d2b085ae62e9317dd2a4e8b14be5b1ecbec2db392fa81cab86ad2bd7c2c68", "deps": [ "@com_thesamet_scalapb_scalapb_runtime", From fde8c33f4c2e965c3b69818758202ff18215ad56 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sat, 4 Feb 2023 21:31:27 +0000 Subject: [PATCH 23/36] Revert "Bump jmh version: 1.20 -> 1.36 (#1466)" This reverts commit 1e4df56559ca8b68eb9a173cdf048a3c81bead09. --- third_party/repositories/scala_2_11.bzl | 20 ++++++++++---------- third_party/repositories/scala_2_12.bzl | 20 ++++++++++---------- third_party/repositories/scala_2_13.bzl | 20 ++++++++++---------- third_party/repositories/scala_3_1.bzl | 20 ++++++++++---------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 956299818..947568f0b 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -235,24 +235,24 @@ artifacts = { ], }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core": { - "artifact": "org.openjdk.jmh:jmh-core:1.36", - "sha256": "f90974e37d0da8886b5c05e6e3e7e20556900d747c5a41c1023b47c3301ea73c", + "artifact": "org.openjdk.jmh:jmh-core:1.20", + "sha256": "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm": { - "artifact": "org.openjdk.jmh:jmh-generator-asm:1.36", - "sha256": "7460b11b823dee74b3e19617d35d5911b01245303d6e31c30f83417cfc2f54b5", + "artifact": "org.openjdk.jmh:jmh-generator-asm:1.20", + "sha256": "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection": { - "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.36", - "sha256": "a9c72760e12c199e2a2c28f1a126ebf0cc5b51c0b58d46472596fc32f7f92534", + "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.20", + "sha256": "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e", }, "io_bazel_rules_scala_org_ows2_asm_asm": { - "artifact": "org.ow2.asm:asm:9.0", - "sha256": "0df97574914aee92fd349d0cb4e00f3345d45b2c239e0bb50f0a90ead47888e0", + "artifact": "org.ow2.asm:asm:6.1.1", + "sha256": "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833", }, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple": { - "artifact": "net.sf.jopt-simple:jopt-simple:5.0.4", - "sha256": "df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28", + "artifact": "net.sf.jopt-simple:jopt-simple:4.6", + "sha256": "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda", }, "io_bazel_rules_scala_org_apache_commons_commons_math3": { "artifact": "org.apache.commons:commons-math3:3.6.1", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index 98c61b9c6..9cec6dc8d 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -235,24 +235,24 @@ artifacts = { ], }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core": { - "artifact": "org.openjdk.jmh:jmh-core:1.36", - "sha256": "f90974e37d0da8886b5c05e6e3e7e20556900d747c5a41c1023b47c3301ea73c", + "artifact": "org.openjdk.jmh:jmh-core:1.20", + "sha256": "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm": { - "artifact": "org.openjdk.jmh:jmh-generator-asm:1.36", - "sha256": "7460b11b823dee74b3e19617d35d5911b01245303d6e31c30f83417cfc2f54b5", + "artifact": "org.openjdk.jmh:jmh-generator-asm:1.20", + "sha256": "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection": { - "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.36", - "sha256": "a9c72760e12c199e2a2c28f1a126ebf0cc5b51c0b58d46472596fc32f7f92534", + "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.20", + "sha256": "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e", }, "io_bazel_rules_scala_org_ows2_asm_asm": { - "artifact": "org.ow2.asm:asm:9.0", - "sha256": "0df97574914aee92fd349d0cb4e00f3345d45b2c239e0bb50f0a90ead47888e0", + "artifact": "org.ow2.asm:asm:6.1.1", + "sha256": "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833", }, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple": { - "artifact": "net.sf.jopt-simple:jopt-simple:5.0.4", - "sha256": "df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28", + "artifact": "net.sf.jopt-simple:jopt-simple:4.6", + "sha256": "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda", }, "io_bazel_rules_scala_org_apache_commons_commons_math3": { "artifact": "org.apache.commons:commons-math3:3.6.1", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index df4bcf62d..a11f02b81 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -240,24 +240,24 @@ artifacts = { ], }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core": { - "artifact": "org.openjdk.jmh:jmh-core:1.36", - "sha256": "f90974e37d0da8886b5c05e6e3e7e20556900d747c5a41c1023b47c3301ea73c", + "artifact": "org.openjdk.jmh:jmh-core:1.20", + "sha256": "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm": { - "artifact": "org.openjdk.jmh:jmh-generator-asm:1.36", - "sha256": "7460b11b823dee74b3e19617d35d5911b01245303d6e31c30f83417cfc2f54b5", + "artifact": "org.openjdk.jmh:jmh-generator-asm:1.20", + "sha256": "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection": { - "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.36", - "sha256": "a9c72760e12c199e2a2c28f1a126ebf0cc5b51c0b58d46472596fc32f7f92534", + "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.20", + "sha256": "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e", }, "io_bazel_rules_scala_org_ows2_asm_asm": { - "artifact": "org.ow2.asm:asm:9.0", - "sha256": "0df97574914aee92fd349d0cb4e00f3345d45b2c239e0bb50f0a90ead47888e0", + "artifact": "org.ow2.asm:asm:6.1.1", + "sha256": "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833", }, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple": { - "artifact": "net.sf.jopt-simple:jopt-simple:5.0.4", - "sha256": "df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28", + "artifact": "net.sf.jopt-simple:jopt-simple:4.6", + "sha256": "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda", }, "io_bazel_rules_scala_org_apache_commons_commons_math3": { "artifact": "org.apache.commons:commons-math3:3.6.1", diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index 49217d90f..49d17e9d6 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -252,24 +252,24 @@ artifacts = { ], }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core": { - "artifact": "org.openjdk.jmh:jmh-core:1.36", - "sha256": "f90974e37d0da8886b5c05e6e3e7e20556900d747c5a41c1023b47c3301ea73c", + "artifact": "org.openjdk.jmh:jmh-core:1.20", + "sha256": "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm": { - "artifact": "org.openjdk.jmh:jmh-generator-asm:1.36", - "sha256": "7460b11b823dee74b3e19617d35d5911b01245303d6e31c30f83417cfc2f54b5", + "artifact": "org.openjdk.jmh:jmh-generator-asm:1.20", + "sha256": "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection": { - "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.36", - "sha256": "a9c72760e12c199e2a2c28f1a126ebf0cc5b51c0b58d46472596fc32f7f92534", + "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.20", + "sha256": "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e", }, "io_bazel_rules_scala_org_ows2_asm_asm": { - "artifact": "org.ow2.asm:asm:9.0", - "sha256": "0df97574914aee92fd349d0cb4e00f3345d45b2c239e0bb50f0a90ead47888e0", + "artifact": "org.ow2.asm:asm:6.1.1", + "sha256": "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833", }, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple": { - "artifact": "net.sf.jopt-simple:jopt-simple:5.0.4", - "sha256": "df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28", + "artifact": "net.sf.jopt-simple:jopt-simple:4.6", + "sha256": "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda", }, "io_bazel_rules_scala_org_apache_commons_commons_math3": { "artifact": "org.apache.commons:commons-math3:3.6.1", From 6bd7ad49ac778a1dc5e726f95d9095a453b75ec0 Mon Sep 17 00:00:00 2001 From: Dmitry Komanov Date: Tue, 31 Jan 2023 00:29:48 +0200 Subject: [PATCH 24/36] Bump jmh version: 1.20 -> 1.36 (#1466) Also bump versions of its dependencies: * org.ow2.asm:asm: 6.1.1 -> 9.0 * net.sf.jopt-simple:jopt-simple: 4.6 -> 5.0.4 --- third_party/repositories/scala_2_11.bzl | 20 ++++++++++---------- third_party/repositories/scala_2_12.bzl | 20 ++++++++++---------- third_party/repositories/scala_2_13.bzl | 20 ++++++++++---------- third_party/repositories/scala_3_1.bzl | 20 ++++++++++---------- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 947568f0b..956299818 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -235,24 +235,24 @@ artifacts = { ], }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core": { - "artifact": "org.openjdk.jmh:jmh-core:1.20", - "sha256": "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca", + "artifact": "org.openjdk.jmh:jmh-core:1.36", + "sha256": "f90974e37d0da8886b5c05e6e3e7e20556900d747c5a41c1023b47c3301ea73c", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm": { - "artifact": "org.openjdk.jmh:jmh-generator-asm:1.20", - "sha256": "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5", + "artifact": "org.openjdk.jmh:jmh-generator-asm:1.36", + "sha256": "7460b11b823dee74b3e19617d35d5911b01245303d6e31c30f83417cfc2f54b5", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection": { - "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.20", - "sha256": "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e", + "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.36", + "sha256": "a9c72760e12c199e2a2c28f1a126ebf0cc5b51c0b58d46472596fc32f7f92534", }, "io_bazel_rules_scala_org_ows2_asm_asm": { - "artifact": "org.ow2.asm:asm:6.1.1", - "sha256": "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833", + "artifact": "org.ow2.asm:asm:9.0", + "sha256": "0df97574914aee92fd349d0cb4e00f3345d45b2c239e0bb50f0a90ead47888e0", }, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple": { - "artifact": "net.sf.jopt-simple:jopt-simple:4.6", - "sha256": "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda", + "artifact": "net.sf.jopt-simple:jopt-simple:5.0.4", + "sha256": "df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28", }, "io_bazel_rules_scala_org_apache_commons_commons_math3": { "artifact": "org.apache.commons:commons-math3:3.6.1", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index 9cec6dc8d..98c61b9c6 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -235,24 +235,24 @@ artifacts = { ], }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core": { - "artifact": "org.openjdk.jmh:jmh-core:1.20", - "sha256": "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca", + "artifact": "org.openjdk.jmh:jmh-core:1.36", + "sha256": "f90974e37d0da8886b5c05e6e3e7e20556900d747c5a41c1023b47c3301ea73c", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm": { - "artifact": "org.openjdk.jmh:jmh-generator-asm:1.20", - "sha256": "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5", + "artifact": "org.openjdk.jmh:jmh-generator-asm:1.36", + "sha256": "7460b11b823dee74b3e19617d35d5911b01245303d6e31c30f83417cfc2f54b5", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection": { - "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.20", - "sha256": "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e", + "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.36", + "sha256": "a9c72760e12c199e2a2c28f1a126ebf0cc5b51c0b58d46472596fc32f7f92534", }, "io_bazel_rules_scala_org_ows2_asm_asm": { - "artifact": "org.ow2.asm:asm:6.1.1", - "sha256": "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833", + "artifact": "org.ow2.asm:asm:9.0", + "sha256": "0df97574914aee92fd349d0cb4e00f3345d45b2c239e0bb50f0a90ead47888e0", }, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple": { - "artifact": "net.sf.jopt-simple:jopt-simple:4.6", - "sha256": "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda", + "artifact": "net.sf.jopt-simple:jopt-simple:5.0.4", + "sha256": "df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28", }, "io_bazel_rules_scala_org_apache_commons_commons_math3": { "artifact": "org.apache.commons:commons-math3:3.6.1", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index a11f02b81..df4bcf62d 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -240,24 +240,24 @@ artifacts = { ], }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core": { - "artifact": "org.openjdk.jmh:jmh-core:1.20", - "sha256": "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca", + "artifact": "org.openjdk.jmh:jmh-core:1.36", + "sha256": "f90974e37d0da8886b5c05e6e3e7e20556900d747c5a41c1023b47c3301ea73c", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm": { - "artifact": "org.openjdk.jmh:jmh-generator-asm:1.20", - "sha256": "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5", + "artifact": "org.openjdk.jmh:jmh-generator-asm:1.36", + "sha256": "7460b11b823dee74b3e19617d35d5911b01245303d6e31c30f83417cfc2f54b5", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection": { - "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.20", - "sha256": "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e", + "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.36", + "sha256": "a9c72760e12c199e2a2c28f1a126ebf0cc5b51c0b58d46472596fc32f7f92534", }, "io_bazel_rules_scala_org_ows2_asm_asm": { - "artifact": "org.ow2.asm:asm:6.1.1", - "sha256": "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833", + "artifact": "org.ow2.asm:asm:9.0", + "sha256": "0df97574914aee92fd349d0cb4e00f3345d45b2c239e0bb50f0a90ead47888e0", }, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple": { - "artifact": "net.sf.jopt-simple:jopt-simple:4.6", - "sha256": "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda", + "artifact": "net.sf.jopt-simple:jopt-simple:5.0.4", + "sha256": "df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28", }, "io_bazel_rules_scala_org_apache_commons_commons_math3": { "artifact": "org.apache.commons:commons-math3:3.6.1", diff --git a/third_party/repositories/scala_3_1.bzl b/third_party/repositories/scala_3_1.bzl index 49d17e9d6..49217d90f 100644 --- a/third_party/repositories/scala_3_1.bzl +++ b/third_party/repositories/scala_3_1.bzl @@ -252,24 +252,24 @@ artifacts = { ], }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_core": { - "artifact": "org.openjdk.jmh:jmh-core:1.20", - "sha256": "1688db5110ea6413bf63662113ed38084106ab1149e020c58c5ac22b91b842ca", + "artifact": "org.openjdk.jmh:jmh-core:1.36", + "sha256": "f90974e37d0da8886b5c05e6e3e7e20556900d747c5a41c1023b47c3301ea73c", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_asm": { - "artifact": "org.openjdk.jmh:jmh-generator-asm:1.20", - "sha256": "2dd4798b0c9120326310cda3864cc2e0035b8476346713d54a28d1adab1414a5", + "artifact": "org.openjdk.jmh:jmh-generator-asm:1.36", + "sha256": "7460b11b823dee74b3e19617d35d5911b01245303d6e31c30f83417cfc2f54b5", }, "io_bazel_rules_scala_org_openjdk_jmh_jmh_generator_reflection": { - "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.20", - "sha256": "57706f7c8278272594a9afc42753aaf9ba0ba05980bae0673b8195908d21204e", + "artifact": "org.openjdk.jmh:jmh-generator-reflection:1.36", + "sha256": "a9c72760e12c199e2a2c28f1a126ebf0cc5b51c0b58d46472596fc32f7f92534", }, "io_bazel_rules_scala_org_ows2_asm_asm": { - "artifact": "org.ow2.asm:asm:6.1.1", - "sha256": "dd3b546415dd4bade2ebe3b47c7828ab0623ee2336604068e2d81023f9f8d833", + "artifact": "org.ow2.asm:asm:9.0", + "sha256": "0df97574914aee92fd349d0cb4e00f3345d45b2c239e0bb50f0a90ead47888e0", }, "io_bazel_rules_scala_net_sf_jopt_simple_jopt_simple": { - "artifact": "net.sf.jopt-simple:jopt-simple:4.6", - "sha256": "3fcfbe3203c2ea521bf7640484fd35d6303186ea2e08e72f032d640ca067ffda", + "artifact": "net.sf.jopt-simple:jopt-simple:5.0.4", + "sha256": "df26cc58f235f477db07f753ba5a3ab243ebe5789d9f89ecf68dd62ea9a66c28", }, "io_bazel_rules_scala_org_apache_commons_commons_math3": { "artifact": "org.apache.commons:commons-math3:3.6.1", From 4b1d96a888938c3eb65e570cb6c06b93d89c0afc Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Mon, 6 Feb 2023 01:59:56 +0000 Subject: [PATCH 25/36] add to predefined outputs --- scala/private/common_outputs.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/scala/private/common_outputs.bzl b/scala/private/common_outputs.bzl index b48adcce8..fd869bee4 100644 --- a/scala/private/common_outputs.bzl +++ b/scala/private/common_outputs.bzl @@ -6,4 +6,5 @@ common_outputs = { "manifest": "%{name}_MANIFEST.MF", "statsfile": "%{name}.statsfile", "diagnosticsfile": "%{name}.diagnosticsproto", + "semanticdb": "%{name}.semanticdb" } From 0760c4220928bf8841363546ce69656c8e859d33 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Mon, 6 Feb 2023 03:53:57 +0000 Subject: [PATCH 26/36] revert predefined output --- scala/private/common_outputs.bzl | 1 - 1 file changed, 1 deletion(-) diff --git a/scala/private/common_outputs.bzl b/scala/private/common_outputs.bzl index fd869bee4..b48adcce8 100644 --- a/scala/private/common_outputs.bzl +++ b/scala/private/common_outputs.bzl @@ -6,5 +6,4 @@ common_outputs = { "manifest": "%{name}_MANIFEST.MF", "statsfile": "%{name}.statsfile", "diagnosticsfile": "%{name}.diagnosticsproto", - "semanticdb": "%{name}.semanticdb" } From 9bdd57a516be2c2075c07647b56e43edd5babbe2 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 12 Feb 2023 01:08:34 +0000 Subject: [PATCH 27/36] include semanticdb in class jar --- scala/private/rule_impls.bzl | 9 --------- .../rulesscala/scalac/CompileOptions.java | 2 -- .../bazel/rulesscala/scalac/ScalacWorker.java | 1 - .../rulesscala/scalac/ScalacWorker3.java | 1 - test/shell/test_examples.sh | 11 +++------- test/shell/test_helper.sh | 9 +++++++++ test/shell/test_semanticdb.sh | 20 ++++++++----------- 7 files changed, 20 insertions(+), 33 deletions(-) diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index 3c84908af..6180e878a 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -73,11 +73,6 @@ def compile_scala( enable_diagnostics_report = toolchain.enable_diagnostics_report enable_semanticdb = toolchain.enable_semanticdb - semanticdb_dir = "{}.semanticdb".format(ctx.label.name) - - if enable_semanticdb: - semanticdb_out = ctx.actions.declare_directory(semanticdb_dir) - outs.append(semanticdb_out) args = ctx.actions.args() args.set_param_file_format("multiline") @@ -104,13 +99,9 @@ def compile_scala( args.add_all("--ResourceJars", resource_jars) args.add_all("--ScalacOpts", scalacopts_expanded) args.add_all("--SourceJars", all_srcjars) - args.add("--EnableSemanticDb", enable_semanticdb) if enable_semanticdb: - target = "{}/{}/{}".format(ctx.bin_dir.path, ctx.label.package, semanticdb_dir) - args.add("--SemanticDbTarget", target) - if hasattr(ctx.attr, "_semanticdb_scalac_plugin"): jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] args.add("--SemanticDbJar", jar) diff --git a/src/java/io/bazel/rulesscala/scalac/CompileOptions.java b/src/java/io/bazel/rulesscala/scalac/CompileOptions.java index 921d8458c..0fa8f6fe7 100644 --- a/src/java/io/bazel/rulesscala/scalac/CompileOptions.java +++ b/src/java/io/bazel/rulesscala/scalac/CompileOptions.java @@ -36,7 +36,6 @@ public class CompileOptions { public final boolean enableDiagnosticsReport; public final boolean enableSemanticDb; - public final Optional semanticDbTarget; public final Optional semanticDbJar; public CompileOptions(String[] lines) { @@ -77,7 +76,6 @@ public CompileOptions(String[] lines) { diagnosticsFile = args.getSingleOrError("DiagnosticsFile"); enableSemanticDb = Boolean.parseBoolean(args.getSingleOrError("EnableSemanticDb")); - semanticDbTarget = args.getSingleOptional("SemanticDbTarget"); semanticDbJar = args.getSingleOptional("SemanticDbJar"); } diff --git a/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java b/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java index 8cec21416..eba1f448f 100644 --- a/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java +++ b/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java @@ -239,7 +239,6 @@ private static String[] getPluginParamsFrom(CompileOptions ops) { String[] params = { "-Yrangepos", "-P:semanticdb:failures:error", - "-P:semanticdb:targetroot:" + ops.semanticDbTarget.get(), "-Xplugin-require:semanticdb" }; diff --git a/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java b/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java index c296b542b..be8b65972 100644 --- a/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java +++ b/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java @@ -241,7 +241,6 @@ private static String[] getPluginParamsFrom(CompileOptions ops) { if (ops.enableSemanticDb) { pluginParams.add("-Xsemanticdb"); - pluginParams.add("-semanticdb-target:" + ops.semanticDbTarget.get()); } return pluginParams.toArray(new String[pluginParams.size()]); diff --git a/test/shell/test_examples.sh b/test/shell/test_examples.sh index f37810e35..3911442b6 100755 --- a/test/shell/test_examples.sh +++ b/test/shell/test_examples.sh @@ -26,15 +26,10 @@ function test_produces_semanticdb_scala3() { cd examples/testing/semanticdb_scala3 bazel run --extra_toolchains=//:semanticdb_toolchain //:run - local OUT_DIR="$(bazel info bazel-bin)/all.semanticdb" - if [ ! -d "$OUT_DIR" ]; then - echo "No SemanticDB out directory" - exit 1 - fi + local JAR="$(bazel info bazel-bin)/all.jar" - local SIZE=$(du -s $OUT_DIR | cut -f1) - if (( SIZE < 8 )); then - echo "No SemanticDb files produced" + if ! jar_contains_files $JAR "Foo.scala.semanticdb" "Main.scala.semanticdb"; then + echo "SemanticDB output not included in jar $JAR" exit 1 fi ) diff --git a/test/shell/test_helper.sh b/test/shell/test_helper.sh index fe10dbd8c..8bd3c49db 100755 --- a/test/shell/test_helper.sh +++ b/test/shell/test_helper.sh @@ -111,3 +111,12 @@ test_scala_library_expect_failure_on_missing_direct_deps() { test_expect_failure_or_warning_on_missing_direct_deps_with_expected_message "${expected_message}" $test_target "--extra_toolchains=//test/toolchains:high_level_transitive_deps_strict_deps_error" } + +jar_contains_files() { + for arg in "${@:2}" + do + if ! jar tf $1 | grep $arg; then + return 1 + fi + done +} \ No newline at end of file diff --git a/test/shell/test_semanticdb.sh b/test/shell/test_semanticdb.sh index 77798f76c..1ca5dda1f 100755 --- a/test/shell/test_semanticdb.sh +++ b/test/shell/test_semanticdb.sh @@ -5,21 +5,17 @@ dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) . "${dir}"/test_helper.sh runner=$(get_test_runner "${1:-local}") +FILES=("A.scala.semanticdb" "B.scala.semanticdb") + test_produces_semanticdb() { bazel build \ --extra_toolchains=//test/semanticdb:semanticdb_toolchain \ //test/semanticdb/... - local OUT_DIR="$(bazel info bazel-bin)/test/semanticdb/all.semanticdb" - - if [ ! -d "$OUT_DIR" ]; then - echo "No SemanticDB out directory" - exit 1 - fi + local JAR="$(bazel info bazel-bin)/test/semanticdb/all.jar" - local SIZE=$(du -s $OUT_DIR | cut -f1) - if (( SIZE < 8 )); then - echo "No SemanticDb files produced" + if ! jar_contains_files $JAR "${FILES[@]}"; then + echo "SemanticDB output not included in jar $JAR" exit 1 fi } @@ -29,10 +25,10 @@ test_no_semanticdb() { bazel build \ //test/semanticdb/... - local OUT_DIR="$(bazel info bazel-bin)/test/semanticdb/all.semanticdb" + local JAR="$(bazel info bazel-bin)/test/semanticdb/all.jar" - if [ -d "$OUT_DIR" ]; then - echo "Got SemanticDB out directory, but wasn't expecting it" + if jar_contains_files $JAR "${FILES[@]}"; then + echo "SemanticDB included in jar $JAR, but wasn't expected to be" exit 1 fi } From 7f9696e1c5d35cead8c41ef9d9198f7d8415bed1 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 5 Mar 2023 22:47:25 +0000 Subject: [PATCH 28/36] fix merge --- scala/scala_toolchain.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/scala/scala_toolchain.bzl b/scala/scala_toolchain.bzl index cef925674..90f0309f7 100644 --- a/scala/scala_toolchain.bzl +++ b/scala/scala_toolchain.bzl @@ -6,6 +6,7 @@ load( "@io_bazel_rules_scala_config//:config.bzl", "ENABLE_COMPILER_DEPENDENCY_TRACKING", ) +load( "@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") def _compute_strict_deps_mode(input_strict_deps_mode, dependency_mode): if dependency_mode == "direct": From 2e4b448c51681822113ca2632e69382aedf464e5 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 5 Mar 2023 23:49:19 +0000 Subject: [PATCH 29/36] fix tests --- scala/private/common_attributes.bzl | 1 + scala/private/rule_impls.bzl | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scala/private/common_attributes.bzl b/scala/private/common_attributes.bzl index 3487562b8..10a6a4920 100644 --- a/scala/private/common_attributes.bzl +++ b/scala/private/common_attributes.bzl @@ -66,6 +66,7 @@ semanticdb_attrs = { } if SCALA_MAJOR_VERSION.startswith("2") else {} common_attrs.update(semanticdb_attrs) +common_attrs_for_plugin_bootstrapping.update(semanticdb_attrs) common_attrs.update({ "_dependency_analyzer_plugin": attr.label( diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index e8c8e998f..755a4901c 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -104,9 +104,8 @@ def compile_scala( args.add("--EnableSemanticDb", enable_semanticdb) if enable_semanticdb: - if hasattr(ctx.attr, "_semanticdb_scalac_plugin"): - jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] - args.add("--SemanticDbJar", jar) + jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] + args.add("--SemanticDbJar", jar) if dependency_info.need_direct_info: args.add_all("--DirectJars", cjars) From b7c12311d5ec16f41e3cb433b5782100f85d7f1e Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 5 Mar 2023 23:57:46 +0000 Subject: [PATCH 30/36] lint --- scala/private/rule_impls.bzl | 1 - scala/scala_toolchain.bzl | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index 755a4901c..98dc649d1 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -57,7 +57,6 @@ def compile_scala( dependency_info, unused_dependency_checker_ignored_targets, stamp_target_label = None): - # look for any plugins: input_plugins = plugins plugins = _collect_plugin_paths(plugins) diff --git a/scala/scala_toolchain.bzl b/scala/scala_toolchain.bzl index 90f0309f7..6ae1b0599 100644 --- a/scala/scala_toolchain.bzl +++ b/scala/scala_toolchain.bzl @@ -5,8 +5,8 @@ load( load( "@io_bazel_rules_scala_config//:config.bzl", "ENABLE_COMPILER_DEPENDENCY_TRACKING", + "SCALA_MAJOR_VERSION", ) -load( "@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") def _compute_strict_deps_mode(input_strict_deps_mode, dependency_mode): if dependency_mode == "direct": From c04194999d8d95fbc6c31dc95c383b62a1fe2649 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Mon, 6 Mar 2023 01:57:37 +0000 Subject: [PATCH 31/36] move to phases --- scala/private/phases/phase_compile.bzl | 5 ++++- scala/private/phases/phase_semanticdb.bzl | 13 +++++++++++++ scala/private/phases/phases.bzl | 5 +++++ scala/private/rule_impls.bzl | 8 ++++---- scala/private/rules/scala_binary.bzl | 2 ++ scala/private/rules/scala_junit_test.bzl | 2 ++ scala/private/rules/scala_library.bzl | 4 ++++ scala/private/rules/scala_repl.bzl | 2 ++ scala/private/rules/scala_test.bzl | 2 ++ scala_proto/private/scala_proto_aspect.bzl | 1 + twitter_scrooge/twitter_scrooge.bzl | 1 + 11 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 scala/private/phases/phase_semanticdb.bzl diff --git a/scala/private/phases/phase_compile.bzl b/scala/private/phases/phase_compile.bzl index 4d59e10ea..7409506be 100644 --- a/scala/private/phases/phase_compile.bzl +++ b/scala/private/phases/phase_compile.bzl @@ -144,6 +144,7 @@ def _phase_compile( deps_providers, default_classpath, unused_dependency_checker_ignored_targets, + p.semanticdb.enabled ) # TODO: simplify the return values and use provider @@ -169,7 +170,8 @@ def _compile_or_empty( dependency_info, deps_providers, default_classpath, - unused_dependency_checker_ignored_targets): + unused_dependency_checker_ignored_targets, + semanticdb_enabled): # We assume that if a srcjar is present, it is not empty if len(ctx.files.srcs) + len(srcjars.to_list()) == 0: _build_nosrc_jar(ctx) @@ -212,6 +214,7 @@ def _compile_or_empty( ctx.executable._scalac, dependency_info, unused_dependency_checker_ignored_targets, + semanticdb_enabled ) # build ijar if needed diff --git a/scala/private/phases/phase_semanticdb.bzl b/scala/private/phases/phase_semanticdb.bzl new file mode 100644 index 000000000..ec8b0b555 --- /dev/null +++ b/scala/private/phases/phase_semanticdb.bzl @@ -0,0 +1,13 @@ +# +# PHASE: phase semanticdb +# +# Outputs for semanticdb when enabled in toolchain +# +def phase_semanticdb(ctx, p): + toolchain = ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"] + enable_semanticdb = toolchain.enable_semanticdb + + if enable_semanticdb: + return struct(enabled = True) + else: + return struct(enabled = False) diff --git a/scala/private/phases/phases.bzl b/scala/private/phases/phases.bzl index fbe7bd674..0843d4d2b 100644 --- a/scala/private/phases/phases.bzl +++ b/scala/private/phases/phases.bzl @@ -67,6 +67,8 @@ load("@io_bazel_rules_scala//scala/private:phases/phase_coverage_runfiles.bzl", load("@io_bazel_rules_scala//scala/private:phases/phase_scalafmt.bzl", _phase_scalafmt = "phase_scalafmt") load("@io_bazel_rules_scala//scala/private:phases/phase_test_environment.bzl", _phase_test_environment = "phase_test_environment") +load("@io_bazel_rules_scala//scala/private:phases/phase_semanticdb.bzl", _phase_semanticdb = "phase_semanticdb") + # API run_phases = _run_phases extras_phases = _extras_phases @@ -146,3 +148,6 @@ phase_test_environment = _phase_test_environment # scalafmt phase_scalafmt = _phase_scalafmt + +# semanticdb +phase_semanticdb = _phase_semanticdb diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index 98dc649d1..e98c085e2 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -17,6 +17,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_tools//tools/jdk:toolchain_utils.bzl", "find_java_toolchain") load(":common.bzl", _collect_plugin_paths = "collect_plugin_paths") load(":resources.bzl", _resource_paths = "paths") +load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") def expand_location(ctx, flags): if hasattr(ctx.attr, "data"): @@ -56,6 +57,7 @@ def compile_scala( scalac, dependency_info, unused_dependency_checker_ignored_targets, + semanticdb_enabled, stamp_target_label = None): # look for any plugins: input_plugins = plugins @@ -71,8 +73,6 @@ def compile_scala( enable_stats_file = toolchain.enable_stats_file enable_diagnostics_report = toolchain.enable_diagnostics_report - enable_semanticdb = toolchain.enable_semanticdb - args = ctx.actions.args() args.set_param_file_format("multiline") args.use_param_file(param_file_arg = "@%s", use_always = True) @@ -100,9 +100,9 @@ def compile_scala( args.add_all("--ResourceJars", resource_jars) args.add_all("--ScalacOpts", scalacopts_expanded) args.add_all("--SourceJars", all_srcjars) - args.add("--EnableSemanticDb", enable_semanticdb) + args.add("--EnableSemanticDb", semanticdb_enabled) - if enable_semanticdb: + if semanticdb_enabled and SCALA_MAJOR_VERSION.startswith(2): jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] args.add("--SemanticDbJar", jar) diff --git a/scala/private/rules/scala_binary.bzl b/scala/private/rules/scala_binary.bzl index 25a89d2c2..4d59e8509 100644 --- a/scala/private/rules/scala_binary.bzl +++ b/scala/private/rules/scala_binary.bzl @@ -23,6 +23,7 @@ load( "phase_runfiles_common", "phase_scalac_provider", "phase_scalacopts", + "phase_semanticdb", "phase_write_executable_common", "phase_write_manifest", "run_phases", @@ -40,6 +41,7 @@ def _scala_binary_impl(ctx): ("java_wrapper", phase_java_wrapper_common), ("declare_executable", phase_declare_executable), ("scalacopts", phase_scalacopts), + ("semanticdb", phase_semanticdb), # no need to build an ijar for an executable ("compile", phase_compile_binary), ("coverage", phase_coverage_common), diff --git a/scala/private/rules/scala_junit_test.bzl b/scala/private/rules/scala_junit_test.bzl index 58567464e..c45d4592d 100644 --- a/scala/private/rules/scala_junit_test.bzl +++ b/scala/private/rules/scala_junit_test.bzl @@ -24,6 +24,7 @@ load( "phase_runfiles_common", "phase_scalac_provider", "phase_scalacopts", + "phase_semanticdb", "phase_test_environment", "phase_write_executable_junit_test", "phase_write_manifest", @@ -46,6 +47,7 @@ def _scala_junit_test_impl(ctx): ("java_wrapper", phase_java_wrapper_common), ("declare_executable", phase_declare_executable), ("scalacopts", phase_scalacopts), + ("semanticdb", phase_semanticdb), # no need to build an ijar for an executable ("compile", phase_compile_junit_test), ("coverage", phase_coverage_common), diff --git a/scala/private/rules/scala_library.bzl b/scala/private/rules/scala_library.bzl index 7cd05bbd8..f6de92b4e 100644 --- a/scala/private/rules/scala_library.bzl +++ b/scala/private/rules/scala_library.bzl @@ -35,6 +35,7 @@ load( "phase_scalac_provider", "phase_scalacopts", "phase_write_manifest", + "phase_semanticdb", "run_phases", ) @@ -66,6 +67,7 @@ def _scala_library_impl(ctx): ("dependency", phase_dependency_common), ("collect_jars", phase_collect_jars_common), ("scalacopts", phase_scalacopts), + ("semanticdb", phase_semanticdb), ("compile", phase_compile_library), ("coverage", phase_coverage_library), ("merge_jars", phase_merge_jars), @@ -146,6 +148,7 @@ def _scala_library_for_plugin_bootstrapping_impl(ctx): ("dependency", phase_dependency_library_for_plugin_bootstrapping), ("collect_jars", phase_collect_jars_common), ("scalacopts", phase_scalacopts), + ("semanticdb", phase_semanticdb), ("compile", phase_compile_library_for_plugin_bootstrapping), ("merge_jars", phase_merge_jars), ("runfiles", phase_runfiles_library), @@ -213,6 +216,7 @@ def _scala_macro_library_impl(ctx): ("dependency", phase_dependency_common), ("collect_jars", phase_collect_jars_macro_library), ("scalacopts", phase_scalacopts), + ("semanticdb", phase_semanticdb), ("compile", phase_compile_macro_library), ("coverage", phase_coverage_common), ("merge_jars", phase_merge_jars), diff --git a/scala/private/rules/scala_repl.bzl b/scala/private/rules/scala_repl.bzl index 9b4695653..67e042742 100644 --- a/scala/private/rules/scala_repl.bzl +++ b/scala/private/rules/scala_repl.bzl @@ -23,6 +23,7 @@ load( "phase_runfiles_common", "phase_scalac_provider", "phase_scalacopts", + "phase_semanticdb", "phase_write_executable_repl", "phase_write_manifest", "run_phases", @@ -41,6 +42,7 @@ def _scala_repl_impl(ctx): ("java_wrapper", phase_java_wrapper_repl), ("declare_executable", phase_declare_executable), ("scalacopts", phase_scalacopts), + ("semanticdb", phase_semanticdb), # no need to build an ijar for an executable ("compile", phase_compile_repl), ("coverage", phase_coverage_common), diff --git a/scala/private/rules/scala_test.bzl b/scala/private/rules/scala_test.bzl index 5120bef00..19e50a639 100644 --- a/scala/private/rules/scala_test.bzl +++ b/scala/private/rules/scala_test.bzl @@ -24,6 +24,7 @@ load( "phase_runfiles_scalatest", "phase_scalac_provider", "phase_scalacopts", + "phase_semanticdb", "phase_test_environment", "phase_write_executable_scalatest", "phase_write_manifest", @@ -43,6 +44,7 @@ def _scala_test_impl(ctx): ("declare_executable", phase_declare_executable), ("scalacopts", phase_scalacopts), # no need to build an ijar for an executable + ("semanticdb", phase_semanticdb), ("compile", phase_compile_scalatest), ("coverage", phase_coverage_common), ("merge_jars", phase_merge_jars), diff --git a/scala_proto/private/scala_proto_aspect.bzl b/scala_proto/private/scala_proto_aspect.bzl index bd80d428c..592495edd 100644 --- a/scala_proto/private/scala_proto_aspect.bzl +++ b/scala_proto/private/scala_proto_aspect.bzl @@ -121,6 +121,7 @@ def _compile_sources(ctx, toolchain, proto, src_jars, deps, scalacopts, stamp_la scalac = toolchain.scalac, dependency_info = legacy_unclear_dependency_info_for_protobuf_scrooge(ctx), unused_dependency_checker_ignored_targets = [], + semanticdb_enabled = False, stamp_target_label = stamp_label, ) diff --git a/twitter_scrooge/twitter_scrooge.bzl b/twitter_scrooge/twitter_scrooge.bzl index becc721a7..e95e4b826 100644 --- a/twitter_scrooge/twitter_scrooge.bzl +++ b/twitter_scrooge/twitter_scrooge.bzl @@ -285,6 +285,7 @@ def _compile_generated_scala( scalac = ctx.executable._scalac, dependency_info = legacy_unclear_dependency_info_for_protobuf_scrooge(ctx), unused_dependency_checker_ignored_targets = [], + semanticdb_enabled = False ) return _create_java_info_provider(scrooge_jar, all_deps, output) From c86b3ffe7d9135bdbdde45c261653a696db698f7 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Mon, 6 Mar 2023 02:06:10 +0000 Subject: [PATCH 32/36] fix bug --- scala/private/rule_impls.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index e98c085e2..abf376fe6 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -102,7 +102,7 @@ def compile_scala( args.add_all("--SourceJars", all_srcjars) args.add("--EnableSemanticDb", semanticdb_enabled) - if semanticdb_enabled and SCALA_MAJOR_VERSION.startswith(2): + if semanticdb_enabled and SCALA_MAJOR_VERSION.startswith("2"): jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] args.add("--SemanticDbJar", jar) From 54b4837cfb89864727acef5fb9293bbd553a4b28 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 12 Mar 2023 21:53:50 +0000 Subject: [PATCH 33/36] force rebuild --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0edfc6aef..51d6655a0 100644 --- a/README.md +++ b/README.md @@ -278,3 +278,4 @@ Here's a (non-exhaustive) list of companies that use `rules_scala` in production * [Twitter](https://twitter.com/) * [VSCO](https://vsco.co) * [Wix](https://www.wix.com/) + From 6de925d68b8482574a50a85e97f89467f0c31944 Mon Sep 17 00:00:00 2001 From: Aish Fenton Date: Sun, 12 Mar 2023 21:58:36 +0000 Subject: [PATCH 34/36] lint fix --- scala/private/phases/phase_compile.bzl | 4 ++-- scala/private/phases/phase_semanticdb.bzl | 2 +- scala/private/phases/phases.bzl | 1 - scala/private/rules/scala_library.bzl | 2 +- twitter_scrooge/twitter_scrooge.bzl | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scala/private/phases/phase_compile.bzl b/scala/private/phases/phase_compile.bzl index 7409506be..0b78d5d45 100644 --- a/scala/private/phases/phase_compile.bzl +++ b/scala/private/phases/phase_compile.bzl @@ -144,7 +144,7 @@ def _phase_compile( deps_providers, default_classpath, unused_dependency_checker_ignored_targets, - p.semanticdb.enabled + p.semanticdb.enabled, ) # TODO: simplify the return values and use provider @@ -214,7 +214,7 @@ def _compile_or_empty( ctx.executable._scalac, dependency_info, unused_dependency_checker_ignored_targets, - semanticdb_enabled + semanticdb_enabled, ) # build ijar if needed diff --git a/scala/private/phases/phase_semanticdb.bzl b/scala/private/phases/phase_semanticdb.bzl index ec8b0b555..4e17a8302 100644 --- a/scala/private/phases/phase_semanticdb.bzl +++ b/scala/private/phases/phase_semanticdb.bzl @@ -1,7 +1,7 @@ # # PHASE: phase semanticdb # -# Outputs for semanticdb when enabled in toolchain +# Outputs for semanticdb when enabled in toolchain # def phase_semanticdb(ctx, p): toolchain = ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"] diff --git a/scala/private/phases/phases.bzl b/scala/private/phases/phases.bzl index 0843d4d2b..a497f4d07 100644 --- a/scala/private/phases/phases.bzl +++ b/scala/private/phases/phases.bzl @@ -66,7 +66,6 @@ load("@io_bazel_rules_scala//scala/private:phases/phase_scalacopts.bzl", _phase_ load("@io_bazel_rules_scala//scala/private:phases/phase_coverage_runfiles.bzl", _phase_coverage_runfiles = "phase_coverage_runfiles") load("@io_bazel_rules_scala//scala/private:phases/phase_scalafmt.bzl", _phase_scalafmt = "phase_scalafmt") load("@io_bazel_rules_scala//scala/private:phases/phase_test_environment.bzl", _phase_test_environment = "phase_test_environment") - load("@io_bazel_rules_scala//scala/private:phases/phase_semanticdb.bzl", _phase_semanticdb = "phase_semanticdb") # API diff --git a/scala/private/rules/scala_library.bzl b/scala/private/rules/scala_library.bzl index f6de92b4e..8ba761e45 100644 --- a/scala/private/rules/scala_library.bzl +++ b/scala/private/rules/scala_library.bzl @@ -34,8 +34,8 @@ load( "phase_runfiles_library", "phase_scalac_provider", "phase_scalacopts", - "phase_write_manifest", "phase_semanticdb", + "phase_write_manifest", "run_phases", ) diff --git a/twitter_scrooge/twitter_scrooge.bzl b/twitter_scrooge/twitter_scrooge.bzl index e95e4b826..38540c139 100644 --- a/twitter_scrooge/twitter_scrooge.bzl +++ b/twitter_scrooge/twitter_scrooge.bzl @@ -285,7 +285,7 @@ def _compile_generated_scala( scalac = ctx.executable._scalac, dependency_info = legacy_unclear_dependency_info_for_protobuf_scrooge(ctx), unused_dependency_checker_ignored_targets = [], - semanticdb_enabled = False + semanticdb_enabled = False, ) return _create_java_info_provider(scrooge_jar, all_deps, output) From d7211349eb2e7fc820a97298d78c536ee697813a Mon Sep 17 00:00:00 2001 From: crt-31 Date: Fri, 4 Aug 2023 18:19:56 -0700 Subject: [PATCH 35/36] Semanticdb to use phase, and other improvements --- WORKSPACE | 4 - docs/scala_toolchain.md | 24 ++- .../semanticdb_scala3 => semanticdb}/BUILD | 10 +- examples/semanticdb/Foo.scala | 3 + examples/semanticdb/Main.scala | 7 + examples/semanticdb/README.md | 13 ++ .../WORKSPACE | 20 ++- examples/semanticdb/aspect.bzl | 24 +++ .../multi_frameworks_toolchain/WORKSPACE | 4 - .../testing/scalatest_repositories/WORKSPACE | 4 - examples/testing/semanticdb_scala3/Foo.scala | 3 - examples/testing/semanticdb_scala3/Main.scala | 4 - .../specs2_junit_repositories/WORKSPACE | 4 - scala/BUILD | 8 +- scala/private/common_attributes.bzl | 14 -- .../private/macros/setup_scala_toolchain.bzl | 28 ++-- scala/private/phases/phase_compile.bzl | 20 ++- scala/private/phases/phase_semanticdb.bzl | 85 ++++++++-- scala/private/rule_impls.bzl | 10 +- scala/private/rules/scala_library.bzl | 2 +- scala/private/toolchain_deps/BUILD | 4 +- scala/scala_toolchain.bzl | 7 +- scala/semanticdb/BUILD | 0 scala/semanticdb/semanticdb_repositories.bzl | 15 -- scala/semanticdb_provider.bzl | 8 + scala_proto/private/scala_proto_aspect.bzl | 2 +- .../bazel/rulesscala/scalac/ScalacWorker.java | 18 +-- .../rulesscala/scalac/ScalacWorker3.java | 4 - .../scalac/compileoptions/CompileOptions.java | 25 +-- test/semanticdb/BUILD | 39 ++++- test/semanticdb/rules.bzl | 35 +++++ .../semantic_provider_vars.sh.template | 5 + test/shell/test_examples.sh | 21 +-- test/shell/test_semanticdb.sh | 146 ++++++++++++++++-- test_version/WORKSPACE.template | 4 - third_party/repositories/scala_2_11.bzl | 7 +- third_party/repositories/scala_2_12.bzl | 7 +- third_party/repositories/scala_2_13.bzl | 7 +- twitter_scrooge/BUILD | 7 - twitter_scrooge/twitter_scrooge.bzl | 2 +- 40 files changed, 452 insertions(+), 202 deletions(-) rename examples/{testing/semanticdb_scala3 => semanticdb}/BUILD (77%) create mode 100644 examples/semanticdb/Foo.scala create mode 100644 examples/semanticdb/Main.scala create mode 100644 examples/semanticdb/README.md rename examples/{testing/semanticdb_scala3 => semanticdb}/WORKSPACE (52%) create mode 100644 examples/semanticdb/aspect.bzl delete mode 100644 examples/testing/semanticdb_scala3/Foo.scala delete mode 100644 examples/testing/semanticdb_scala3/Main.scala delete mode 100644 scala/semanticdb/BUILD delete mode 100644 scala/semanticdb/semanticdb_repositories.bzl create mode 100644 scala/semanticdb_provider.bzl create mode 100644 test/semanticdb/rules.bzl create mode 100644 test/semanticdb/semantic_provider_vars.sh.template diff --git a/WORKSPACE b/WORKSPACE index b83f0b283..b931f346d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -28,10 +28,6 @@ load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config") scala_config(enable_compiler_dependency_tracking = True) -load("//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") - -semanticdb_repositories() - load("//scala:scala.bzl", "rules_scala_setup", "rules_scala_toolchain_deps_repositories") rules_scala_setup() diff --git a/docs/scala_toolchain.md b/docs/scala_toolchain.md index e7eb74f3e..2d5e785c8 100644 --- a/docs/scala_toolchain.md +++ b/docs/scala_toolchain.md @@ -79,7 +79,8 @@ scala_register_toolchains() Allows to configure dependencies lists by configuring DepInfo provider targets. Currently supported dep ids: scala_compile_classpath, scala_library_classpath, scala_macro_classpath, scala_xml, - parser_combinators. + parser_combinators + scala_semanticdb

@@ -143,6 +144,27 @@ scala_register_toolchains() List of target prefixes included for unused deps analysis. Exclude patetrns with '-'

+ + + enable_semanticdb + +

Boolean; optional (default False)

+

+ Enables semanticdb output. +

+ + + + semanticdb_bundle_in_jar + +

Boolean; optional (default False)

+

+ When False, *.semanticdb files are added to the filesystem in a directory. +

+

+ When True, *.semanticdb files will be bundled inside the jar file. +

+ diff --git a/examples/testing/semanticdb_scala3/BUILD b/examples/semanticdb/BUILD similarity index 77% rename from examples/testing/semanticdb_scala3/BUILD rename to examples/semanticdb/BUILD index e89ceb35b..281107111 100644 --- a/examples/testing/semanticdb_scala3/BUILD +++ b/examples/semanticdb/BUILD @@ -4,6 +4,7 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary", "scala_library") scala_toolchain( name = "semanticdb_toolchain_impl", enable_semanticdb = True, + semanticdb_bundle_in_jar = False, visibility = ["//visibility:public"], ) @@ -15,12 +16,13 @@ toolchain( ) scala_library( - name = "all", - srcs = glob(["**/*.scala"]), + name = "hello_lib", + srcs = ["Foo.scala"], ) scala_binary( - name = "run", + name = "hello", + srcs = ["Main.scala"], main_class = "main", - deps = [":all"], + deps = [":hello_lib"], ) diff --git a/examples/semanticdb/Foo.scala b/examples/semanticdb/Foo.scala new file mode 100644 index 000000000..222e82e0e --- /dev/null +++ b/examples/semanticdb/Foo.scala @@ -0,0 +1,3 @@ +class Foo(){ + def sayHello: String = "Hello!!" +} diff --git a/examples/semanticdb/Main.scala b/examples/semanticdb/Main.scala new file mode 100644 index 000000000..0ea328a25 --- /dev/null +++ b/examples/semanticdb/Main.scala @@ -0,0 +1,7 @@ + +object main{ + def main(args: Array[String]): Unit = { + val foo = new Foo() + println(foo.sayHello) + } +} \ No newline at end of file diff --git a/examples/semanticdb/README.md b/examples/semanticdb/README.md new file mode 100644 index 000000000..8aa4301e7 --- /dev/null +++ b/examples/semanticdb/README.md @@ -0,0 +1,13 @@ +# scala_rules Semanticdb example + +This example demonstrates using an aspect to access the semanticdb info for one or more targets. In this example, an aspect is used to generate a json file that contains the semanticdb info that could be consumed by a consumer such as an IDE. + +In this example, note that a scala_toolchain with enable_semanticdb=True is setup in the BUILD file. + +This command can be used to run the aspect (and not run the full build) + +``` +bazel build //... --aspects aspect.bzl%semanticdb_info_aspect --output_groups=json_output_file +``` + +The semanticdb_info.json file will be created for each target, and contains the semanticdb info for the target. \ No newline at end of file diff --git a/examples/testing/semanticdb_scala3/WORKSPACE b/examples/semanticdb/WORKSPACE similarity index 52% rename from examples/testing/semanticdb_scala3/WORKSPACE rename to examples/semanticdb/WORKSPACE index 6ccd1cf5c..1d1fde5e9 100644 --- a/examples/testing/semanticdb_scala3/WORKSPACE +++ b/examples/semanticdb/WORKSPACE @@ -2,23 +2,26 @@ workspace(name = "specs2_junit_repositories") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -skylib_version = "1.0.3" +skylib_version = "1.4.1" http_archive( name = "bazel_skylib", - sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", + sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7", type = "tar.gz", - url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version), + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version), + "https://github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version), + ], ) local_repository( name = "io_bazel_rules_scala", - path = "../../..", + path = "../..", ) load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config") -scala_config(scala_version = "3.1.0") +scala_config(scala_version = "2.13.6") load( "@io_bazel_rules_scala//scala:scala.bzl", @@ -36,6 +39,7 @@ rules_proto_dependencies() rules_proto_toolchains() -load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains") - -scala_register_toolchains() +#Register and use the custom toolchain that has semanticdb enabled +register_toolchains( + "//:semanticdb_toolchain", +) diff --git a/examples/semanticdb/aspect.bzl b/examples/semanticdb/aspect.bzl new file mode 100644 index 000000000..c8d6f9496 --- /dev/null +++ b/examples/semanticdb/aspect.bzl @@ -0,0 +1,24 @@ +#This aspect is an example of exposing semanticdb information for each target into a json file. +# An IDE could use a json file like this to consume the semanticdb data for each target. + +load("@io_bazel_rules_scala//scala:semanticdb_provider.bzl", "SemanticdbInfo") + +def semanticdb_info_aspect_impl(target, ctx): + if SemanticdbInfo in ctx.attr.dep: + output_struct = struct( + target_label = str(target.label), + semanticdb_target_root = target[SemanticdbInfo].target_root, + semanticdb_pluginjar = target[SemanticdbInfo].plugin_jar, + ) + + json_output_file = ctx.actions.declare_file("%s_semanticdb_info.json" % target.label.name) + ctx.actions.write(json_output_file, json.encode_indent(output_struct)) + + return [OutputGroupInfo(json_output_file = depset([json_output_file]))] + return None + +semanticdb_info_aspect = aspect( + implementation = semanticdb_info_aspect_impl, + attr_aspects = ["deps"], + toolchains = ["@io_bazel_rules_scala//scala:toolchain_type"], +) diff --git a/examples/testing/multi_frameworks_toolchain/WORKSPACE b/examples/testing/multi_frameworks_toolchain/WORKSPACE index ebc0d170c..ea4eb2f35 100644 --- a/examples/testing/multi_frameworks_toolchain/WORKSPACE +++ b/examples/testing/multi_frameworks_toolchain/WORKSPACE @@ -51,7 +51,3 @@ junit_repositories() specs2_junit_repositories() register_toolchains(":testing_toolchain") - -load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") - -semanticdb_repositories() diff --git a/examples/testing/scalatest_repositories/WORKSPACE b/examples/testing/scalatest_repositories/WORKSPACE index 4ea3ba0b3..546f9e00b 100644 --- a/examples/testing/scalatest_repositories/WORKSPACE +++ b/examples/testing/scalatest_repositories/WORKSPACE @@ -45,7 +45,3 @@ load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", " scalatest_repositories() scalatest_toolchain() - -load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") - -semanticdb_repositories() diff --git a/examples/testing/semanticdb_scala3/Foo.scala b/examples/testing/semanticdb_scala3/Foo.scala deleted file mode 100644 index e246581ab..000000000 --- a/examples/testing/semanticdb_scala3/Foo.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Foo: - def sayHello: String = "Hello from Scala 3!!" - diff --git a/examples/testing/semanticdb_scala3/Main.scala b/examples/testing/semanticdb_scala3/Main.scala deleted file mode 100644 index c1af540be..000000000 --- a/examples/testing/semanticdb_scala3/Main.scala +++ /dev/null @@ -1,4 +0,0 @@ - -@main def main: Unit = - val foo = new Foo() - println(foo.sayHello) \ No newline at end of file diff --git a/examples/testing/specs2_junit_repositories/WORKSPACE b/examples/testing/specs2_junit_repositories/WORKSPACE index d2f4ed407..3d67bf00d 100644 --- a/examples/testing/specs2_junit_repositories/WORKSPACE +++ b/examples/testing/specs2_junit_repositories/WORKSPACE @@ -45,7 +45,3 @@ load("@io_bazel_rules_scala//testing:specs2_junit.bzl", "specs2_junit_repositori specs2_junit_repositories() specs2_junit_toolchain() - -load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") - -semanticdb_repositories() diff --git a/scala/BUILD b/scala/BUILD index 1ec198e06..fdc157a18 100644 --- a/scala/BUILD +++ b/scala/BUILD @@ -34,6 +34,8 @@ _PARSER_COMBINATORS_DEPS = ["@io_bazel_rules_scala_scala_parser_combinators"] _SCALA_XML_DEPS = ["@io_bazel_rules_scala_scala_xml"] +_SCALA_SEMANTICDB_DEPS = ["@org_scalameta_semanticdb_scalac"] if SCALA_MAJOR_VERSION.startswith("2") else [] + setup_scala_toolchain( name = "default_toolchain", scala_compile_classpath = _SCALA_COMPILE_CLASSPATH_DEPS, @@ -110,8 +112,8 @@ declare_deps_provider( ) declare_deps_provider( - name = "semanticdb_scalac_provider", - deps_id = "semanticdb_scalac", + name = "scala_semanticdb_provider", + deps_id = "scala_semanticdb", visibility = ["//visibility:public"], - deps = ["@org_scalameta_semanticdb_scalac"], + deps = _SCALA_SEMANTICDB_DEPS, ) diff --git a/scala/private/common_attributes.bzl b/scala/private/common_attributes.bzl index 10a6a4920..35e21eb98 100644 --- a/scala/private/common_attributes.bzl +++ b/scala/private/common_attributes.bzl @@ -8,7 +8,6 @@ load( "@io_bazel_rules_scala//scala:plusone.bzl", _collect_plus_one_deps_aspect = "collect_plus_one_deps_aspect", ) -load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") common_attrs_for_plugin_bootstrapping = { "srcs": attr.label_list(allow_files = [ @@ -55,19 +54,6 @@ common_attrs = {} common_attrs.update(common_attrs_for_plugin_bootstrapping) -semanticdb_attrs = { - "_semanticdb_scalac_plugin": attr.label( - default = Label( - "@io_bazel_rules_scala//scala/private/toolchain_deps:semanticdb_scalac", - ), - providers = [[JavaInfo]], - mandatory = False, - ), -} if SCALA_MAJOR_VERSION.startswith("2") else {} - -common_attrs.update(semanticdb_attrs) -common_attrs_for_plugin_bootstrapping.update(semanticdb_attrs) - common_attrs.update({ "_dependency_analyzer_plugin": attr.label( default = Label( diff --git a/scala/private/macros/setup_scala_toolchain.bzl b/scala/private/macros/setup_scala_toolchain.bzl index ed226a954..d28729689 100644 --- a/scala/private/macros/setup_scala_toolchain.bzl +++ b/scala/private/macros/setup_scala_toolchain.bzl @@ -1,6 +1,5 @@ load("//scala:scala_toolchain.bzl", "scala_toolchain") load("//scala:providers.bzl", "declare_deps_provider") -load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") def setup_scala_toolchain( name, @@ -9,6 +8,8 @@ def setup_scala_toolchain( scala_macro_classpath, scala_xml_deps = None, parser_combinators_deps = None, + scala_semanticdb_dep = None, + enable_semanticdb = False, visibility = ["//visibility:public"], **kwargs): scala_xml_provider = "%s_scala_xml_provider" % name @@ -16,7 +17,7 @@ def setup_scala_toolchain( scala_compile_classpath_provider = "%s_scala_compile_classpath_provider" % name scala_library_classpath_provider = "%s_scala_library_classpath_provider" % name scala_macro_classpath_provider = "%s_scala_macro_classpath_provider" % name - semanticdb_scalac_provider = "%s_scala_semanticdb_scalac_provider" % name + scala_semanticdb_dep_provider = "%s_scala_semanticdb_dep_provider" % name declare_deps_provider( name = scala_compile_classpath_provider, @@ -59,13 +60,6 @@ def setup_scala_toolchain( else: parser_combinators_provider = "@io_bazel_rules_scala//scala:parser_combinators_provider" - declare_deps_provider( - name = semanticdb_scalac_provider, - deps_id = "semanticdb_scalac", - visibility = visibility, - deps = ["@org_scalameta_semanticdb_scalac"], - ) - dep_providers = [ scala_xml_provider, parser_combinators_provider, @@ -73,12 +67,24 @@ def setup_scala_toolchain( scala_library_classpath_provider, scala_macro_classpath_provider, ] - if SCALA_MAJOR_VERSION.startswith("2"): - dep_providers.append(semanticdb_scalac_provider) + + if enable_semanticdb == True: + if scala_semanticdb_dep != None: + declare_deps_provider( + name = scala_semanticdb_dep_provider, + deps_id = "scala_semanticdb", + deps = [scala_semanticdb_dep], + visibility = visibility, + ) + + dep_providers.append(scala_semanticdb_dep_provider) + else: + dep_providers.append("@io_bazel_rules_scala//scala:scala_semanticdb_provider") scala_toolchain( name = "%s_impl" % name, dep_providers = dep_providers, + enable_semanticdb = enable_semanticdb, visibility = visibility, **kwargs ) diff --git a/scala/private/phases/phase_compile.bzl b/scala/private/phases/phase_compile.bzl index 0b78d5d45..cacd18bad 100644 --- a/scala/private/phases/phase_compile.bzl +++ b/scala/private/phases/phase_compile.bzl @@ -129,10 +129,18 @@ def _phase_compile( jars2labels = p.collect_jars.jars2labels.jars_to_labels deps_providers = p.collect_jars.deps_providers default_classpath = p.scalac_provider.default_classpath + plugins = ctx.attr.plugins + additional_outputs = [] + scalacopts = p.scalacopts + + if (hasattr(p, "semanticdb")): + scalacopts += p.semanticdb.scalacopts + plugins = plugins + p.semanticdb.plugin + additional_outputs += p.semanticdb.outputs out = _compile_or_empty( ctx, - p.scalacopts, + scalacopts, manifest, jars, srcjars, @@ -144,7 +152,8 @@ def _phase_compile( deps_providers, default_classpath, unused_dependency_checker_ignored_targets, - p.semanticdb.enabled, + plugins, + additional_outputs, ) # TODO: simplify the return values and use provider @@ -171,7 +180,8 @@ def _compile_or_empty( deps_providers, default_classpath, unused_dependency_checker_ignored_targets, - semanticdb_enabled): + plugins, + additional_outputs): # We assume that if a srcjar is present, it is not empty if len(ctx.files.srcs) + len(srcjars.to_list()) == 0: _build_nosrc_jar(ctx) @@ -202,7 +212,7 @@ def _compile_or_empty( jars, all_srcjars, transitive_compile_jars, - ctx.attr.plugins, + plugins, ctx.attr.resource_strip_prefix, ctx.files.resources, ctx.files.resource_jars, @@ -214,7 +224,7 @@ def _compile_or_empty( ctx.executable._scalac, dependency_info, unused_dependency_checker_ignored_targets, - semanticdb_enabled, + additional_outputs, ) # build ijar if needed diff --git a/scala/private/phases/phase_semanticdb.bzl b/scala/private/phases/phase_semanticdb.bzl index 4e17a8302..ae0ebd2d7 100644 --- a/scala/private/phases/phase_semanticdb.bzl +++ b/scala/private/phases/phase_semanticdb.bzl @@ -1,13 +1,78 @@ -# -# PHASE: phase semanticdb -# -# Outputs for semanticdb when enabled in toolchain -# +load( + "@io_bazel_rules_scala//scala/private/toolchain_deps:toolchain_deps.bzl", + "find_deps_info_on", +) +load("@io_bazel_rules_scala//scala:semanticdb_provider.bzl", "SemanticdbInfo") +load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") +load("@bazel_skylib//lib:paths.bzl", "paths") + def phase_semanticdb(ctx, p): + #semanticdb_bundle_in_jar feature: enables bundling the semanticdb files within the output jar. + + #Scala 2: Uses the semanticdb compiler plugin. Will output semanticdb files into the specified 'targetroot' which defaults to be under the '_scalac/classes' dir. When targetroot is under the _scalac/classes dir scalac bundles the *.semanticdb files into the jar. + + #Scala3: Semanticdb is built into scalac. Currently, if semanticdb-target is used, the semanticdb files are written and not bundled, otherwise, the semanticdb files are not written as files and only available inside the jar. + toolchain = ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"] - enable_semanticdb = toolchain.enable_semanticdb + toolchain_type_label = "@io_bazel_rules_scala//scala:toolchain_type" + + if toolchain.enable_semanticdb == True: + scalacopts = [] + semanticdb_deps = [] + output_files = [] + plugin_jar_path = "" + + target_output_path = paths.dirname(ctx.outputs.jar.path) + + semanticdb_intpath = "_scalac/" + ctx.label.name + "/classes" if toolchain.semanticdb_bundle_in_jar == True else "semanticdb/" + ctx.label.name + + semanticdb_target_root = "%s/%s" % (target_output_path, semanticdb_intpath) + + #declare all the semanticdb files + if (not toolchain.semanticdb_bundle_in_jar): + semanticdb_outpath = "META-INF/semanticdb" + + for currSrc in ctx.files.srcs: + if currSrc.extension == "scala": + outputfilename = "%s/%s/%s.semanticdb" % (semanticdb_intpath, semanticdb_outpath, currSrc.path) + output_files.append(ctx.actions.declare_file(outputfilename)) + + if SCALA_MAJOR_VERSION.startswith("2"): + semanticdb_deps = find_deps_info_on(ctx, toolchain_type_label, "scala_semanticdb").deps + + if len(semanticdb_deps) == 0: + fail("semanticdb enabled, but semanticdb plugin jar not specified in scala_toolchain") + if len(semanticdb_deps) != 1: + fail("more than one semanticdb plugin jar was specified in scala_toolchain. Expect a single semanticdb plugin jar") + + plugin_jar_path = semanticdb_deps[0][JavaInfo].java_outputs[0].class_jar.path + + scalacopts += [ + #note: Xplugin parameter handled in scalacworker, + "-Yrangepos", + "-P:semanticdb:failures:error", + "-P:semanticdb:targetroot:" + semanticdb_target_root, + ] + else: + #Note: In Scala3, semanticdb is built-in to compiler, so no need for plugin + + scalacopts.append("-Ysemanticdb") + + if toolchain.semanticdb_bundle_in_jar == False: + scalacopts.append("-semanticdb-target:" + semanticdb_target_root) + + semanticdb_provider = SemanticdbInfo( + semanticdb_enabled = True, + target_root = None if toolchain.semanticdb_bundle_in_jar else semanticdb_target_root, + is_bundled_in_jar = toolchain.semanticdb_bundle_in_jar, + plugin_jar = plugin_jar_path, + ) + + return struct( + scalacopts = scalacopts, + plugin = semanticdb_deps, + outputs = output_files, + external_providers = {"SemanticdbInfo": semanticdb_provider}, + ) - if enable_semanticdb: - return struct(enabled = True) - else: - return struct(enabled = False) + return None diff --git a/scala/private/rule_impls.bzl b/scala/private/rule_impls.bzl index 69da612c5..3af8cab7a 100644 --- a/scala/private/rule_impls.bzl +++ b/scala/private/rule_impls.bzl @@ -17,7 +17,6 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_tools//tools/jdk:toolchain_utils.bzl", "find_java_toolchain") load(":common.bzl", "rpathlocation_from_rootpath", _collect_plugin_paths = "collect_plugin_paths") load(":resources.bzl", _resource_paths = "paths") -load("@io_bazel_rules_scala_config//:config.bzl", "SCALA_MAJOR_VERSION") def expand_location(ctx, flags): if hasattr(ctx.attr, "data"): @@ -57,7 +56,7 @@ def compile_scala( scalac, dependency_info, unused_dependency_checker_ignored_targets, - semanticdb_enabled, + additional_outputs, stamp_target_label = None): # look for any plugins: input_plugins = plugins @@ -100,11 +99,6 @@ def compile_scala( args.add_all("--ResourceJars", resource_jars) args.add_all("--ScalacOpts", scalacopts_expanded) args.add_all("--SourceJars", all_srcjars) - args.add("--EnableSemanticDb", semanticdb_enabled) - - if semanticdb_enabled and SCALA_MAJOR_VERSION.startswith("2"): - jar = [jo.class_jar.path for jo in ctx.attr._semanticdb_scalac_plugin[JavaInfo].outputs.jars][0] - args.add("--SemanticDbJar", jar) if dependency_info.need_direct_info: args.add_all("--DirectJars", cjars) @@ -119,7 +113,7 @@ def compile_scala( if dependency_info.unused_deps_mode != "off" or dependency_info.strict_deps_mode != "off": args.add_all("--UnusedDepsIgnoredTargets", unused_dependency_checker_ignored_targets) - outs = [output, statsfile, diagnosticsfile, scaladepsfile] + outs = [output, statsfile, diagnosticsfile, scaladepsfile] + additional_outputs ins = depset( direct = [manifest] + sources + classpath_resources + resources + resource_jars, diff --git a/scala/private/rules/scala_library.bzl b/scala/private/rules/scala_library.bzl index 8ba761e45..8a2909759 100644 --- a/scala/private/rules/scala_library.bzl +++ b/scala/private/rules/scala_library.bzl @@ -148,7 +148,7 @@ def _scala_library_for_plugin_bootstrapping_impl(ctx): ("dependency", phase_dependency_library_for_plugin_bootstrapping), ("collect_jars", phase_collect_jars_common), ("scalacopts", phase_scalacopts), - ("semanticdb", phase_semanticdb), + #("semanticdb", phase_semanticdb), noneed for semanticdb in bootstrap ("compile", phase_compile_library_for_plugin_bootstrapping), ("merge_jars", phase_merge_jars), ("runfiles", phase_runfiles_library), diff --git a/scala/private/toolchain_deps/BUILD b/scala/private/toolchain_deps/BUILD index 467a87765..5a2991da9 100644 --- a/scala/private/toolchain_deps/BUILD +++ b/scala/private/toolchain_deps/BUILD @@ -25,7 +25,7 @@ common_toolchain_deps( ) common_toolchain_deps( - name = "semanticdb_scalac", - deps_id = "semanticdb_scalac", + name = "scala_semanticdb", + deps_id = "scala_semanticdb", visibility = ["//visibility:public"], ) diff --git a/scala/scala_toolchain.bzl b/scala/scala_toolchain.bzl index bf675855d..4beac53ff 100644 --- a/scala/scala_toolchain.bzl +++ b/scala/scala_toolchain.bzl @@ -74,7 +74,6 @@ def _scala_toolchain_impl(ctx): enable_stats_file = ctx.attr.enable_stats_file enable_diagnostics_report = ctx.attr.enable_diagnostics_report - enable_semanticdb = ctx.attr.enable_semanticdb all_strict_deps_patterns = ctx.attr.dependency_tracking_strict_deps_patterns strict_deps_includes, strict_deps_excludes = _partition_patterns(all_strict_deps_patterns) @@ -99,7 +98,8 @@ def _scala_toolchain_impl(ctx): enable_diagnostics_report = enable_diagnostics_report, jacocorunner = ctx.attr.jacocorunner, enable_stats_file = enable_stats_file, - enable_semanticdb = enable_semanticdb, + enable_semanticdb = ctx.attr.enable_semanticdb, + semanticdb_bundle_in_jar = ctx.attr.semanticdb_bundle_in_jar, use_argument_file_in_runner = ctx.attr.use_argument_file_in_runner, ) return [toolchain] @@ -113,7 +113,7 @@ def _default_dep_providers(): "@io_bazel_rules_scala//scala:scala_macro_classpath_provider", ] if SCALA_MAJOR_VERSION.startswith("2"): - dep_providers.append("@io_bazel_rules_scala//scala:semanticdb_scalac_provider") + dep_providers.append("@io_bazel_rules_scala//scala:scala_semanticdb_provider") return dep_providers scala_toolchain = rule( @@ -168,6 +168,7 @@ scala_toolchain = rule( default = False, doc = "Enable SemanticDb", ), + "semanticdb_bundle_in_jar": attr.bool(default = False, doc = "Option to bundle the semanticdb files inside the output jar file"), "use_argument_file_in_runner": attr.bool( default = False, doc = "Changes java binaries scripts (including tests) to use argument files and not classpath jars to improve performance, requires java > 8", diff --git a/scala/semanticdb/BUILD b/scala/semanticdb/BUILD deleted file mode 100644 index e69de29bb..000000000 diff --git a/scala/semanticdb/semanticdb_repositories.bzl b/scala/semanticdb/semanticdb_repositories.bzl deleted file mode 100644 index bfe1141c7..000000000 --- a/scala/semanticdb/semanticdb_repositories.bzl +++ /dev/null @@ -1,15 +0,0 @@ -load( - "//scala:scala_cross_version.bzl", - _default_maven_server_urls = "default_maven_server_urls", -) -load("//third_party/repositories:repositories.bzl", "repositories") - -def semanticdb_repositories( - maven_servers = _default_maven_server_urls(), - overriden_artifacts = {}): - repositories( - for_artifact_ids = ["org_scalameta_semanticdb_scalac"], - maven_servers = maven_servers, - fetch_sources = False, - overriden_artifacts = overriden_artifacts, - ) diff --git a/scala/semanticdb_provider.bzl b/scala/semanticdb_provider.bzl new file mode 100644 index 000000000..6b1ecfc0b --- /dev/null +++ b/scala/semanticdb_provider.bzl @@ -0,0 +1,8 @@ +SemanticdbInfo = provider( + fields = { + "semanticdb_enabled": "boolean", + "target_root": "directory containing the semanticdb files (relative to execroot).", + "is_bundled_in_jar": "boolean: whether the semanticdb files are bundled inside the jar", + "plugin_jar": "path to semanticdb plugin jar (relative to execroot)", + }, +) diff --git a/scala_proto/private/scala_proto_aspect.bzl b/scala_proto/private/scala_proto_aspect.bzl index 592495edd..9832a75f3 100644 --- a/scala_proto/private/scala_proto_aspect.bzl +++ b/scala_proto/private/scala_proto_aspect.bzl @@ -121,8 +121,8 @@ def _compile_sources(ctx, toolchain, proto, src_jars, deps, scalacopts, stamp_la scalac = toolchain.scalac, dependency_info = legacy_unclear_dependency_info_for_protobuf_scrooge(ctx), unused_dependency_checker_ignored_targets = [], - semanticdb_enabled = False, stamp_target_label = stamp_label, + additional_outputs = [], ) return JavaInfo( diff --git a/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java b/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java index 12ff71710..149833cf8 100644 --- a/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java +++ b/src/java/io/bazel/rulesscala/scalac/ScalacWorker.java @@ -243,17 +243,6 @@ private static String[] getPluginParamsFrom(CompileOptions ops) { "-P:dependency-analyzer:unused-deps-ignored-targets:" + String.join(":", ignoredTargets)); } - } - - if (ops.enableSemanticDb) { - - String[] params = { - "-Yrangepos", - "-P:semanticdb:failures:error", - "-Xplugin-require:semanticdb" - }; - - pluginParams.addAll(Arrays.asList(params)); } return pluginParams.toArray(new String[pluginParams.size()]); @@ -271,12 +260,7 @@ private static boolean isMacroException(Throwable ex) { private static void compileScalaSources(CompileOptions ops, String[] scalaSources, Path classes) throws IOException, Exception { - List plugins = new ArrayList(Arrays.asList(ops.plugins)); - if (ops.enableSemanticDb) { - plugins.add(ops.semanticDbJar.get()); - } - - String[] pluginArgs = buildPluginArgs(plugins.toArray(new String[0])); + String[] pluginArgs = buildPluginArgs(ops.plugins); String[] pluginParams = getPluginParamsFrom(ops); String[] constParams = { diff --git a/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java b/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java index 9630872f8..82112771c 100644 --- a/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java +++ b/src/java/io/bazel/rulesscala/scalac/ScalacWorker3.java @@ -241,10 +241,6 @@ private static String[] getPluginParamsFrom(CompileOptions ops) { } } - if (ops.enableSemanticDb) { - pluginParams.add("-Xsemanticdb"); - } - return pluginParams.toArray(new String[pluginParams.size()]); } diff --git a/src/java/io/bazel/rulesscala/scalac/compileoptions/CompileOptions.java b/src/java/io/bazel/rulesscala/scalac/compileoptions/CompileOptions.java index 04c4847e7..20c041b53 100644 --- a/src/java/io/bazel/rulesscala/scalac/compileoptions/CompileOptions.java +++ b/src/java/io/bazel/rulesscala/scalac/compileoptions/CompileOptions.java @@ -3,7 +3,6 @@ import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Optional; public class CompileOptions { public final String outputName; @@ -36,11 +35,7 @@ public class CompileOptions { public final String dependencyTrackingMethod; public final String diagnosticsFile; public final boolean enableDiagnosticsReport; - - public final boolean enableSemanticDb; - public final Optional semanticDbJar; public final String scalaDepsFile; - public CompileOptions(String[] lines) { Args args = new Args(lines); @@ -76,11 +71,9 @@ public CompileOptions(String[] lines) { statsfile = args.getSingleOrError("StatsfileOutput"); enableStatsFile = Boolean.parseBoolean(args.getSingleOrError("EnableStatsFile")); - enableDiagnosticsReport = Boolean.parseBoolean(args.getSingleOrError("EnableDiagnosticsReport")); + enableDiagnosticsReport = + Boolean.parseBoolean(args.getSingleOrError("EnableDiagnosticsReport")); diagnosticsFile = args.getSingleOrError("DiagnosticsFile"); - - enableSemanticDb = Boolean.parseBoolean(args.getSingleOrError("EnableSemanticDb")); - semanticDbJar = args.getSingleOptional("SemanticDbJar"); scalaDepsFile = args.getSingleOrError("ScalaDepsFile"); } @@ -104,27 +97,17 @@ String[] getOrEmpty(String k) { } String getSingleOrError(String k) { - Optional opt = getSingleOptional(k); - if (opt.isPresent()) { - return opt.get(); - } else { - throw new RuntimeException("Missing required arg " + k); - } - } - - Optional getSingleOptional(String k) { if (index.containsKey(k)) { String[] v = index.get(k); if (v.length == 1) { - return Optional.of(v[0]); + return v[0]; } else { throw new RuntimeException( k + " expected to contain single value but got " + Arrays.toString(v)); } } else { - return Optional.empty(); + throw new RuntimeException("Missing required arg " + k); } } - } } diff --git a/test/semanticdb/BUILD b/test/semanticdb/BUILD index f3b51b7f8..5cec87149 100644 --- a/test/semanticdb/BUILD +++ b/test/semanticdb/BUILD @@ -1,20 +1,51 @@ load("//scala:scala_toolchain.bzl", "scala_toolchain") load("//scala:scala.bzl", "scala_library") +load("//test/semanticdb:rules.bzl", "semanticdb_vars_script") scala_toolchain( - name = "semanticdb_toolchain_impl", + name = "semanticdb_bundle_toolchain_impl", enable_semanticdb = True, + semanticdb_bundle_in_jar = True, visibility = ["//visibility:public"], ) toolchain( - name = "semanticdb_toolchain", - toolchain = "semanticdb_toolchain_impl", + name = "semanticdb_bundle_toolchain", + toolchain = "semanticdb_bundle_toolchain_impl", + toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", + visibility = ["//visibility:public"], +) + +scala_toolchain( + name = "semanticdb_nobundle_toolchain_impl", + enable_semanticdb = True, + semanticdb_bundle_in_jar = False, + visibility = ["//visibility:public"], +) + +toolchain( + name = "semanticdb_nobundle_toolchain", + toolchain = "semanticdb_nobundle_toolchain_impl", toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type", visibility = ["//visibility:public"], ) scala_library( - name = "all", + name = "all_lib", srcs = glob(["**/*.scala"]), ) + +semanticdb_vars_script( + name = "semantic_provider_vars_all", + dep = "all_lib", +) + +scala_library( + name = "empty_lib", + srcs = [], +) + +semanticdb_vars_script( + name = "semantic_provider_vars_empty", + dep = "empty_lib", +) diff --git a/test/semanticdb/rules.bzl b/test/semanticdb/rules.bzl new file mode 100644 index 000000000..50ff80d2c --- /dev/null +++ b/test/semanticdb/rules.bzl @@ -0,0 +1,35 @@ +load("//scala:semanticdb_provider.bzl", "SemanticdbInfo") + +def semanticdb_vars_script_impl(ctx): + if SemanticdbInfo in ctx.attr.dep: + out_script = ctx.actions.declare_file("%s.sh" % ctx.label.name) + semanticdb_info = ctx.attr.dep[SemanticdbInfo] + + ctx.actions.expand_template( + output = out_script, + template = ctx.file._script, + substitutions = { + "%TARGETROOT%": "" if semanticdb_info.target_root == None else semanticdb_info.target_root, + "%ENABLED%": "1" if semanticdb_info.semanticdb_enabled else "0", + "%ISBUNDLED%": "1" if semanticdb_info.is_bundled_in_jar else "0", + "%PLUGINPATH%": semanticdb_info.plugin_jar, + }, + ) + return [ + DefaultInfo(files = depset( + [out_script], + transitive = [ctx.attr.dep[DefaultInfo].files], + )), + ] + return None + +semanticdb_vars_script = rule( + implementation = semanticdb_vars_script_impl, + attrs = { + "dep": attr.label(mandatory = True), + "_script": attr.label( + allow_single_file = True, + default = "semantic_provider_vars.sh.template", + ), + }, +) diff --git a/test/semanticdb/semantic_provider_vars.sh.template b/test/semanticdb/semantic_provider_vars.sh.template new file mode 100644 index 000000000..e8602c506 --- /dev/null +++ b/test/semanticdb/semantic_provider_vars.sh.template @@ -0,0 +1,5 @@ +#!/bin/bash +semanticdb_target_root="%TARGETROOT%" +semanticdb_enabled=%ENABLED% +semanticdb_is_bundled=%ISBUNDLED% +semanticdb_pluginjarpath="%PLUGINPATH%" \ No newline at end of file diff --git a/test/shell/test_examples.sh b/test/shell/test_examples.sh index 3194cd011..e8b7078f8 100755 --- a/test/shell/test_examples.sh +++ b/test/shell/test_examples.sh @@ -28,25 +28,18 @@ function scala3_3_example() { (cd examples/scala3; bazel build --repo_env=SCALA_VERSION=3.3.0 //...) } -function test_produces_semanticdb_scala3() { - # NB: In subshell, so "cd" doesn't change local CWD - ( - cd examples/testing/semanticdb_scala3 - bazel run --extra_toolchains=//:semanticdb_toolchain //:run - - local JAR="$(bazel info bazel-bin)/all.jar" - - if ! jar_contains_files $JAR "Foo.scala.semanticdb" "Main.scala.semanticdb"; then - echo "SemanticDB output not included in jar $JAR" - exit 1 - fi +function semanticdb_example() { + ( cd examples/semanticdb; + bazel build //... --aspects aspect.bzl%semanticdb_info_aspect --output_groups=json_output_file; + bazel build //... ) } + $runner scalatest_repositories_example $runner specs2_junit_repositories_example $runner multi_framework_toolchain_example +$runner semanticdb_example $runner scala3_1_example $runner scala3_2_example -$runner scala3_3_example -$runner test_produces_semanticdb_scala3 \ No newline at end of file +$runner scala3_3_example \ No newline at end of file diff --git a/test/shell/test_semanticdb.sh b/test/shell/test_semanticdb.sh index 1ca5dda1f..6ee5f095e 100755 --- a/test/shell/test_semanticdb.sh +++ b/test/shell/test_semanticdb.sh @@ -7,31 +7,147 @@ runner=$(get_test_runner "${1:-local}") FILES=("A.scala.semanticdb" "B.scala.semanticdb") -test_produces_semanticdb() { - bazel build \ - --extra_toolchains=//test/semanticdb:semanticdb_toolchain \ - //test/semanticdb/... +jar_contains_files() { + for arg in "${@:2}" + do + if ! jar tf $1 | grep $arg; then + return 1 + fi + done +} + +test_produces_semanticdb(){ + set -e + + local scala_majver=$1 + local is_bundle=$2 - local JAR="$(bazel info bazel-bin)/test/semanticdb/all.jar" - if ! jar_contains_files $JAR "${FILES[@]}"; then - echo "SemanticDB output not included in jar $JAR" + if [ $is_bundle -eq 1 ]; then + local toolchain="--extra_toolchains=//test/semanticdb:semanticdb_bundle_toolchain" + else + local toolchain="--extra_toolchains=//test/semanticdb:semanticdb_nobundle_toolchain" + fi + + if [ $scala_majver -eq 3 ]; then + local version_opt="--repo_env=SCALA_VERSION=3.3.0" + fi + + + bazel build //test/semanticdb:semantic_provider_vars_all ${toolchain} ${version_opt} + + #semantic_provider_vars.sh contains the SemanticdbInfo data + . $(bazel info bazel-bin)/test/semanticdb/semantic_provider_vars_all.sh + + #Check the Provider variables + if [ $semanticdb_enabled -ne 1 ]; then + echo "Error: SemanticdbInfo.semanticdb_enabled not equal to true" exit 1 fi + + + if [ $semanticdb_is_bundled -ne $is_bundle ]; then + echo "Error: SemanticdbInfo.is_bundled_in_jar is incorrect." + exit 1 + fi + + if [ $is_bundle -eq 0 ]; then + if [[ $semanticdb_target_root == "" ]]; then + echo "Error: SemanticdbInfo.target_root expected to have a value" + exit 1 + fi + else + if [[ $semanticdb_target_root != "" ]]; then + echo "Error: SemanticdbInfo.target_root expected to be empty string" + exit 1 + fi + fi + + if [[ $scala_majver == 3 ]] && [[ $semanticdb_pluginjarpath != "" ]]; then + echo "Error: SemanticdbInfo.pluginjarpath expected to be empty for scala 3" + exit 1 + fi + if [[ $scala_majver == 2 ]] && [[ $semanticdb_pluginjarpath == "" ]]; then + echo "Error: SemanticdbInfo.pluginjarpath expected to be set for scala 2" + exit 1 + fi + + if [ $is_bundle -eq 0 ]; then + + semanticdb_path="$(bazel info execution_root)/${semanticdb_target_root}/META-INF/semanticdb/test/semanticdb/" + + for arg in $FILES + do + if ! [ -f "${semanticdb_path}${arg}" ]; then + echo "Error: Expected Semanticdb file not found: ${semanticdb_path}${arg}" + exit 1; + + fi + done + fi + + local JAR="$(bazel info bazel-bin)/test/semanticdb/all_lib.jar" + + if [ $is_bundle -eq 0 ]; then + if jar_contains_files $JAR $FILES; then + echo "Error: SemanticDB output erroneously included in jar: $JAR" + exit 1 + fi + else + if ! jar_contains_files $JAR $FILES; then + echo "Error: SemanticDB output not included in jar: $JAR" + exit 1 + fi + fi +} + +test_empty_semanticdb(){ + #just make sure this special case of semanticdb with no source files builds fine + + set -e + + bazel build //test/semanticdb:semantic_provider_vars_empty --extra_toolchains=//test/semanticdb:semanticdb_nobundle_toolchain } test_no_semanticdb() { - bazel clean - bazel build \ - //test/semanticdb/... + #verify no semanticdb files have been generated in the bin dir or bundled in the jar + + set -e + + local jar="$(bazel info bazel-bin)/test/semanticdb/all_lib.jar" + local targetout_path="$(bazel info bazel-bin)/test/semanticdb" - local JAR="$(bazel info bazel-bin)/test/semanticdb/all.jar" + rm -rf $targetout_path #clean out the output dir for clean slate - if jar_contains_files $JAR "${FILES[@]}"; then - echo "SemanticDB included in jar $JAR, but wasn't expected to be" + #bazel clean + bazel build //test/semanticdb:all_lib + + #there should be no *.semanticdb files under the target's output dir + if [ $( find $targetout_path -type f -name *.semanticdb | wc -l ) -gt 0 ] ; then + echo "Error: Semanticdb files erroneously found in target output" exit 1 fi + + if jar_contains_files $jar "${FILES[@]}"; then + echo "Error: Semanticdb included in jar $JAR, but wasn't expected to be" + exit 1 + fi +} + +run_semanticdb_tests() { + local bundle=1; local nobundle=0 + local scala3=3; local scala2=2 + + $runner test_produces_semanticdb $scala2 $bundle + $runner test_produces_semanticdb $scala2 $nobundle + + $runner test_empty_semanticdb + + $runner test_produces_semanticdb $scala3 $bundle + $runner test_produces_semanticdb $scala3 $nobundle + + $runner test_no_semanticdb + } -$runner test_produces_semanticdb -$runner test_no_semanticdb \ No newline at end of file +run_semanticdb_tests diff --git a/test_version/WORKSPACE.template b/test_version/WORKSPACE.template index da2e30d87..34c499f2f 100644 --- a/test_version/WORKSPACE.template +++ b/test_version/WORKSPACE.template @@ -68,7 +68,3 @@ register_toolchains("@io_bazel_rules_scala//testing:testing_toolchain") load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_unused_deps_toolchains") scala_register_unused_deps_toolchains() - -load("@io_bazel_rules_scala//scala/semanticdb:semanticdb_repositories.bzl", "semanticdb_repositories") - -semanticdb_repositories() \ No newline at end of file diff --git a/third_party/repositories/scala_2_11.bzl b/third_party/repositories/scala_2_11.bzl index 956299818..4c8492092 100644 --- a/third_party/repositories/scala_2_11.bzl +++ b/third_party/repositories/scala_2_11.bzl @@ -78,8 +78,11 @@ artifacts = { ], }, "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.11.12:4.7.3", - "sha256": "0db52fc6639f73b15c3fb9fc1cb441704399f0d8dee8352ca1cf359630e7ca0f", + "artifact": "org.scalameta:semanticdb-scalac_%s:4.8.6" % scala_version, + "sha256": "1253abd1e8c8b3ec0720995d378846bbc439d168e7ea815fe91da6bef8b1de9d", + "deps": [ + "@io_bazel_rules_scala_scala_library", + ], }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.11:1.0.1", diff --git a/third_party/repositories/scala_2_12.bzl b/third_party/repositories/scala_2_12.bzl index 98c61b9c6..e5f8ae48d 100644 --- a/third_party/repositories/scala_2_12.bzl +++ b/third_party/repositories/scala_2_12.bzl @@ -78,8 +78,11 @@ artifacts = { ], }, "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.12.14:4.7.3", - "sha256": "e5e31e1b48aedd3c7c2c2731d5053fd3429a3b37f076d95e8214acfa551c226a", + "artifact": "org.scalameta:semanticdb-scalac_%s:4.8.4" % scala_version, + "sha256": "f31614cd13b6dc5c97804aa814b6f7ad4d67124290c08d0c9296b53e46d744e0", + "deps": [ + "@io_bazel_rules_scala_scala_library", + ], }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.12:1.0.1", diff --git a/third_party/repositories/scala_2_13.bzl b/third_party/repositories/scala_2_13.bzl index df4bcf62d..5279c44ef 100644 --- a/third_party/repositories/scala_2_13.bzl +++ b/third_party/repositories/scala_2_13.bzl @@ -82,8 +82,11 @@ artifacts = { ], }, "org_scalameta_semanticdb_scalac": { - "artifact": "org.scalameta:semanticdb-scalac_2.13.6:4.7.3", - "sha256": "fbc7703b3ac407a4695d6055197cf9ea520260e0757dec488992b498a86ed656", + "artifact": "org.scalameta:semanticdb-scalac_%s:4.8.4" % scala_version, + "sha256": "acc1f667d4e98b42ba851309feb391cf301afeeeeddb8c172874a2184b18b057", + "deps": [ + "@io_bazel_rules_scala_scala_library", + ], }, "org_scalameta_fastparse": { "artifact": "org.scalameta:fastparse_2.13:1.0.1", diff --git a/twitter_scrooge/BUILD b/twitter_scrooge/BUILD index 9afed8288..f65df7c15 100644 --- a/twitter_scrooge/BUILD +++ b/twitter_scrooge/BUILD @@ -13,13 +13,6 @@ toolchain( visibility = ["//visibility:public"], ) -declare_deps_provider( - name = "semanticdb_scalac_provider", - deps_id = "semanticdb_scalac", - visibility = ["//visibility:public"], - deps = ["@org_scalameta_semanticdb_scalac"], -) - declare_deps_provider( name = "aspect_compile_classpath_provider", deps_id = "aspect_compile_classpath", diff --git a/twitter_scrooge/twitter_scrooge.bzl b/twitter_scrooge/twitter_scrooge.bzl index 38540c139..6dc61850a 100644 --- a/twitter_scrooge/twitter_scrooge.bzl +++ b/twitter_scrooge/twitter_scrooge.bzl @@ -285,7 +285,7 @@ def _compile_generated_scala( scalac = ctx.executable._scalac, dependency_info = legacy_unclear_dependency_info_for_protobuf_scrooge(ctx), unused_dependency_checker_ignored_targets = [], - semanticdb_enabled = False, + additional_outputs = [], ) return _create_java_info_provider(scrooge_jar, all_deps, output) From fe7111f229dcc8a505437b7dba9a7148e8c11b3e Mon Sep 17 00:00:00 2001 From: crt-31 Date: Tue, 12 Sep 2023 18:15:09 -0700 Subject: [PATCH 36/36] semanticdb: addressed pr review comments - fixed semanticdb example - added prefix '_' to semanticdb output path - renamed certain vars to not prepend with "scala_" - changed depsprovider var name to be plural instead of singular --- docs/scala_toolchain.md | 4 ++-- examples/semanticdb/aspect.bzl | 4 ++-- scala/BUILD | 8 ++++---- scala/private/macros/setup_scala_toolchain.bzl | 16 ++++++++-------- scala/private/phases/phase_semanticdb.bzl | 4 ++-- scala/private/toolchain_deps/BUILD | 4 ++-- scala/scala_toolchain.bzl | 2 +- test/shell/test_examples.sh | 2 +- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/scala_toolchain.md b/docs/scala_toolchain.md index 2d5e785c8..924e2bfed 100644 --- a/docs/scala_toolchain.md +++ b/docs/scala_toolchain.md @@ -79,8 +79,8 @@ scala_register_toolchains() Allows to configure dependencies lists by configuring DepInfo provider targets. Currently supported dep ids: scala_compile_classpath, scala_library_classpath, scala_macro_classpath, scala_xml, - parser_combinators - scala_semanticdb + parser_combinators, + semanticdb

diff --git a/examples/semanticdb/aspect.bzl b/examples/semanticdb/aspect.bzl index c8d6f9496..a03807ecd 100644 --- a/examples/semanticdb/aspect.bzl +++ b/examples/semanticdb/aspect.bzl @@ -4,7 +4,7 @@ load("@io_bazel_rules_scala//scala:semanticdb_provider.bzl", "SemanticdbInfo") def semanticdb_info_aspect_impl(target, ctx): - if SemanticdbInfo in ctx.attr.dep: + if SemanticdbInfo in target: output_struct = struct( target_label = str(target.label), semanticdb_target_root = target[SemanticdbInfo].target_root, @@ -15,7 +15,7 @@ def semanticdb_info_aspect_impl(target, ctx): ctx.actions.write(json_output_file, json.encode_indent(output_struct)) return [OutputGroupInfo(json_output_file = depset([json_output_file]))] - return None + return [] semanticdb_info_aspect = aspect( implementation = semanticdb_info_aspect_impl, diff --git a/scala/BUILD b/scala/BUILD index fdc157a18..82f1180f4 100644 --- a/scala/BUILD +++ b/scala/BUILD @@ -34,7 +34,7 @@ _PARSER_COMBINATORS_DEPS = ["@io_bazel_rules_scala_scala_parser_combinators"] _SCALA_XML_DEPS = ["@io_bazel_rules_scala_scala_xml"] -_SCALA_SEMANTICDB_DEPS = ["@org_scalameta_semanticdb_scalac"] if SCALA_MAJOR_VERSION.startswith("2") else [] +_SEMANTICDB_DEPS = ["@org_scalameta_semanticdb_scalac"] if SCALA_MAJOR_VERSION.startswith("2") else [] setup_scala_toolchain( name = "default_toolchain", @@ -112,8 +112,8 @@ declare_deps_provider( ) declare_deps_provider( - name = "scala_semanticdb_provider", - deps_id = "scala_semanticdb", + name = "semanticdb_provider", + deps_id = "semanticdb", visibility = ["//visibility:public"], - deps = _SCALA_SEMANTICDB_DEPS, + deps = _SEMANTICDB_DEPS, ) diff --git a/scala/private/macros/setup_scala_toolchain.bzl b/scala/private/macros/setup_scala_toolchain.bzl index d28729689..f8fa55d7d 100644 --- a/scala/private/macros/setup_scala_toolchain.bzl +++ b/scala/private/macros/setup_scala_toolchain.bzl @@ -8,7 +8,7 @@ def setup_scala_toolchain( scala_macro_classpath, scala_xml_deps = None, parser_combinators_deps = None, - scala_semanticdb_dep = None, + semanticdb_deps = None, enable_semanticdb = False, visibility = ["//visibility:public"], **kwargs): @@ -17,7 +17,7 @@ def setup_scala_toolchain( scala_compile_classpath_provider = "%s_scala_compile_classpath_provider" % name scala_library_classpath_provider = "%s_scala_library_classpath_provider" % name scala_macro_classpath_provider = "%s_scala_macro_classpath_provider" % name - scala_semanticdb_dep_provider = "%s_scala_semanticdb_dep_provider" % name + semanticdb_deps_provider = "%s_semanticdb_deps_provider" % name declare_deps_provider( name = scala_compile_classpath_provider, @@ -69,17 +69,17 @@ def setup_scala_toolchain( ] if enable_semanticdb == True: - if scala_semanticdb_dep != None: + if semanticdb_deps != None: declare_deps_provider( - name = scala_semanticdb_dep_provider, - deps_id = "scala_semanticdb", - deps = [scala_semanticdb_dep], + name = semanticdb_deps_provider, + deps_id = "semanticdb", + deps = [semanticdb_deps], visibility = visibility, ) - dep_providers.append(scala_semanticdb_dep_provider) + dep_providers.append(semanticdb_deps_provider) else: - dep_providers.append("@io_bazel_rules_scala//scala:scala_semanticdb_provider") + dep_providers.append("@io_bazel_rules_scala//scala:semanticdb_provider") scala_toolchain( name = "%s_impl" % name, diff --git a/scala/private/phases/phase_semanticdb.bzl b/scala/private/phases/phase_semanticdb.bzl index ae0ebd2d7..ed7a2deba 100644 --- a/scala/private/phases/phase_semanticdb.bzl +++ b/scala/private/phases/phase_semanticdb.bzl @@ -24,7 +24,7 @@ def phase_semanticdb(ctx, p): target_output_path = paths.dirname(ctx.outputs.jar.path) - semanticdb_intpath = "_scalac/" + ctx.label.name + "/classes" if toolchain.semanticdb_bundle_in_jar == True else "semanticdb/" + ctx.label.name + semanticdb_intpath = "_scalac/" + ctx.label.name + "/classes" if toolchain.semanticdb_bundle_in_jar == True else "_semanticdb/" + ctx.label.name semanticdb_target_root = "%s/%s" % (target_output_path, semanticdb_intpath) @@ -38,7 +38,7 @@ def phase_semanticdb(ctx, p): output_files.append(ctx.actions.declare_file(outputfilename)) if SCALA_MAJOR_VERSION.startswith("2"): - semanticdb_deps = find_deps_info_on(ctx, toolchain_type_label, "scala_semanticdb").deps + semanticdb_deps = find_deps_info_on(ctx, toolchain_type_label, "semanticdb").deps if len(semanticdb_deps) == 0: fail("semanticdb enabled, but semanticdb plugin jar not specified in scala_toolchain") diff --git a/scala/private/toolchain_deps/BUILD b/scala/private/toolchain_deps/BUILD index 5a2991da9..9cca1b572 100644 --- a/scala/private/toolchain_deps/BUILD +++ b/scala/private/toolchain_deps/BUILD @@ -25,7 +25,7 @@ common_toolchain_deps( ) common_toolchain_deps( - name = "scala_semanticdb", - deps_id = "scala_semanticdb", + name = "semanticdb", + deps_id = "semanticdb", visibility = ["//visibility:public"], ) diff --git a/scala/scala_toolchain.bzl b/scala/scala_toolchain.bzl index 4beac53ff..2b7accd28 100644 --- a/scala/scala_toolchain.bzl +++ b/scala/scala_toolchain.bzl @@ -113,7 +113,7 @@ def _default_dep_providers(): "@io_bazel_rules_scala//scala:scala_macro_classpath_provider", ] if SCALA_MAJOR_VERSION.startswith("2"): - dep_providers.append("@io_bazel_rules_scala//scala:scala_semanticdb_provider") + dep_providers.append("@io_bazel_rules_scala//scala:semanticdb_provider") return dep_providers scala_toolchain = rule( diff --git a/test/shell/test_examples.sh b/test/shell/test_examples.sh index e8b7078f8..d492ea437 100755 --- a/test/shell/test_examples.sh +++ b/test/shell/test_examples.sh @@ -29,13 +29,13 @@ function scala3_3_example() { } function semanticdb_example() { + set -e ( cd examples/semanticdb; bazel build //... --aspects aspect.bzl%semanticdb_info_aspect --output_groups=json_output_file; bazel build //... ) } - $runner scalatest_repositories_example $runner specs2_junit_repositories_example $runner multi_framework_toolchain_example