Skip to content

Commit 313ce9a

Browse files
committed
WIP: Bzlmod part the one hundred twenty-fifth
Refactor scala_toolchains to use `artifact_ids_to_fetch_sources`.
1 parent c7eb1c7 commit 313ce9a

File tree

2 files changed

+41
-37
lines changed

2 files changed

+41
-37
lines changed

MODULE.bazel.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scala/private/macros/toolchains.bzl

+40-36
Original file line numberDiff line numberDiff line change
@@ -122,60 +122,64 @@ def scala_toolchains(
122122
if specs2:
123123
junit = True
124124

125-
artifact_ids = []
126-
fetch_sources_by_id = {}
125+
artifact_ids_to_fetch_sources = {}
127126

128127
if scalatest:
129-
scalatest_artifacts = scalatest_artifact_ids()
130-
artifact_ids.extend(scalatest_artifacts)
131-
fetch_sources_by_id.update({id: True for id in scalatest_artifacts})
128+
artifact_ids_to_fetch_sources.update({
129+
id: True
130+
for id in scalatest_artifact_ids()
131+
})
132132
if junit:
133-
junit_artifacts = junit_artifact_ids()
134-
artifact_ids.extend(junit_artifacts)
135-
fetch_sources_by_id.update({id: True for id in junit_artifacts})
133+
artifact_ids_to_fetch_sources.update({
134+
id: True
135+
for id in junit_artifact_ids()
136+
})
136137
if specs2:
137-
specs2_artifacts = specs2_artifact_ids() + specs2_junit_artifact_ids()
138-
artifact_ids.extend(specs2_artifacts)
139-
fetch_sources_by_id.update({id: True for id in specs2_artifacts})
138+
artifact_ids_to_fetch_sources.update({
139+
id: True
140+
for id in specs2_artifact_ids() + specs2_junit_artifact_ids()
141+
})
140142
if jmh:
141-
jmh_artifacts = jmh_artifact_ids()
142-
artifact_ids.extend(jmh_artifacts)
143-
fetch_sources_by_id.update({id: False for id in jmh_artifacts})
143+
artifact_ids_to_fetch_sources.update({
144+
id: False
145+
for id in jmh_artifact_ids()
146+
})
144147
if twitter_scrooge:
145-
scrooge_artifacts = twitter_scrooge_artifact_ids(
146-
libthrift = libthrift,
147-
scrooge_core = scrooge_core,
148-
scrooge_generator = scrooge_generator,
149-
util_core = util_core,
150-
util_logging = util_logging,
151-
)
152-
artifact_ids.extend(scrooge_artifacts)
153-
fetch_sources_by_id.update({id: False for id in scrooge_artifacts})
148+
artifact_ids_to_fetch_sources.update({
149+
id: False
150+
for id in twitter_scrooge_artifact_ids(
151+
libthrift = libthrift,
152+
scrooge_core = scrooge_core,
153+
scrooge_generator = scrooge_generator,
154+
util_core = util_core,
155+
util_logging = util_logging,
156+
)
157+
})
154158

155159
for scala_version in SCALA_VERSIONS:
156-
version_specific_artifact_ids = []
160+
version_specific_artifact_ids = {}
157161

158162
if scala_proto:
159-
scala_proto_artifacts = scala_proto_artifact_ids(scala_version)
160-
version_specific_artifact_ids.extend(scala_proto_artifacts)
161-
fetch_sources_by_id.update({
163+
version_specific_artifact_ids.update({
162164
id: True
163-
for id in scala_proto_artifacts
165+
for id in scala_proto_artifact_ids(scala_version)
164166
})
165167
if scalafmt:
166-
version_specific_artifact_ids.extend(
167-
scalafmt_artifact_ids(scala_version),
168-
)
168+
version_specific_artifact_ids.update({
169+
id: fetch_sources
170+
for id in scalafmt_artifact_ids(scala_version)
171+
})
172+
173+
all_artifacts = (
174+
artifact_ids_to_fetch_sources | version_specific_artifact_ids
175+
)
169176

170177
repositories(
171178
scala_version = scala_version,
172-
for_artifact_ids = {
173-
id: True
174-
for id in (artifact_ids + version_specific_artifact_ids)
175-
}.keys(),
179+
for_artifact_ids = all_artifacts.keys(),
176180
maven_servers = maven_servers,
177181
fetch_sources = fetch_sources,
178-
fetch_sources_by_id = fetch_sources_by_id,
182+
fetch_sources_by_id = all_artifacts,
179183
overriden_artifacts = overridden_artifacts,
180184
validate_scala_version = validate_scala_version,
181185
)

0 commit comments

Comments
 (0)