diff --git a/.bazelignore b/.bazelignore index f159e245c..b2ee82139 100644 --- a/.bazelignore +++ b/.bazelignore @@ -13,6 +13,7 @@ examples/semanticdb examples/testing/multi_frameworks_toolchain examples/testing/scalatest_repositories examples/testing/specs2_junit_repositories +examples/twitter_scrooge test/proto_cross_repo_boundary/repo test_cross_build third_party/test/example_external_workspace diff --git a/README.md b/README.md index 8c10303ae..1cb04fdbb 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,9 @@ This project defines core build rules for [Scala](https://www.scala-lang.org/) t - [scala_import](./docs/scala_import.md) - [scala_doc](./docs/scala_doc.md) +See the [docs](./docs/) directory for documentation on other `rules_scala` +capabilities as well. + ## Getting started [Install Bazel][], preferably using the [Bazelisk][] wrapper. See the diff --git a/docs/twitter_scrooge.md b/docs/twitter_scrooge.md new file mode 100644 index 000000000..79ab81aaa --- /dev/null +++ b/docs/twitter_scrooge.md @@ -0,0 +1,79 @@ +# Using the `twitter_scrooge` toolchain and rules + +## Rules + +```py +load("@rules_scala//thrift:thrift.bzl", "thrift_library") +load( + "@rules_scala//twitter_scrooge/toolchain:toolchain.bzl", + "setup_scrooge_toolchain", +) +load( + "@rules_scala//twitter_scrooge:twitter_scrooge.bzl", + "scrooge_java_library", + "scrooge_scala_library", +) +``` + +## Examples + +The [`//test/src/main/scala/scalarules/test/twitter_scrooge`][] package provides +extensive examples of `twitter_scrooge` rule usage. + +## Toolchain configuration + +### Default builtin toolchain + +To use the builtin toolchain with its default dependencies under Bzlmod: + +```py +# MODULE.bazel + +scala_deps = use_extension("//scala/extensions:deps.bzl", "scala_deps") +dev_deps.scala() +dev_deps.twitter_scrooge() +``` + +And under `WORKSPACE`: + +```py +# WORKSPACE +load( + "@rules_scala//scala:toolchains.bzl", + "scala_register_toolchains", + "scala_toolchains", +) + +scala_toolchains(twitter_scrooge = True) + +scala_register_toolchains() +``` + +### Builtin toolchain dependency overrides + +The [`examples/twitter_scrooge`][] repository shows how to configure the +toolchains for `twitter_scrooge` rules in both [`MODULE.bazel`][] and +[`WORKSPACE`][]. Both use [`rules_jvm_external`][] to import Maven artifacts for +overriding the builtin `twitter_scrooge` toolchain defaults. + +### Defining a custom toolchain + +[`examples/twitter_scrooge/BUILD`][] shows how to use `setup_scrooge_toolchain` +to define a custom `twitter_scrooge` toolchain with [`rules_jvm_external`][] +artifacts. + +### More information + +See the comments in the above [`examples/twitter_scrooge`][] files for +configuration details. + +See the [Bazel manual on toolchain resolution]( +https://bazel.build/extending/toolchains#toolchain-resolution) for guidance on +selecting a specific toolchain. + +[`//test/src/main/scala/scalarules/test/twitter_scrooge`]: ../test/src/main/scala/scalarules/test/twitter_scrooge +[`examples/twitter_scrooge`]: ../examples/twitter_scrooge/ +[`MODULE.bazel`]: ../examples/twitter_scrooge/MODULE.bazel +[`WORKSPACE`]: ../examples/twitter_scrooge/WORKSPACE +[`examples/twitter_scrooge/BUILD`]: ../examples/twitter_scrooge/BUILD +[`rules_jvm_external`]: https://github.com/bazel-contrib/rules_jvm_external diff --git a/examples/twitter_scrooge/.bazelrc b/examples/twitter_scrooge/.bazelrc new file mode 100644 index 000000000..005efba2f --- /dev/null +++ b/examples/twitter_scrooge/.bazelrc @@ -0,0 +1 @@ +import ../../.bazelrc diff --git a/examples/twitter_scrooge/.bazelversion b/examples/twitter_scrooge/.bazelversion new file mode 100644 index 000000000..e8be68404 --- /dev/null +++ b/examples/twitter_scrooge/.bazelversion @@ -0,0 +1 @@ +7.6.1 diff --git a/examples/twitter_scrooge/BUILD b/examples/twitter_scrooge/BUILD new file mode 100644 index 000000000..f3784f9c2 --- /dev/null +++ b/examples/twitter_scrooge/BUILD @@ -0,0 +1,65 @@ +# Targets adapted from //test/src/main/scala/scalarules/test/twitter_scrooge. +load("@rules_scala//scala:scala.bzl", "scala_library") +load("@rules_scala//thrift:thrift.bzl", "thrift_library") +load( + "@rules_scala//twitter_scrooge:twitter_scrooge.bzl", + "scrooge_scala_library", +) +load( + "@rules_scala//twitter_scrooge/toolchain:toolchain.bzl", + "setup_scrooge_toolchain", +) + +# When using `setup_scrooge_toolchain` with all its dependencies specified, you +# don't need to instantiate the builtin toolchain. In that case, make sure to +# register your custom toolchain via `register_toolchains` in `MODULE.bazel` or +# `WORKSPACE`. See the comments in those files for further details. +# +# It's OK to remove any of these overrides in order to use the builtin defaults +# for those dependencies instead. However, in that case, you _must_ instantiate +# the default `twitter_scrooge` toolchain in `MODULE.bazel` or `WORKSPACE`, +# without the corresponding dependency overrides. This allows `rules_scala` to +# generate the necessary builtin dependency repositories, even if you don't use +# the default toolchain. +# +# However, if you remove the `scrooge_generator` override, the toolchain will +# also depend on the builtin `mustache` and `scopt` repos. You will need to +# remove the `mustache` and `scopt` overrides, too, to use the builtin repos +# instead. +setup_scrooge_toolchain( + name = "toolchain_from_build_file", + javax_annotation_api = "@maven//:javax_annotation_javax_annotation_api", + libthrift = "@maven//:org_apache_thrift_libthrift", + mustache = "@maven//:com_github_spullara_mustache_java_compiler", + scopt = "@maven//:com_github_scopt_scopt_2_12", + scrooge_core = "@maven//:com_twitter_scrooge_core_2_12", + scrooge_generator = "@maven//:com_twitter_scrooge_generator_2_12", + util_core = "@maven//:com_twitter_util_core_2_12", + util_logging = "@maven//:com_twitter_util_logging_2_12", +) + +scala_library( + name = "justscrooge", + srcs = ["JustScrooge.scala"], + exports = [":scrooge"], + deps = [":scrooge"], +) + +scrooge_scala_library( + name = "scrooge", + visibility = ["//visibility:public"], + deps = [":thrift"], +) + +thrift_library( + name = "thrift", + srcs = ["Thrift1.thrift"], + visibility = ["//visibility:public"], + deps = [":thrift2"], +) + +thrift_library( + name = "thrift2", + srcs = ["Thrift2.thrift"], + visibility = ["//visibility:public"], +) diff --git a/examples/twitter_scrooge/JustScrooge.scala b/examples/twitter_scrooge/JustScrooge.scala new file mode 100644 index 000000000..15c6e05d8 --- /dev/null +++ b/examples/twitter_scrooge/JustScrooge.scala @@ -0,0 +1,9 @@ +package examples.twitter_scrooge + +object JustScrooge { + val classes = Seq(classOf[Struct1]) + + def main(args: Array[String]) { + print(s"classes ${classes.mkString(",")}") + } +} diff --git a/examples/twitter_scrooge/MODULE.bazel b/examples/twitter_scrooge/MODULE.bazel new file mode 100644 index 000000000..523aa795f --- /dev/null +++ b/examples/twitter_scrooge/MODULE.bazel @@ -0,0 +1,128 @@ +# Test configuration for test/shell/test_twitter_scrooge_toolchains.sh. +module(name = "twitter_scrooge_toolchains") + +bazel_dep(name = "rules_scala") +local_path_override( + module_name = "rules_scala", + path = "../..", +) + +bazel_dep(name = "latest_dependencies") +local_path_override( + module_name = "latest_dependencies", + path = "../../deps/latest", +) + +bazel_dep( + name = "protobuf", + version = "31.1", + repo_name = "com_google_protobuf", +) + +# Temporarily required for `protoc` toolchainization until resolution of +# protocolbuffers/protobuf#19679. +single_version_override( + module_name = "protobuf", + patch_strip = 1, + patches = ["//:protobuf.patch"], + version = "31.1", +) + +bazel_dep(name = "rules_jvm_external", version = "6.7") + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + artifacts = [ + "com.github.scopt:scopt_2.12:4.0.0-RC2", + "com.github.spullara.mustache.java:compiler:0.8.18", + "com.twitter:scrooge-core_2.12:21.2.0", + "com.twitter:scrooge-generator_2.12:21.2.0", + "com.twitter:util-core_2.12:21.2.0", + "com.twitter:util-logging_2.12:21.2.0", + "javax.annotation:javax.annotation-api:1.3.2", + "org.apache.thrift:libthrift:0.10.0", + ], + lock_file = "//:maven_install.json", +) +use_repo(maven, "maven") + +scala_protoc = use_extension( + "@rules_scala//scala/extensions:protoc.bzl", + "scala_protoc", + dev_dependency = True, +) +use_repo(scala_protoc, "rules_scala_protoc_toolchains") + +register_toolchains("@rules_scala_protoc_toolchains//...:all") + +scala_config = use_extension( + "@rules_scala//scala/extensions:config.bzl", + "scala_config", +) +scala_config.settings(scala_version = "2.12.20") + +scala_deps = use_extension( + "@rules_scala//scala/extensions:deps.bzl", + "scala_deps", + dev_dependency = True, +) +scala_deps.scala() + +# When using `setup_scrooge_toolchain` with all its dependencies specified in a +# `BUILD` file, you don't need to instantiate this builtin toolchain. In that +# case, make sure to register your custom toolchain via `register_toolchains` +# (see below). See the `//:toolchain_from_build_file` comments in the `BUILD` +# file for further details. +# +# It's OK to remove any of these overrides in order to use the builtin defaults +# for those dependencies instead. +# +# However, if you remove the `scrooge_generator` override, the toolchain will +# also depend on the builtin `mustache` and `scopt` repos. You will need to +# remove the `mustache` and `scopt` overrides, too, to use the builtin repos +# instead. +scala_deps.twitter_scrooge( + javax_annotation_api = "@maven//:javax_annotation_javax_annotation_api", + libthrift = "@maven//:org_apache_thrift_libthrift", + mustache = "@maven//:com_github_spullara_mustache_java_compiler", + scopt = "@maven//:com_github_scopt_scopt_2_12", + scrooge_core = "@maven//:com_twitter_scrooge_core_2_12", + scrooge_generator = "@maven//:com_twitter_scrooge_generator_2_12", + util_core = "@maven//:com_twitter_util_core_2_12", + util_logging = "@maven//:com_twitter_util_logging_2_12", +) + +# If you want to depend on any of the builtin repos when using +# `setup_scala_toolchain` in a `BUILD` file, you will need to: +# +# - Remove the `scala_deps.twitter_scrooge()` overrides for those repos. This +# enables the module extension to generate the builtin repos for those +# dependencies. +# +# - Uncomment the `use_repo` call below to import the builtin repos into the +# main module's scope. +# +# `version_suffix` should match the `scala_version` argument to +# `scala_config.settings()`. +#version_suffix = "_2_12_20" +#[ +# use_repo(scala_deps, repo + version_suffix) +# for repo in [ +# "libthrift", +# "io_bazel_rules_scala_scrooge_core", +# "io_bazel_rules_scala_scrooge_generator", +# "io_bazel_rules_scala_util_core", +# "io_bazel_rules_scala_util_logging", +# "io_bazel_rules_scala_javax_annotation_api", +# "io_bazel_rules_scala_mustache", +# "io_bazel_rules_scala_scopt", +# ] +#] + +# To depend on the toolchain defined by `setup_scala_toolchain` by default, +# instead of the builtin toolchain, uncomment this line. You can also specify it +# on demand via: +# +# bazel build --extra_toolchains=//:toolchain_from_build_file //... +# +#register_toolchains("//:toolchain_from_build_file") diff --git a/examples/twitter_scrooge/Thrift1.thrift b/examples/twitter_scrooge/Thrift1.thrift new file mode 100644 index 000000000..b850e2924 --- /dev/null +++ b/examples/twitter_scrooge/Thrift1.thrift @@ -0,0 +1,7 @@ +namespace java examples.twitter_scrooge + +include "Thrift2.thrift" + +struct Struct1 { + 1: Thrift2.Struct2 msg +} diff --git a/examples/twitter_scrooge/Thrift2.thrift b/examples/twitter_scrooge/Thrift2.thrift new file mode 100644 index 000000000..4d156479d --- /dev/null +++ b/examples/twitter_scrooge/Thrift2.thrift @@ -0,0 +1,5 @@ +namespace java examples.twitter_scrooge + +struct Struct2 { + 1: string msg +} diff --git a/examples/twitter_scrooge/WORKSPACE b/examples/twitter_scrooge/WORKSPACE new file mode 100644 index 000000000..2faebd6b1 --- /dev/null +++ b/examples/twitter_scrooge/WORKSPACE @@ -0,0 +1,154 @@ +# Test configuration for test/shell/test_twitter_scrooge_toolchains.sh. +workspace(name = "twitter_scrooge_toolchains") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +local_repository( + name = "rules_scala", + path = "../..", +) + +load("@rules_scala//scala:latest_deps.bzl", "rules_scala_dependencies") + +rules_scala_dependencies() + +load("@platforms//host:extension.bzl", "host_platform_repo") + +host_platform_repo(name = "host_platform") + +register_toolchains("@rules_scala_protoc_toolchains//...:all") + +load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies") + +rules_java_dependencies() + +load("@bazel_features//:deps.bzl", "bazel_features_deps") + +bazel_features_deps() + +load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") + +bazel_skylib_workspace() + +http_archive( + name = "rules_python", + sha256 = "9f9f3b300a9264e4c77999312ce663be5dee9a56e361a1f6fe7ec60e1beef9a3", + strip_prefix = "rules_python-1.4.1", + url = "https://github.com/bazelbuild/rules_python/releases/download/1.4.1/rules_python-1.4.1.tar.gz", +) + +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + +protobuf_deps() + +load("@rules_java//java:repositories.bzl", "rules_java_toolchains") + +rules_java_toolchains() + +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") + +rules_proto_dependencies() + +load("@rules_proto//proto:setup.bzl", "rules_proto_setup") + +rules_proto_setup() + +load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") + +rules_proto_toolchains() + +load("@rules_scala//protoc:toolchains.bzl", "scala_protoc_toolchains") + +scala_protoc_toolchains(name = "rules_scala_protoc_toolchains") + +RULES_JVM_EXTERNAL_TAG = "6.7" + +RULES_JVM_EXTERNAL_SHA = "a1e351607f04fed296ba33c4977d3fe2a615ed50df7896676b67aac993c53c18" + +http_archive( + name = "rules_jvm_external", + sha256 = RULES_JVM_EXTERNAL_SHA, + strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, + url = "https://github.com/bazel-contrib/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG), +) + +load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps") + +rules_jvm_external_deps() + +load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup") + +rules_jvm_external_setup() + +load("@rules_jvm_external//:defs.bzl", "maven_install") + +maven_install( + artifacts = [ + "com.github.scopt:scopt_2.12:4.0.0-RC2", + "com.github.spullara.mustache.java:compiler:0.8.18", + "com.twitter:scrooge-core_2.12:21.2.0", + "com.twitter:scrooge-generator_2.12:21.2.0", + "com.twitter:util-core_2.12:21.2.0", + "com.twitter:util-logging_2.12:21.2.0", + "javax.annotation:javax.annotation-api:1.3.2", + "org.apache.thrift:libthrift:0.10.0", + ], + maven_install_json = "//:maven_install.json", + repositories = [ + "https://repo1.maven.org/maven2", + ], +) + +load("@maven//:defs.bzl", "pinned_maven_install") + +pinned_maven_install() + +load("@rules_scala//:scala_config.bzl", "scala_config") + +scala_config(scala_version = "2.12.20") + +load( + "@rules_scala//scala:toolchains.bzl", + "scala_register_toolchains", + "scala_toolchains", +) + +# When using `setup_scrooge_toolchain` with all its dependencies specified in a +# `BUILD` file, you don't need to instantiate this builtin toolchain. In that +# case, make sure to register your custom toolchain via `register_toolchains` +# (see below). See the `//:toolchain_from_build_file` comments in the `BUILD` +# file for further details. +# +# It's OK to remove any of these overrides in order to use the builtin defaults +# for those dependencies instead. +# +# However, if you remove the `scrooge_generator` override, the toolchain will +# also depend on the builtin `mustache` and `scopt` repos. You will need to +# remove the `mustache` and `scopt` overrides, too, to use the builtin repos +# instead. +scala_toolchains( + twitter_scrooge = { + "libthrift": "@maven//:org_apache_thrift_libthrift", + "scrooge_core": "@maven//:com_twitter_scrooge_core_2_12", + "scrooge_generator": "@maven//:com_twitter_scrooge_generator_2_12", + "util_core": "@maven//:com_twitter_util_core_2_12", + "util_logging": "@maven//:com_twitter_util_logging_2_12", + "javax_annotation_api": "@maven//:javax_annotation_javax_annotation_api", + "mustache": "@maven//:com_github_spullara_mustache_java_compiler", + "scopt": "@maven//:com_github_scopt_scopt_2_12", + }, +) + +# To depend on the toolchain defined by `setup_scala_toolchain` by default, +# instead of the builtin toolchain, uncomment this line. You can also specify it +# on demand via: +# +# bazel build --extra_toolchains=//:toolchain_from_build_file //... +# +#register_toolchains("//:toolchain_from_build_file") + +scala_register_toolchains() diff --git a/examples/twitter_scrooge/maven_install.json b/examples/twitter_scrooge/maven_install.json new file mode 100755 index 000000000..cc59e35d4 --- /dev/null +++ b/examples/twitter_scrooge/maven_install.json @@ -0,0 +1,608 @@ +{ + "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", + "__INPUT_ARTIFACTS_HASH": 1947796996, + "__RESOLVED_ARTIFACTS_HASH": -1477454183, + "artifacts": { + "com.github.ben-manes.caffeine:caffeine": { + "shasums": { + "jar": "814b15a9bf598e0fa854dd70ba9f6e03a413a97979de0c3f49317295e4352bc8" + }, + "version": "2.8.5" + }, + "com.github.scopt:scopt_2.12": { + "shasums": { + "jar": "d19a4e8b8c013a56e03bc57bdf87abe6297c974cf907585d00284eae61c6ac91" + }, + "version": "4.0.0-RC2" + }, + "com.github.spullara.mustache.java:compiler": { + "shasums": { + "jar": "ddabc1ef897fd72319a761d29525fd61be57dc25d04d825f863f83cc89000e66" + }, + "version": "0.8.18" + }, + "com.google.code.findbugs:jsr305": { + "shasums": { + "jar": "1e7f53fa5b8b5c807e986ba335665da03f18d660802d8bf061823089d1bee468" + }, + "version": "2.0.1" + }, + "com.google.errorprone:error_prone_annotations": { + "shasums": { + "jar": "5f2a0648230a662e8be049df308d583d7369f13af683e44ddf5829b6d741a228" + }, + "version": "2.4.0" + }, + "com.google.guava:guava": { + "shasums": { + "jar": "a896857d07845d38c7dc5bbc0457b6d9b0f62ecffda010e5e9ec12d561f676d3" + }, + "version": "16.0.1" + }, + "com.twitter:scrooge-core_2.12": { + "shasums": { + "jar": "1178f6cef63c9ad9e787ee7dbb26008d2a8cec9afee7629d0037c534d5b5d575" + }, + "version": "21.2.0" + }, + "com.twitter:scrooge-generator_2.12": { + "shasums": { + "jar": "ac5afecfd742ce07cf127b253df20ebf265d75d02d5f38bd8c683da194780862" + }, + "version": "21.2.0" + }, + "com.twitter:util-app-lifecycle_2.12": { + "shasums": { + "jar": "fcc047fdc83f1caa5d7f5845b0cd71a92f47f87b7bd58db001a6db70fff9593f" + }, + "version": "21.2.0" + }, + "com.twitter:util-app_2.12": { + "shasums": { + "jar": "f5cbf130b97c0bc87c063d6fc9b0fce7e8fed4c526bbf4878194a008ea30d862" + }, + "version": "21.2.0" + }, + "com.twitter:util-core_2.12": { + "shasums": { + "jar": "5d4ed75a26a3a2cc7fdc1dbeb29878a70024a8b7864287ed1e182dbca9c775a5" + }, + "version": "21.2.0" + }, + "com.twitter:util-function_2.12": { + "shasums": { + "jar": "9b6cec98066aa535a63fbf64b63b6dce0a1b48e59c578fd0afae60a52d144f80" + }, + "version": "21.2.0" + }, + "com.twitter:util-lint_2.12": { + "shasums": { + "jar": "7b15d834d5373c00802517a366bcb354710bf036e608a8ab2a1d358a98d73059" + }, + "version": "21.2.0" + }, + "com.twitter:util-logging_2.12": { + "shasums": { + "jar": "6110ea70a1ea65c477cec72b7a2ce2ec92427e081ff9366272cb7c3bcadf69a9" + }, + "version": "21.2.0" + }, + "com.twitter:util-registry_2.12": { + "shasums": { + "jar": "3f45cd2a289d20ab4fb09663acd68f61a273509ec328d840da053bb0b2aa3a7d" + }, + "version": "21.2.0" + }, + "com.twitter:util-stats_2.12": { + "shasums": { + "jar": "3bd7b40f47f7e022cc8bf70ebd4cf898d4596db166492b7d966cb360b2eea224" + }, + "version": "21.2.0" + }, + "commons-cli:commons-cli": { + "shasums": { + "jar": "3a2f057041aa6a8813f5b59b695f726c5e85014a703d208d7e1689098e92d8c0" + }, + "version": "1.3.1" + }, + "commons-codec:commons-codec": { + "shasums": { + "jar": "ad19d2601c3abf0b946b5c3a4113e226a8c1e3305e395b90013b78dd94a723ce" + }, + "version": "1.9" + }, + "commons-logging:commons-logging": { + "shasums": { + "jar": "daddea1ea0be0f56978ab3006b8ac92834afeefbd9b7e4e6316fca57df0fa636" + }, + "version": "1.2" + }, + "javax.annotation:javax.annotation-api": { + "shasums": { + "jar": "e04ba5195bcd555dc95650f7cc614d151e4bcd52d29a10b8aa2197f3ab89ab9b" + }, + "version": "1.3.2" + }, + "org.apache.httpcomponents:httpclient": { + "shasums": { + "jar": "b2958ffb74f691e108abe69af0002ccff90ba326420596b1aab5bb0f63c31ef9" + }, + "version": "4.4.1" + }, + "org.apache.httpcomponents:httpcore": { + "shasums": { + "jar": "dd1390c17d40f760f7e51bb20523a8d63deb69e94babeaf567eb76ecd2cad422" + }, + "version": "4.4.1" + }, + "org.apache.thrift:libthrift": { + "shasums": { + "jar": "8591718c1884ac8001b4c5ca80f349c0a6deec691de0af720c5e3bc3a581dada" + }, + "version": "0.10.0" + }, + "org.checkerframework:checker-qual": { + "shasums": { + "jar": "bce5c887460542d69c0ffce05919fef8f56f9964a1505a99f6ae69a58351507e" + }, + "version": "3.4.1" + }, + "org.codehaus.plexus:plexus-utils": { + "shasums": { + "jar": "b5035e5abfd9d3c73c9311a5ac54de59248d1242ee5fa47212d0fcb097b1cd1e" + }, + "version": "1.5.4" + }, + "org.scala-lang.modules:scala-collection-compat_2.12": { + "shasums": { + "jar": "8aab3e1f9dd7bc392a2e27cf168af94fdc7cc2752131fc852192302fb21efdb4" + }, + "version": "2.1.2" + }, + "org.scala-lang.modules:scala-parser-combinators_2.12": { + "shasums": { + "jar": "24985eb43e295a9dd77905ada307a850ca25acf819cdb579c093fc6987b0dbc2" + }, + "version": "1.1.2" + }, + "org.scala-lang:scala-library": { + "shasums": { + "jar": "dbfe77a3fc7a16c0c7cb6cb2b91fecec5438f2803112a744cb1b187926a138be" + }, + "version": "2.12.11" + }, + "org.scala-lang:scala-reflect": { + "shasums": { + "jar": "5f9e156aeba45ef2c4d24b303405db259082739015190b3b334811843bd90d6a" + }, + "version": "2.12.11" + }, + "org.slf4j:slf4j-api": { + "shasums": { + "jar": "0aee9a77a4940d72932b0d0d9557793f872e66a03f598e473f45e7efecdccf99" + }, + "version": "1.7.12" + } + }, + "dependencies": { + "com.github.ben-manes.caffeine:caffeine": [ + "com.google.errorprone:error_prone_annotations", + "org.checkerframework:checker-qual" + ], + "com.github.scopt:scopt_2.12": [ + "org.scala-lang:scala-library" + ], + "com.github.spullara.mustache.java:compiler": [ + "com.google.guava:guava" + ], + "com.twitter:scrooge-core_2.12": [ + "com.twitter:util-core_2.12", + "javax.annotation:javax.annotation-api", + "org.scala-lang:scala-library" + ], + "com.twitter:scrooge-generator_2.12": [ + "com.github.scopt:scopt_2.12", + "com.github.spullara.mustache.java:compiler", + "com.google.code.findbugs:jsr305", + "commons-cli:commons-cli", + "org.apache.thrift:libthrift", + "org.codehaus.plexus:plexus-utils", + "org.scala-lang.modules:scala-parser-combinators_2.12", + "org.scala-lang:scala-library" + ], + "com.twitter:util-app-lifecycle_2.12": [ + "com.twitter:util-core_2.12", + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang:scala-library" + ], + "com.twitter:util-app_2.12": [ + "com.twitter:util-app-lifecycle_2.12", + "com.twitter:util-core_2.12", + "com.twitter:util-registry_2.12", + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang:scala-library" + ], + "com.twitter:util-core_2.12": [ + "com.twitter:util-function_2.12", + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang.modules:scala-parser-combinators_2.12", + "org.scala-lang:scala-library", + "org.scala-lang:scala-reflect" + ], + "com.twitter:util-function_2.12": [ + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang:scala-library" + ], + "com.twitter:util-lint_2.12": [ + "com.twitter:util-core_2.12", + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang:scala-library" + ], + "com.twitter:util-logging_2.12": [ + "com.twitter:util-app_2.12", + "com.twitter:util-core_2.12", + "com.twitter:util-stats_2.12", + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang:scala-library" + ], + "com.twitter:util-registry_2.12": [ + "com.twitter:util-core_2.12", + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang:scala-library" + ], + "com.twitter:util-stats_2.12": [ + "com.github.ben-manes.caffeine:caffeine", + "com.google.code.findbugs:jsr305", + "com.twitter:util-core_2.12", + "com.twitter:util-lint_2.12", + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang:scala-library" + ], + "org.apache.httpcomponents:httpclient": [ + "commons-codec:commons-codec", + "commons-logging:commons-logging", + "org.apache.httpcomponents:httpcore" + ], + "org.apache.thrift:libthrift": [ + "org.apache.httpcomponents:httpclient", + "org.apache.httpcomponents:httpcore", + "org.slf4j:slf4j-api" + ], + "org.scala-lang.modules:scala-collection-compat_2.12": [ + "org.scala-lang:scala-library" + ], + "org.scala-lang.modules:scala-parser-combinators_2.12": [ + "org.scala-lang:scala-library" + ], + "org.scala-lang:scala-reflect": [ + "org.scala-lang:scala-library" + ] + }, + "packages": { + "com.github.ben-manes.caffeine:caffeine": [ + "com.github.benmanes.caffeine", + "com.github.benmanes.caffeine.base", + "com.github.benmanes.caffeine.cache", + "com.github.benmanes.caffeine.cache.stats" + ], + "com.github.scopt:scopt_2.12": [ + "scopt" + ], + "com.github.spullara.mustache.java:compiler": [ + "com.github.mustachejava", + "com.github.mustachejava.codes", + "com.github.mustachejava.functions", + "com.github.mustachejava.jruby", + "com.github.mustachejava.reflect", + "com.github.mustachejava.reflect.guards", + "com.github.mustachejava.resolver", + "com.github.mustachejava.util" + ], + "com.google.code.findbugs:jsr305": [ + "javax.annotation", + "javax.annotation.concurrent", + "javax.annotation.meta" + ], + "com.google.errorprone:error_prone_annotations": [ + "com.google.errorprone.annotations", + "com.google.errorprone.annotations.concurrent" + ], + "com.google.guava:guava": [ + "com.google.common.annotations", + "com.google.common.base", + "com.google.common.base.internal", + "com.google.common.cache", + "com.google.common.collect", + "com.google.common.escape", + "com.google.common.eventbus", + "com.google.common.hash", + "com.google.common.html", + "com.google.common.io", + "com.google.common.math", + "com.google.common.net", + "com.google.common.primitives", + "com.google.common.reflect", + "com.google.common.util.concurrent", + "com.google.common.xml", + "com.google.thirdparty.publicsuffix" + ], + "com.twitter:scrooge-core_2.12": [ + "com.twitter.scrooge", + "com.twitter.scrooge.adapt", + "com.twitter.scrooge.internal", + "com.twitter.scrooge.validation" + ], + "com.twitter:scrooge-generator_2.12": [ + "com.twitter.scrooge", + "com.twitter.scrooge.android_generator", + "com.twitter.scrooge.ast", + "com.twitter.scrooge.backend", + "com.twitter.scrooge.backend.lua", + "com.twitter.scrooge.frontend", + "com.twitter.scrooge.java_generator", + "com.twitter.scrooge.java_generator.test", + "com.twitter.scrooge.mustache" + ], + "com.twitter:util-app-lifecycle_2.12": [ + "com.twitter.app.lifecycle" + ], + "com.twitter:util-app_2.12": [ + "com.twitter.app", + "com.twitter.finagle.util" + ], + "com.twitter:util-core_2.12": [ + "", + "com.twitter.concurrent", + "com.twitter.conversions", + "com.twitter.io", + "com.twitter.service", + "com.twitter.util", + "com.twitter.util.javainterop" + ], + "com.twitter:util-function_2.12": [ + "com.twitter.function" + ], + "com.twitter:util-lint_2.12": [ + "com.twitter.util.lint" + ], + "com.twitter:util-logging_2.12": [ + "com.twitter.logging" + ], + "com.twitter:util-registry_2.12": [ + "com.twitter.util.registry" + ], + "com.twitter:util-stats_2.12": [ + "com.twitter.finagle.stats" + ], + "commons-cli:commons-cli": [ + "org.apache.commons.cli" + ], + "commons-codec:commons-codec": [ + "org.apache.commons.codec", + "org.apache.commons.codec.binary", + "org.apache.commons.codec.digest", + "org.apache.commons.codec.language", + "org.apache.commons.codec.language.bm", + "org.apache.commons.codec.net" + ], + "commons-logging:commons-logging": [ + "org.apache.commons.logging", + "org.apache.commons.logging.impl" + ], + "javax.annotation:javax.annotation-api": [ + "javax.annotation", + "javax.annotation.security", + "javax.annotation.sql" + ], + "org.apache.httpcomponents:httpclient": [ + "org.apache.http.auth", + "org.apache.http.auth.params", + "org.apache.http.client", + "org.apache.http.client.config", + "org.apache.http.client.entity", + "org.apache.http.client.methods", + "org.apache.http.client.params", + "org.apache.http.client.protocol", + "org.apache.http.client.utils", + "org.apache.http.conn", + "org.apache.http.conn.params", + "org.apache.http.conn.routing", + "org.apache.http.conn.scheme", + "org.apache.http.conn.socket", + "org.apache.http.conn.ssl", + "org.apache.http.conn.util", + "org.apache.http.cookie", + "org.apache.http.cookie.params", + "org.apache.http.impl.auth", + "org.apache.http.impl.client", + "org.apache.http.impl.conn", + "org.apache.http.impl.conn.tsccm", + "org.apache.http.impl.cookie", + "org.apache.http.impl.execchain" + ], + "org.apache.httpcomponents:httpcore": [ + "org.apache.http", + "org.apache.http.annotation", + "org.apache.http.concurrent", + "org.apache.http.config", + "org.apache.http.entity", + "org.apache.http.impl", + "org.apache.http.impl.bootstrap", + "org.apache.http.impl.entity", + "org.apache.http.impl.io", + "org.apache.http.impl.pool", + "org.apache.http.io", + "org.apache.http.message", + "org.apache.http.params", + "org.apache.http.pool", + "org.apache.http.protocol", + "org.apache.http.ssl", + "org.apache.http.util" + ], + "org.apache.thrift:libthrift": [ + "org.apache.thrift", + "org.apache.thrift.async", + "org.apache.thrift.meta_data", + "org.apache.thrift.protocol", + "org.apache.thrift.scheme", + "org.apache.thrift.server", + "org.apache.thrift.transport" + ], + "org.checkerframework:checker-qual": [ + "org.checkerframework.checker.compilermsgs.qual", + "org.checkerframework.checker.fenum.qual", + "org.checkerframework.checker.formatter", + "org.checkerframework.checker.formatter.qual", + "org.checkerframework.checker.guieffect.qual", + "org.checkerframework.checker.i18n.qual", + "org.checkerframework.checker.i18nformatter", + "org.checkerframework.checker.i18nformatter.qual", + "org.checkerframework.checker.index.qual", + "org.checkerframework.checker.initialization.qual", + "org.checkerframework.checker.interning.qual", + "org.checkerframework.checker.lock.qual", + "org.checkerframework.checker.nullness", + "org.checkerframework.checker.nullness.qual", + "org.checkerframework.checker.optional.qual", + "org.checkerframework.checker.propkey.qual", + "org.checkerframework.checker.regex", + "org.checkerframework.checker.regex.qual", + "org.checkerframework.checker.signature.qual", + "org.checkerframework.checker.signedness", + "org.checkerframework.checker.signedness.qual", + "org.checkerframework.checker.tainting.qual", + "org.checkerframework.checker.units", + "org.checkerframework.checker.units.qual", + "org.checkerframework.common.aliasing.qual", + "org.checkerframework.common.reflection.qual", + "org.checkerframework.common.returnsreceiver.qual", + "org.checkerframework.common.subtyping.qual", + "org.checkerframework.common.util.report.qual", + "org.checkerframework.common.value.qual", + "org.checkerframework.dataflow.qual", + "org.checkerframework.framework.qual", + "org.checkerframework.framework.util" + ], + "org.codehaus.plexus:plexus-utils": [ + "hidden.org.codehaus.plexus.interpolation", + "hidden.org.codehaus.plexus.interpolation.os", + "hidden.org.codehaus.plexus.interpolation.reflection", + "hidden.org.codehaus.plexus.interpolation.util", + "org.codehaus.plexus.util", + "org.codehaus.plexus.util.cli", + "org.codehaus.plexus.util.cli.shell", + "org.codehaus.plexus.util.dag", + "org.codehaus.plexus.util.interpolation", + "org.codehaus.plexus.util.introspection", + "org.codehaus.plexus.util.io", + "org.codehaus.plexus.util.reflection", + "org.codehaus.plexus.util.xml", + "org.codehaus.plexus.util.xml.pull" + ], + "org.scala-lang.modules:scala-collection-compat_2.12": [ + "scala.collection.compat", + "scala.collection.compat.immutable", + "scala.jdk" + ], + "org.scala-lang.modules:scala-parser-combinators_2.12": [ + "scala.util.parsing.combinator", + "scala.util.parsing.combinator.lexical", + "scala.util.parsing.combinator.syntactical", + "scala.util.parsing.combinator.token", + "scala.util.parsing.input", + "scala.util.parsing.json" + ], + "org.scala-lang:scala-library": [ + "scala", + "scala.annotation", + "scala.annotation.meta", + "scala.annotation.unchecked", + "scala.beans", + "scala.collection", + "scala.collection.concurrent", + "scala.collection.convert", + "scala.collection.generic", + "scala.collection.immutable", + "scala.collection.mutable", + "scala.collection.parallel", + "scala.collection.parallel.immutable", + "scala.collection.parallel.mutable", + "scala.collection.script", + "scala.compat", + "scala.concurrent", + "scala.concurrent.duration", + "scala.concurrent.forkjoin", + "scala.concurrent.impl", + "scala.io", + "scala.math", + "scala.ref", + "scala.reflect", + "scala.reflect.macros.internal", + "scala.runtime", + "scala.runtime.java8", + "scala.sys", + "scala.sys.process", + "scala.text", + "scala.util", + "scala.util.control", + "scala.util.hashing", + "scala.util.matching" + ], + "org.scala-lang:scala-reflect": [ + "scala.reflect.api", + "scala.reflect.internal", + "scala.reflect.internal.annotations", + "scala.reflect.internal.pickling", + "scala.reflect.internal.settings", + "scala.reflect.internal.tpe", + "scala.reflect.internal.transform", + "scala.reflect.internal.util", + "scala.reflect.io", + "scala.reflect.macros", + "scala.reflect.macros.blackbox", + "scala.reflect.macros.whitebox", + "scala.reflect.runtime" + ], + "org.slf4j:slf4j-api": [ + "org.slf4j", + "org.slf4j.helpers", + "org.slf4j.spi" + ] + }, + "repositories": { + "https://repo1.maven.org/maven2/": [ + "com.github.ben-manes.caffeine:caffeine", + "com.github.scopt:scopt_2.12", + "com.github.spullara.mustache.java:compiler", + "com.google.code.findbugs:jsr305", + "com.google.errorprone:error_prone_annotations", + "com.google.guava:guava", + "com.twitter:scrooge-core_2.12", + "com.twitter:scrooge-generator_2.12", + "com.twitter:util-app-lifecycle_2.12", + "com.twitter:util-app_2.12", + "com.twitter:util-core_2.12", + "com.twitter:util-function_2.12", + "com.twitter:util-lint_2.12", + "com.twitter:util-logging_2.12", + "com.twitter:util-registry_2.12", + "com.twitter:util-stats_2.12", + "commons-cli:commons-cli", + "commons-codec:commons-codec", + "commons-logging:commons-logging", + "javax.annotation:javax.annotation-api", + "org.apache.httpcomponents:httpclient", + "org.apache.httpcomponents:httpcore", + "org.apache.thrift:libthrift", + "org.checkerframework:checker-qual", + "org.codehaus.plexus:plexus-utils", + "org.scala-lang.modules:scala-collection-compat_2.12", + "org.scala-lang.modules:scala-parser-combinators_2.12", + "org.scala-lang:scala-library", + "org.scala-lang:scala-reflect", + "org.slf4j:slf4j-api" + ] + }, + "services": {}, + "version": "2" +} diff --git a/examples/twitter_scrooge/protobuf.patch b/examples/twitter_scrooge/protobuf.patch new file mode 120000 index 000000000..c8f00be6e --- /dev/null +++ b/examples/twitter_scrooge/protobuf.patch @@ -0,0 +1 @@ +../../protoc/0001-protobuf-19679-rm-protoc-dep.patch \ No newline at end of file diff --git a/scala/toolchains.bzl b/scala/toolchains.bzl index ddf5874ac..fe6415650 100644 --- a/scala/toolchains.bzl +++ b/scala/toolchains.bzl @@ -236,7 +236,12 @@ def scala_toolchains( scala_proto_options = scala_proto_options["default_gen_opts"], jmh = jmh, twitter_scrooge = twitter_scrooge, - twitter_scrooge_deps = twitter_scrooge_options, + # When we _really_ drop Bazel 6 entirely, this attribute can become an + # attr.string_keyed_label_dict, and this conversion won't be necessary. + twitter_scrooge_deps = { + k: str(v) + for k, v in twitter_scrooge_options.items() + }, ) def scala_register_toolchains(name = _DEFAULT_TOOLCHAINS_REPO_NAME): diff --git a/test/shell/test_examples.sh b/test/shell/test_examples.sh index 2c41afd01..2df5f1830 100755 --- a/test/shell/test_examples.sh +++ b/test/shell/test_examples.sh @@ -1,90 +1,98 @@ +#!/usr/bin/env bash +# +# Tests for `examples/` repositories + +set -e + +dir="$( cd "${BASH_SOURCE[0]%/*}" && echo "${PWD%/test/shell}" )" +test_source="${dir}/test/shell/${BASH_SOURCE[0]#*test/shell/}" # 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}") - -function test_example(){ - local dir1=$1; - local cmd1=$2; - ( - set -e - - cd $dir1 - $cmd1 - bazel shutdown; #cleanup bazel process - ) +. "${dir}"/test/shell/test_runner.sh +export USE_BAZEL_VERSION=${USE_BAZEL_VERSION:-$(cat $dir/.bazelversion)} + +run_in_example_dir(){ + local test_dir="$1"; + shift + + set -e + cd "examples/${test_dir}" + "$@" + bazel shutdown + cd "$dir" } -function scalatest_repositories_example() { - test_example examples/testing/scalatest_repositories "bazel test //..." +test_scalatest_repositories_example() { + run_in_example_dir testing/scalatest_repositories bazel test //... } -function specs2_junit_repositories_example() { - - test_example examples/testing/specs2_junit_repositories "bazel test //..." +test_specs2_junit_repositories_example() { + run_in_example_dir testing/specs2_junit_repositories bazel test //... } -function multi_framework_toolchain_example() { - test_example examples/testing/multi_frameworks_toolchain "bazel test //..." +test_multi_framework_toolchain_example() { + run_in_example_dir testing/multi_frameworks_toolchain bazel test //... } -function scala3_1_example() { - test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.1.3 //..." +test_scala3_1_example() { + run_in_example_dir scala3 bazel build --repo_env=SCALA_VERSION=3.1.3 //... } -function scala3_2_example() { - test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.2.2 //..." +test_scala3_2_example() { + run_in_example_dir scala3 bazel build --repo_env=SCALA_VERSION=3.2.2 //... } -function scala3_3_example() { - test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.3.6 //..." +test_scala3_3_example() { + run_in_example_dir scala3 bazel build --repo_env=SCALA_VERSION=3.3.6 //... } -function scala3_4_example() { - test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.4.3 //..." +test_scala3_4_example() { + run_in_example_dir scala3 bazel build --repo_env=SCALA_VERSION=3.4.3 //... } -function scala3_5_example() { - test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.5.2 //..." +test_scala3_5_example() { + run_in_example_dir scala3 bazel build --repo_env=SCALA_VERSION=3.5.2 //... } -function scala3_6_example() { - test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.6.4 //..." +test_scala3_6_example() { + run_in_example_dir scala3 bazel build --repo_env=SCALA_VERSION=3.6.4 //... } -function scala3_7_example() { - test_example examples/scala3 "bazel build --repo_env=SCALA_VERSION=3.7.1 //..." +test_scala3_7_example() { + run_in_example_dir scala3 bazel build --repo_env=SCALA_VERSION=3.7.1 //... } -function semanticdb_example() { - - function build_semanticdb_example(){ - bazel build //... --aspects aspect.bzl%semanticdb_info_aspect --output_groups=json_output_file +test_semanticdb_example() { + build_semanticdb_example(){ + bazel build //... --aspects aspect.bzl%semanticdb_info_aspect \ + --output_groups=json_output_file + echo bazel build //... } - - test_example examples/semanticdb build_semanticdb_example + + run_in_example_dir semanticdb build_semanticdb_example +} + +test_cross_build_example() { + run_in_example_dir crossbuild bazel build //... } -function cross_build_example() { - test_example examples/crossbuild "bazel build //..." +test_overridden_artifacts_example() { + run_in_example_dir overridden_artifacts bazel test --test_output=errors //... } -function overridden_artifacts_example() { - test_example examples/overridden_artifacts \ - "bazel test --test_output=errors //..." +test_twitter_scrooge_example() { + # Tests for twitter_scrooge toolchain setup problems under Bzlmod from #1744. + # Neither of the errors occurred under `WORKSPACE` + build_twitter_scrooge_example() { + # `ERROR: no such package '@@[unknown repo...` + bazel build //... + echo + + # `expected value of type 'string' for dict value element, but got Label` + bazel build //:justscrooge + } + + run_in_example_dir twitter_scrooge build_twitter_scrooge_example } -$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 scala3_4_example -$runner scala3_5_example -$runner scala3_6_example -$runner cross_build_example -$runner overridden_artifacts_example +run_tests "$test_source" "$(get_test_runner "${1:-local}")" diff --git a/twitter_scrooge/toolchain/toolchain.bzl b/twitter_scrooge/toolchain/toolchain.bzl index 09aa03b7a..b5848c0ca 100644 --- a/twitter_scrooge/toolchain/toolchain.bzl +++ b/twitter_scrooge/toolchain/toolchain.bzl @@ -19,13 +19,11 @@ def twitter_scrooge_artifact_ids( scrooge_core = None, scrooge_generator = None, util_core = None, - util_logging = None): - artifact_ids = [ - # Mustache is needed to generate java from thrift. - "io_bazel_rules_scala_mustache", - "io_bazel_rules_scala_javax_annotation_api", - "io_bazel_rules_scala_scopt", - ] + GUAVA_ARTIFACT_IDS + util_logging = None, + javax_annotation_api = None, + mustache = None, + scopt = None): + artifact_ids = [] if libthrift == None: artifact_ids.append("libthrift") @@ -37,8 +35,15 @@ def twitter_scrooge_artifact_ids( artifact_ids.append("io_bazel_rules_scala_util_core") if util_logging == None: artifact_ids.append("io_bazel_rules_scala_util_logging") + if javax_annotation_api == None: + artifact_ids.append("io_bazel_rules_scala_javax_annotation_api") + if mustache == None: + # Mustache is for generating Java from Thrift. + artifact_ids.append("io_bazel_rules_scala_mustache") + if scopt == None: + artifact_ids.append("io_bazel_rules_scala_scopt") - return artifact_ids + return artifact_ids + GUAVA_ARTIFACT_IDS def _scrooge_toolchain_impl(ctx): toolchain = platform_common.ToolchainInfo( @@ -76,6 +81,9 @@ TOOLCHAIN_DEFAULTS = { "scrooge_generator": None, "util_core": None, "util_logging": None, + "javax_annotation_api": None, + "mustache": None, + "scopt": None, } def setup_scrooge_toolchain( @@ -84,7 +92,10 @@ def setup_scrooge_toolchain( scrooge_core = None, scrooge_generator = None, util_core = None, - util_logging = None): + util_logging = None, + javax_annotation_api = None, + mustache = None, + scopt = None): version = version_suffix(SCALA_VERSION) if libthrift == None: @@ -97,6 +108,14 @@ def setup_scrooge_toolchain( util_core = "@io_bazel_rules_scala_util_core" + version if util_logging == None: util_logging = "@io_bazel_rules_scala_util_logging" + version + if javax_annotation_api == None: + javax_annotation_api = ( + "@io_bazel_rules_scala_javax_annotation_api" + version + ) + if mustache == None: + mustache = "@io_bazel_rules_scala_mustache" + version + if scopt == None: + scopt = "@io_bazel_rules_scala_scopt" + version scrooge_toolchain( name = "%s_impl" % name, @@ -116,7 +135,7 @@ def setup_scrooge_toolchain( deps_id = "aspect_compile_classpath", visibility = ["//visibility:public"], deps = [ - "@io_bazel_rules_scala_javax_annotation_api" + version, + javax_annotation_api, Label("//scala/private/toolchain_deps:scala_library_classpath"), libthrift, scrooge_core, @@ -147,8 +166,8 @@ def setup_scrooge_toolchain( deps_id = "compiler_classpath", visibility = ["//visibility:public"], deps = [ - "@io_bazel_rules_scala_mustache" + version, - "@io_bazel_rules_scala_scopt" + version, + mustache, + scopt, Label("//scala/private/toolchain_deps:parser_combinators"), scrooge_generator, util_core,