|
| 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 = [">=6.5.0", "<8.0.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.15", |
| 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 | + |
| 31 | +# Bazel 6 breaks with any higher version of `rules_cc`, because: |
| 32 | +# - 0.0.10 requires Bazel 7 to define `CcSharedLibraryHintInfo` |
| 33 | +# - 0.0.13 and up don't support `protobuf` v21.7, requiring at least v27.0 |
| 34 | +# - 0.1.0 should work, but requires `stardoc` 0.7.0, which requires Bazel 7 |
| 35 | +# (though it's a `dev_dependency`, it still gets pulled in during analysis, |
| 36 | +# breaking the build) |
| 37 | +bazel_dep(name = "rules_cc", version = "0.0.9") |
| 38 | +single_version_override( |
| 39 | + module_name = "rules_cc", |
| 40 | + version = "0.0.9", |
| 41 | +) |
| 42 | + |
| 43 | +bazel_dep(name = "rules_java", version = "7.12.4") |
| 44 | +bazel_dep(name = "rules_proto", version = "6.0.2") |
| 45 | + |
| 46 | +# For now, users are revlocked to protobuf-21.7 or protobuf-25.5 (which doesn't |
| 47 | +# build under Bazel 6). |
| 48 | +bazel_dep( |
| 49 | + name = "protobuf", |
| 50 | + version = "21.7", |
| 51 | + repo_name = "com_google_protobuf", |
| 52 | +) |
| 53 | +single_version_override( |
| 54 | + module_name = "protobuf", |
| 55 | + version = "21.7", |
| 56 | +) |
| 57 | + |
| 58 | +scala_config = use_extension( |
| 59 | + "//scala/extensions:config.bzl", |
| 60 | + "scala_config", |
| 61 | +) |
| 62 | +use_repo(scala_config, "io_bazel_rules_scala_config") |
| 63 | + |
| 64 | +dev_config = use_extension( |
| 65 | + "//scala/extensions:config.bzl", |
| 66 | + "scala_config", |
| 67 | + dev_dependency = True, |
| 68 | +) |
| 69 | +dev_config.settings( |
| 70 | + enable_compiler_dependency_tracking = True, |
| 71 | + scala_version = SCALA_VERSION, |
| 72 | + scala_versions = SCALA_VERSIONS, |
| 73 | +) |
| 74 | + |
| 75 | +scala_deps = use_extension("//scala/extensions:deps.bzl", "scala_deps") |
| 76 | + |
| 77 | +# Register some of our testing toolchains first when building our repo. |
| 78 | +register_toolchains( |
| 79 | + "//scala:unused_dependency_checker_error_toolchain", |
| 80 | + "//test/proto:scalapb_toolchain", |
| 81 | + "//test/toolchains:java21_toolchain_definition", |
| 82 | + dev_dependency = True, |
| 83 | +) |
| 84 | + |
| 85 | +use_repo( |
| 86 | + scala_deps, |
| 87 | + "rules_scala_toolchains", |
| 88 | + "scala_compiler_sources", |
| 89 | +) |
| 90 | + |
| 91 | +register_toolchains("@rules_scala_toolchains//...:all") |
| 92 | + |
| 93 | +# Dev dependencies |
| 94 | + |
| 95 | +dev_deps = use_extension( |
| 96 | + "//scala/extensions:deps.bzl", |
| 97 | + "scala_deps", |
| 98 | + dev_dependency = True, |
| 99 | +) |
| 100 | +dev_deps.toolchains( |
| 101 | + jmh = True, |
| 102 | + scala_proto = True, |
| 103 | + #scala_proto_enable_all_options = True, |
| 104 | + scalafmt = True, |
| 105 | + testing = True, |
| 106 | + #scalatest = True, |
| 107 | + #junit = True, |
| 108 | + #specs2 = True, |
| 109 | + twitter_scrooge = True, |
| 110 | +) |
| 111 | + |
| 112 | +use_repo( |
| 113 | + dev_deps, |
| 114 | + "scala_proto_rules_scalapb_compilerplugin", |
| 115 | + "scala_proto_rules_scalapb_protoc_bridge", |
| 116 | + "scalafmt_default", |
| 117 | +) |
| 118 | + |
| 119 | +# Default versions of version specific repos needed by some of our tests. Tests |
| 120 | +# that set `--repo_env=SCALA_VERSION=...` break without using the default here, |
| 121 | +# because version specific repos for other versions won't be available. |
| 122 | +use_repo( |
| 123 | + dev_deps, |
| 124 | + "io_bazel_rules_scala_guava", |
| 125 | + "io_bazel_rules_scala_junit_junit", |
| 126 | + "io_bazel_rules_scala_scala_compiler", |
| 127 | + "io_bazel_rules_scala_scala_library", |
| 128 | +) |
| 129 | + |
| 130 | +[ |
| 131 | + [ |
| 132 | + use_repo(dev_deps, dep + "_" + scala_version.replace(".", "_")) |
| 133 | + for dep in [ |
| 134 | + "io_bazel_rules_scala_junit_junit", |
| 135 | + "io_bazel_rules_scala_scala_compiler", |
| 136 | + "io_bazel_rules_scala_scala_library", |
| 137 | + ] + ( |
| 138 | + # We can remove this condition once we drop support for Scala 2.11. |
| 139 | + ["scala_proto_rules_scalapb_protoc_gen"] |
| 140 | + if not scala_version.startswith("2.11.") else [] |
| 141 | + ) |
| 142 | + ] |
| 143 | + for scala_version in SCALA_VERSIONS |
| 144 | +] |
| 145 | + |
| 146 | +[ |
| 147 | + [ |
| 148 | + use_repo(dev_deps, dep + "_" + scala_version.replace(".", "_")) |
| 149 | + for dep in [ |
| 150 | + "io_bazel_rules_scala_scala_reflect", |
| 151 | + ] |
| 152 | + ] |
| 153 | + for scala_version in SCALA_2_VERSIONS |
| 154 | +] |
| 155 | + |
| 156 | +[ |
| 157 | + [ |
| 158 | + use_repo(dev_deps, dep + "_" + scala_version.replace(".", "_")) |
| 159 | + for dep in [ |
| 160 | + "io_bazel_rules_scala_scala_compiler_2", |
| 161 | + "io_bazel_rules_scala_scala_library_2", |
| 162 | + "io_bazel_rules_scala_scala_reflect_2", |
| 163 | + ] |
| 164 | + ] |
| 165 | + for scala_version in SCALA_3_VERSIONS |
| 166 | +] |
| 167 | + |
| 168 | +internal_dev_deps = use_extension( |
| 169 | + "//scala/private/extensions:dev_deps.bzl", |
| 170 | + "dev_deps", |
| 171 | + dev_dependency = True, |
| 172 | +) |
| 173 | + |
| 174 | +# See //scala/private:extensions/dev_deps.bzl for notes on some of these repos. |
| 175 | +use_repo( |
| 176 | + internal_dev_deps, |
| 177 | + "com_github_bazelbuild_buildtools", |
| 178 | + "com_github_jnr_jffi_native", |
| 179 | + "com_google_guava_guava_21_0", |
| 180 | + "com_google_guava_guava_21_0_with_file", |
| 181 | + "com_twitter__scalding_date", |
| 182 | + "org_apache_commons_commons_lang_3_5", |
| 183 | + "org_apache_commons_commons_lang_3_5_without_file", |
| 184 | + "org_springframework_spring_core", |
| 185 | + "org_springframework_spring_tx", |
| 186 | + "org_typelevel__cats_core", |
| 187 | + "org_typelevel_kind_projector", |
| 188 | +) |
| 189 | + |
| 190 | +java_toolchains = use_extension( |
| 191 | + "@rules_java//java:extensions.bzl", |
| 192 | + "toolchains", |
| 193 | + dev_dependency = True, |
| 194 | +) |
| 195 | + |
| 196 | +use_repo( |
| 197 | + java_toolchains, |
| 198 | + # //test/toolchains:java21_toolchain |
| 199 | + "remotejdk21_linux", |
| 200 | + "remotejdk21_macos", |
| 201 | + "remotejdk21_win", |
| 202 | + # //test/jmh:test_jmh_jdk8 |
| 203 | + "remote_jdk8_linux", |
| 204 | + "remote_jdk8_macos", |
| 205 | + "remote_jdk8_windows", |
| 206 | +) |
| 207 | + |
| 208 | +[ |
| 209 | + ( |
| 210 | + bazel_dep(name = name, dev_dependency = True), |
| 211 | + local_path_override(module_name = name, path = path) |
| 212 | + ) |
| 213 | + for name, path in [ |
| 214 | + ( |
| 215 | + "proto_cross_repo_boundary", |
| 216 | + "test/proto_cross_repo_boundary/repo", |
| 217 | + ), |
| 218 | + ( |
| 219 | + "test_new_local_repo", |
| 220 | + "third_party/test/new_local_repo", |
| 221 | + ), |
| 222 | + ( |
| 223 | + "example_external_workspace", |
| 224 | + "third_party/test/example_external_workspace", |
| 225 | + ), |
| 226 | + ] |
| 227 | +] |
| 228 | + |
| 229 | +bazel_dep( |
| 230 | + name = "platforms", |
| 231 | + version = "0.0.11", |
| 232 | + dev_dependency = True, |
| 233 | +) |
| 234 | +bazel_dep( |
| 235 | + name = "bazel_ci_rules", |
| 236 | + version = "1.0.0", |
| 237 | + dev_dependency = True, |
| 238 | + repo_name = "bazelci_rules", |
| 239 | +) |
| 240 | +bazel_dep( |
| 241 | + name = "rules_go", |
| 242 | + version = "0.53.0", |
| 243 | + dev_dependency = True, |
| 244 | + repo_name = "io_bazel_rules_go", # for com_github_bazelbuild_buildtools |
| 245 | +) |
| 246 | +bazel_dep(name = "gazelle", version = "0.42.0", dev_dependency = True) |
| 247 | + |
| 248 | +go_sdk = use_extension( |
| 249 | + "@io_bazel_rules_go//go:extensions.bzl", |
| 250 | + "go_sdk", |
| 251 | + dev_dependency = True, |
| 252 | +) |
| 253 | +go_sdk.download(version = "1.24.0") |
| 254 | + |
| 255 | +go_deps = use_extension( |
| 256 | + "@gazelle//:extensions.bzl", |
| 257 | + "go_deps", |
| 258 | + dev_dependency = True, |
| 259 | +) |
| 260 | + |
| 261 | +# The go_deps.module calls are inspired by the following to get the |
| 262 | +# com_github_bazelbuild_buildtools repo to work: |
| 263 | +# |
| 264 | +# - https://github.com/bazelbuild/bazel-central-registry/blob/main/modules/gazelle/0.39.1/MODULE.bazel#L31-L57 |
| 265 | +# |
| 266 | +# To get the latest version and hashes for each per: |
| 267 | +# |
| 268 | +# - https://go.dev/ref/mod#go-list-m |
| 269 | +# - https://go.dev/ref/mod#checksum-database |
| 270 | +# |
| 271 | +# go list -m golang.org/x/tools@latest |
| 272 | +# curl https://sum.golang.org/lookup/golang.org/x/tools@v0.29.0 |
| 273 | +go_deps.module( |
| 274 | + path = "golang.org/x/tools", |
| 275 | + sum = "h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY=", |
| 276 | + version = "v0.30.0", |
| 277 | +) |
| 278 | + |
| 279 | +go_deps.module( |
| 280 | + path = "github.com/golang/protobuf", |
| 281 | + sum = "h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=", |
| 282 | + version = "v1.5.4", |
| 283 | +) |
| 284 | +use_repo( |
| 285 | + go_deps, |
| 286 | + "com_github_golang_protobuf", |
| 287 | + "org_golang_x_tools", |
| 288 | +) |
| 289 | + |
| 290 | +bazel_dep(name = "rules_python", version = "0.38.0", dev_dependency = True) |
0 commit comments