11"""Exports repos used by @io_bazel_rules_scala rules"""
22
3- load ("//jmh:jmh.bzl" , "jmh_repositories" )
4- load ("//junit:junit.bzl" , "junit_repositories" )
5- load ("//scala/private/extensions:toolchains.bzl" , "scala_toolchains_repo" )
6- load ("//scala/private:macros/scala_repositories.bzl" , "scala_repositories" )
7- load (
8- "//scala/scalafmt:scalafmt_repositories.bzl" ,
9- "scalafmt_default_config" ,
10- "scalafmt_repositories" ,
11- )
3+ load ("//scala/private:macros/toolchains.bzl" , "scala_toolchains" )
124load ("//scala:scala_cross_version.bzl" , "default_maven_server_urls" )
13- load ("//scala_proto:scala_proto.bzl" , "scala_proto_repositories" )
14- load ("//scalatest:scalatest.bzl" , "scalatest_repositories" )
15- load ("//specs2:specs2_junit.bzl" , "specs2_junit_repositories" )
16- load ("//testing/private:repositories.bzl" , "testing_repositories" )
17- load ("//twitter_scrooge:twitter_scrooge.bzl" , "twitter_scrooge" )
18- load ("@io_bazel_rules_scala_config//:config.bzl" , "SCALA_VERSIONS" )
195
206# The _defaults() and _to_attrs() schema compensates for the fact that there's
217# no way to pull the default value from an `attr` object. Without this, we'd
@@ -41,7 +27,7 @@ _settings = {
4127 "default" : {},
4228 },
4329 ),
44- "load_toolchain_dependencies " : struct (
30+ "load_scala_toolchain_dependencies " : struct (
4531 attr = attr .bool ,
4632 params = {
4733 "default" : True ,
@@ -84,12 +70,12 @@ _toolchains_attrs = {
8470 "scalatest" : attr .bool (),
8571 "junit" : attr .bool (),
8672 "specs2" : attr .bool (),
87- "twitter_scrooge" : attr .bool (),
88- "jmh" : attr .bool (),
89- "scala_proto" : attr .bool (),
90- "scala_proto_enable_all_options" : attr .bool (),
9173 "testing" : attr .bool (),
9274 "scalafmt" : attr .bool (),
75+ "scala_proto" : attr .bool (),
76+ "scala_proto_enable_all_options" : attr .bool (),
77+ "twitter_scrooge" : attr .bool (),
78+ "jmh" : attr .bool (),
9379}
9480
9581def _get_root_module (module_ctx ):
@@ -167,7 +153,7 @@ def _get_settings(module_ctx):
167153 scalafmt = _compile_root_tags (module_ctx , "scalafmt" , _defaults (_scalafmt ))
168154
169155 return (
170- settings ["load_toolchain_dependencies " ],
156+ settings ["load_scala_toolchain_dependencies " ],
171157 settings ["maven_servers" ],
172158 settings ["overridden_artifacts" ],
173159 settings ["fetch_sources" ],
@@ -235,101 +221,26 @@ def _get_toolchains(module_ctx):
235221
236222def _scala_deps_impl (module_ctx ):
237223 (
238- load_toolchain_dependencies ,
224+ load_scala_toolchain_dependencies ,
239225 maven_servers ,
240226 overridden_artifacts ,
241227 fetch_sources ,
242228 validate_scala_version ,
243229 scalafmt_default_config_path ,
244230 ) = _get_settings (module_ctx )
245- compiler_srcjars = _get_scala_compiler_srcjars (module_ctx )
246- toolchains = _get_toolchains (module_ctx )
247231
248- scala_repositories (
232+ scala_toolchains (
249233 maven_servers = maven_servers ,
250- # Note the internal macro parameter misspells "overriden".
251- overriden_artifacts = overridden_artifacts ,
252- load_dep_rules = False , # MODULE.bazel loads dependencies now.
253- load_jar_deps = load_toolchain_dependencies ,
234+ overridden_artifacts = overridden_artifacts ,
235+ load_rules_scala_dependencies = False , # MODULE.bazel loads these now.
236+ load_scala_toolchain_dependencies = load_scala_toolchain_dependencies ,
254237 fetch_sources = fetch_sources ,
255238 validate_scala_version = validate_scala_version ,
256- scala_compiler_srcjars = compiler_srcjars ,
239+ scala_compiler_srcjars = _get_scala_compiler_srcjars (module_ctx ),
240+ scalafmt_default_config_path = scalafmt_default_config_path ,
241+ ** _get_toolchains (module_ctx )
257242 )
258243
259- if "scalatest" in toolchains :
260- scalatest_repositories (
261- maven_servers = maven_servers ,
262- fetch_sources = fetch_sources ,
263- )
264-
265- for scala_version in SCALA_VERSIONS :
266- if "junit" in toolchains :
267- junit_repositories (
268- maven_servers = maven_servers ,
269- scala_version = scala_version ,
270- overriden_artifacts = overridden_artifacts ,
271- fetch_sources = fetch_sources ,
272- )
273- if "specs2" in toolchains :
274- specs2_junit_repositories (
275- maven_servers = maven_servers ,
276- scala_version = scala_version ,
277- overriden_artifacts = overridden_artifacts ,
278- create_junit_repositories = "junit" not in toolchains ,
279- )
280- if (
281- "scala_proto" in toolchains or
282- "scala_proto_enable_all_options" in toolchains
283- ):
284- scala_proto_repositories (
285- maven_servers = maven_servers ,
286- scala_version = scala_version ,
287- overriden_artifacts = overridden_artifacts ,
288- register_toolchains = False ,
289- )
290-
291- if "twitter_scrooge" in toolchains :
292- twitter_scrooge (
293- maven_servers = maven_servers ,
294- overriden_artifacts = overridden_artifacts ,
295- bzlmod_enabled = True ,
296- )
297-
298- if "jmh" in toolchains :
299- jmh_repositories (
300- maven_servers = maven_servers ,
301- overriden_artifacts = overridden_artifacts ,
302- bzlmod_enabled = True ,
303- )
304- if "testing" in toolchains :
305- testing_repositories (
306- maven_servers = maven_servers ,
307- fetch_sources = False ,
308- )
309- if "scalafmt" in toolchains :
310- scalafmt_default_config (scalafmt_default_config_path )
311- scalafmt_repositories (
312- maven_servers = maven_servers ,
313- overriden_artifacts = overridden_artifacts ,
314- bzlmod_enabled = True ,
315- )
316-
317- if len (toolchains ) != 0 :
318- scala_toolchains_repo (
319- scala = "scala" in toolchains ,
320- scalatest = "scalatest" in toolchains ,
321- junit = "junit" in toolchains ,
322- specs2 = "specs2" in toolchains ,
323- twitter_scrooge = "twitter_scrooge" in toolchains ,
324- jmh = "jmh" in toolchains ,
325- scala_proto = "scala_proto" in toolchains ,
326- scala_proto_enable_all_options = (
327- "scala_proto_enable_all_options" in toolchains
328- ),
329- testing = "testing" in toolchains ,
330- scalafmt = "scalafmt" in toolchains ,
331- )
332-
333244scala_deps = module_extension (
334245 implementation = _scala_deps_impl ,
335246 tag_classes = {
0 commit comments