|
| 1 | +"""Bazel module definition for rules_scala""" |
| 2 | + |
| 3 | +module( |
| 4 | + name = "rules_scala", |
| 5 | + version = "7.0.0", |
| 6 | + compatibility_level = 7, |
| 7 | + bazel_compatibility = [">=7.5.0"], |
| 8 | +) |
| 9 | + |
| 10 | +SCALA_VERSION = "2.12.20" |
| 11 | + |
| 12 | +# These versions match those required by some tests, including |
| 13 | +# test_thirdparty_version.sh. |
| 14 | +SCALA_2_VERSIONS = [ |
| 15 | + "2.11.12", |
| 16 | + "2.12.20", |
| 17 | + "2.13.16", |
| 18 | +] |
| 19 | + |
| 20 | +SCALA_3_VERSIONS = [ |
| 21 | + "3.1.3", |
| 22 | + "3.3.5", |
| 23 | + "3.5.2", |
| 24 | + "3.6.3", |
| 25 | +] |
| 26 | + |
| 27 | +SCALA_VERSIONS = SCALA_2_VERSIONS + SCALA_3_VERSIONS |
| 28 | + |
| 29 | +bazel_dep(name = "bazel_skylib", version = "1.7.1") |
| 30 | +bazel_dep(name = "platforms", version = "0.0.11") |
| 31 | +bazel_dep(name = "rules_cc", version = "0.1.1") |
| 32 | +bazel_dep(name = "rules_java", version = "8.10.0") |
| 33 | +bazel_dep(name = "rules_proto", version = "7.1.0") |
| 34 | + |
| 35 | +bazel_dep( |
| 36 | + name = "protobuf", |
| 37 | + version = "29.3", |
| 38 | + repo_name = "com_google_protobuf", |
| 39 | +) |
| 40 | + |
| 41 | +# Temporarily required for `protoc` toolchainization until resolution of |
| 42 | +# protocolbuffers/protobuf#19679. |
| 43 | +single_version_override( |
| 44 | + module_name = "protobuf", |
| 45 | + version = "29.3", |
| 46 | + patches = ["//protoc:0001-protobuf-19679-rm-protoc-dep.patch"], |
| 47 | + patch_strip = 1, |
| 48 | +) |
| 49 | + |
| 50 | +scala_config = use_extension( |
| 51 | + "//scala/extensions:config.bzl", |
| 52 | + "scala_config", |
| 53 | +) |
| 54 | +use_repo(scala_config, "rules_scala_config") |
| 55 | + |
| 56 | +dev_config = use_extension( |
| 57 | + "//scala/extensions:config.bzl", |
| 58 | + "scala_config", |
| 59 | + dev_dependency = True, |
| 60 | +) |
| 61 | +dev_config.settings( |
| 62 | + enable_compiler_dependency_tracking = True, |
| 63 | + scala_version = SCALA_VERSION, |
| 64 | + scala_versions = SCALA_VERSIONS, |
| 65 | +) |
| 66 | + |
| 67 | +scala_deps = use_extension("//scala/extensions:deps.bzl", "scala_deps") |
| 68 | + |
| 69 | +# This is optional, but still safe to include even when not using |
| 70 | +# `--incompatible_enable_proto_toolchain_resolution`. |
| 71 | +register_toolchains("//protoc:all") |
| 72 | + |
| 73 | +# Register some of our testing toolchains first when building our repo. |
| 74 | +register_toolchains( |
| 75 | + "//scala:unused_dependency_checker_error_toolchain", |
| 76 | + "//test/proto:scalapb_toolchain", |
| 77 | + "//test/toolchains:java21_toolchain_definition", |
| 78 | + dev_dependency = True, |
| 79 | +) |
| 80 | + |
| 81 | +use_repo( |
| 82 | + scala_deps, |
| 83 | + "rules_scala_toolchains", |
| 84 | + "scala_compiler_sources", |
| 85 | +) |
| 86 | + |
| 87 | +register_toolchains("@rules_scala_toolchains//...:all") |
| 88 | + |
| 89 | +# Dev dependencies |
| 90 | + |
| 91 | +dev_deps = use_extension( |
| 92 | + "//scala/extensions:deps.bzl", |
| 93 | + "scala_deps", |
| 94 | + dev_dependency = True, |
| 95 | +) |
| 96 | +dev_deps.toolchains( |
| 97 | + jmh = True, |
| 98 | + scala_proto = True, |
| 99 | + scalafmt = True, |
| 100 | + scalatest = True, |
| 101 | + junit = True, |
| 102 | + specs2 = True, |
| 103 | + twitter_scrooge = True, |
| 104 | +) |
| 105 | + |
| 106 | +use_repo( |
| 107 | + dev_deps, |
| 108 | + "scala_proto_rules_scalapb_compilerplugin", |
| 109 | + "scala_proto_rules_scalapb_protoc_bridge", |
| 110 | + "scalafmt_default", |
| 111 | +) |
| 112 | + |
| 113 | +# Default versions of version specific repos needed by some of our tests. Tests |
| 114 | +# that set `--repo_env=SCALA_VERSION=...` break without using the default here, |
| 115 | +# because version specific repos for other versions won't be available. |
| 116 | +use_repo( |
| 117 | + dev_deps, |
| 118 | + "io_bazel_rules_scala_guava", |
| 119 | + "io_bazel_rules_scala_junit_junit", |
| 120 | + "io_bazel_rules_scala_scala_compiler", |
| 121 | + "io_bazel_rules_scala_scala_library", |
| 122 | +) |
| 123 | + |
| 124 | +[ |
| 125 | + [ |
| 126 | + use_repo(dev_deps, dep + "_" + scala_version.replace(".", "_")) |
| 127 | + for dep in [ |
| 128 | + "io_bazel_rules_scala_junit_junit", |
| 129 | + "io_bazel_rules_scala_scala_compiler", |
| 130 | + "io_bazel_rules_scala_scala_library", |
| 131 | + ] + ( |
| 132 | + # We can remove this condition once we drop support for Scala 2.11. |
| 133 | + ["scala_proto_rules_scalapb_protoc_gen"] |
| 134 | + if not scala_version.startswith("2.11.") else [] |
| 135 | + ) |
| 136 | + ] |
| 137 | + for scala_version in SCALA_VERSIONS |
| 138 | +] |
| 139 | + |
| 140 | +[ |
| 141 | + [ |
| 142 | + use_repo(dev_deps, dep + "_" + scala_version.replace(".", "_")) |
| 143 | + for dep in [ |
| 144 | + "io_bazel_rules_scala_scala_reflect", |
| 145 | + ] |
| 146 | + ] |
| 147 | + for scala_version in SCALA_2_VERSIONS |
| 148 | +] |
| 149 | + |
| 150 | +[ |
| 151 | + [ |
| 152 | + use_repo(dev_deps, dep + "_" + scala_version.replace(".", "_")) |
| 153 | + for dep in [ |
| 154 | + "io_bazel_rules_scala_scala_compiler_2", |
| 155 | + "io_bazel_rules_scala_scala_library_2", |
| 156 | + "io_bazel_rules_scala_scala_reflect_2", |
| 157 | + ] |
| 158 | + ] |
| 159 | + for scala_version in SCALA_3_VERSIONS |
| 160 | +] |
| 161 | + |
| 162 | +internal_dev_deps = use_extension( |
| 163 | + "//scala/private/extensions:dev_deps.bzl", |
| 164 | + "dev_deps", |
| 165 | + dev_dependency = True, |
| 166 | +) |
| 167 | + |
| 168 | +# See //scala/private:extensions/dev_deps.bzl for notes on some of these repos. |
| 169 | +use_repo( |
| 170 | + internal_dev_deps, |
| 171 | + "com_github_bazelbuild_buildtools", |
| 172 | + "com_github_jnr_jffi_native", |
| 173 | + "com_google_guava_guava_21_0", |
| 174 | + "com_google_guava_guava_21_0_with_file", |
| 175 | + "com_twitter__scalding_date", |
| 176 | + "org_apache_commons_commons_lang_3_5", |
| 177 | + "org_apache_commons_commons_lang_3_5_without_file", |
| 178 | + "org_springframework_spring_core", |
| 179 | + "org_springframework_spring_tx", |
| 180 | + "org_typelevel__cats_core", |
| 181 | + "org_typelevel_kind_projector", |
| 182 | +) |
| 183 | + |
| 184 | +java_toolchains = use_extension( |
| 185 | + "@rules_java//java:extensions.bzl", |
| 186 | + "toolchains", |
| 187 | + dev_dependency = True, |
| 188 | +) |
| 189 | + |
| 190 | +use_repo( |
| 191 | + java_toolchains, |
| 192 | + # //test/toolchains:java21_toolchain |
| 193 | + "remotejdk21_linux", |
| 194 | + "remotejdk21_macos", |
| 195 | + "remotejdk21_win", |
| 196 | + # //test/jmh:test_jmh_jdk8 |
| 197 | + "remote_jdk8_linux", |
| 198 | + "remote_jdk8_macos", |
| 199 | + "remote_jdk8_windows", |
| 200 | +) |
| 201 | + |
| 202 | +[ |
| 203 | + ( |
| 204 | + bazel_dep(name = name, dev_dependency = True), |
| 205 | + local_path_override(module_name = name, path = path) |
| 206 | + ) |
| 207 | + for name, path in [ |
| 208 | + ( |
| 209 | + "proto_cross_repo_boundary", |
| 210 | + "test/proto_cross_repo_boundary/repo", |
| 211 | + ), |
| 212 | + ( |
| 213 | + "test_new_local_repo", |
| 214 | + "third_party/test/new_local_repo", |
| 215 | + ), |
| 216 | + ( |
| 217 | + "example_external_workspace", |
| 218 | + "third_party/test/example_external_workspace", |
| 219 | + ), |
| 220 | + ] |
| 221 | +] |
| 222 | + |
| 223 | +bazel_dep( |
| 224 | + name = "bazel_ci_rules", |
| 225 | + version = "1.0.0", |
| 226 | + dev_dependency = True, |
| 227 | + repo_name = "bazelci_rules", |
| 228 | +) |
| 229 | +bazel_dep( |
| 230 | + name = "rules_go", |
| 231 | + version = "0.53.0", |
| 232 | + dev_dependency = True, |
| 233 | + repo_name = "io_bazel_rules_go", # for com_github_bazelbuild_buildtools |
| 234 | +) |
| 235 | +bazel_dep(name = "gazelle", version = "0.42.0", dev_dependency = True) |
| 236 | + |
| 237 | +go_sdk = use_extension( |
| 238 | + "@io_bazel_rules_go//go:extensions.bzl", |
| 239 | + "go_sdk", |
| 240 | + dev_dependency = True, |
| 241 | +) |
| 242 | +go_sdk.download(version = "1.24.1") |
| 243 | + |
| 244 | +go_deps = use_extension( |
| 245 | + "@gazelle//:extensions.bzl", |
| 246 | + "go_deps", |
| 247 | + dev_dependency = True, |
| 248 | +) |
| 249 | + |
| 250 | +# The go_deps.module calls are inspired by the following to get the |
| 251 | +# com_github_bazelbuild_buildtools repo to work: |
| 252 | +# |
| 253 | +# - https://github.com/bazelbuild/bazel-central-registry/blob/main/modules/gazelle/0.39.1/MODULE.bazel#L31-L57 |
| 254 | +# |
| 255 | +# To get the latest version and hashes for each per: |
| 256 | +# |
| 257 | +# - https://go.dev/ref/mod#go-list-m |
| 258 | +# - https://go.dev/ref/mod#checksum-database |
| 259 | +# |
| 260 | +# go list -m golang.org/x/tools@latest |
| 261 | +# curl https://sum.golang.org/lookup/golang.org/x/[email protected] |
| 262 | +go_deps.module( |
| 263 | + path = "golang.org/x/tools", |
| 264 | + sum = "h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=", |
| 265 | + version = "v0.30.0", |
| 266 | +) |
| 267 | + |
| 268 | +go_deps.module( |
| 269 | + path = "github.com/golang/protobuf", |
| 270 | + sum = "h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=", |
| 271 | + version = "v1.5.4", |
| 272 | +) |
| 273 | +use_repo( |
| 274 | + go_deps, |
| 275 | + "com_github_golang_protobuf", |
| 276 | + "org_golang_x_tools", |
| 277 | +) |
| 278 | + |
| 279 | +bazel_dep(name = "rules_python", version = "1.2.0", dev_dependency = True) |
0 commit comments