Skip to content

Commit d9e701d

Browse files
authored
Merge pull request #74 from lucidsoftware/bzlmod-migration
Migrate to Bzlmod
2 parents ceef5c1 + 5de9438 commit d9e701d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3146
-2452
lines changed

.bazelrc_shared

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ test --test_output=all
4141

4242
common:rules --disk_cache=.bazel_cache
4343
common:tests --disk_cache=../.bazel_cache
44+
common:tests --@rules_scala_annex//rules/scala:scala-toolchain=test_zinc_2_13

BUILD

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
21
load(
32
"@rules_java//toolchains:default_java_toolchain.bzl",
43
"DEFAULT_TOOLCHAIN_CONFIGURATION",
54
"default_java_toolchain",
65
)
6+
load("//rules/scalafmt:register_toolchain.bzl", "register_scalafmt_toolchain")
77

88
default_java_toolchain(
99
name = "repository_default_toolchain_21",
@@ -14,11 +14,7 @@ default_java_toolchain(
1414
target_version = "21",
1515
)
1616

17-
buildifier(
18-
name = "buildifier",
19-
)
20-
21-
buildifier(
22-
name = "buildifier_check",
23-
mode = "check",
17+
register_scalafmt_toolchain(
18+
name = "annex_scalafmt",
19+
config = ".scalafmt.conf",
2420
)

CONTRIBUTING.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,32 @@ $ ./scripts/format.sh
2121

2222
## Maven deps
2323

24-
[rules_jvm_external](https://github.com/bazel-contrib/rules_jvm_external) is used to generate maven deps. If you need to change
25-
dependencies, modify `maven_install` in the following different `workspace.bzl` files
24+
[rules_jvm_external](https://github.com/bazel-contrib/rules_jvm_external) is used to resolve Maven
25+
dependencies. If you need to change dependencies, add your artifacts to the `annex*.install` calls
26+
in [`MODULE.bazel`](MODULE.bazel) or [`tests/MODULE.bazel`](tests/MODULE.bazel).
2627

27-
```
28-
rules/scala/workspace.bzl
29-
rules/scala_proto/workspace.bzl
30-
rules/scalafmt/workspace.bzl
31-
tests/workspace.bzl
32-
```
33-
To reference the dependency, use the `name` attribute of the `maven_install` rule as the repository name and the versionless dependency as the target. E.g. `@<maven_install_name>//:<versionless_dependency>`.
28+
To reference the dependency, use the `name` attribute of the `annex*.install` call as the
29+
repository name and the versionless dependency as the target. E.g.
30+
`@<maven_install_name>//:<versionless_dependency>`.
3431

35-
For example, if you'd like to add `org.scala-sbt:compiler-interface:1.2.1` as a dependency, simply add it to the `artifacts` list in `maven_install` with the attribute `name = "annex"`, and then refer to it with `@annex//:org_scala_sbt_compiler_interface`.
32+
For example, if you'd like to add `org.scala-sbt:compiler-interface:1.2.1` as a dependency, simply
33+
add it to the `artifacts` list of the `maven.install` call, and then refer to it with
34+
`@annex//:org_scala_sbt_compiler_interface`.
3635

37-
```
38-
maven_install(
36+
```starlark
37+
annex.install(
3938
name = "annex",
4039
artifacts = [
40+
...,
4141
"org.scala-sbt:compiler-interface:1.2.1",
42+
...,
4243
],
44+
fetch_sources = True,
45+
lock_file = "//:annex_install.json",
4346
repositories = [
4447
"https://repo.maven.apache.org/maven2",
48+
"https://maven-central.storage-download.googleapis.com/maven2",
49+
"https://mirror.bazel.build/repo1.maven.org/maven2",
4550
],
4651
)
4752
```

MODULE.bazel

Lines changed: 147 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,147 @@
1-
###############################################################################
2-
# Bazel now uses Bzlmod by default to manage external dependencies.
3-
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
4-
#
5-
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
6-
###############################################################################
1+
module(name = "rules_scala_annex")
2+
3+
bazel_dep(name = "bazel_skylib", version = "1.7.1")
4+
5+
bazel_dep(name = "buildifier_prebuilt", version = "7.3.1", dev_dependency = True)
6+
7+
bazel_dep(name = "rules_java", version = "7.12.2")
8+
bazel_dep(name = "rules_jvm_external", version = "6.5")
9+
10+
bazel_dep(name = "rules_pkg", version = "1.0.1", dev_dependency = True)
11+
bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True)
12+
13+
register_toolchains(
14+
"//:annex_scalafmt",
15+
"//:repository_default_toolchain_21_definition",
16+
"//rules/scala_proto:scalapb_scala_proto_toolchain",
17+
"//src/main/scala:annex_bootstrap_2_13",
18+
"//src/main/scala:annex_bootstrap_3",
19+
"//src/main/scala:annex_zinc_2_13",
20+
"//src/main/scala:annex_zinc_3",
21+
)
22+
23+
# Please ensure these stay up-to-date with the versions in `/rules/scala/versions.bzl`,
24+
# `/tests/MODULE.bazel`, and `/MODULE.bazel`. Unfortunately, `MODULE.bazel` files can't call `load`,
25+
# so we have to copy them here.
26+
scala_2_12_version = "2.12.19"
27+
28+
scala_2_13_version = "2.13.15"
29+
30+
scala_3_version = "3.5.2"
31+
32+
scalapb_version = "0.11.17"
33+
34+
zinc_version = "1.10.4"
35+
36+
annex = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
37+
annex.install(
38+
name = "annex",
39+
artifacts = [
40+
"ch.epfl.scala:bloop-frontend_2.12:1.0.0",
41+
"com.thesamet.scalapb:lenses_2.13:{}".format(scalapb_version),
42+
"com.thesamet.scalapb:scalapb-runtime_2.13:{}".format(scalapb_version),
43+
"net.sourceforge.argparse4j:argparse4j:0.8.1",
44+
"org.jacoco:org.jacoco.core:0.7.5.201505241946",
45+
"org.scala-lang:scala-compiler:{}".format(scala_2_13_version),
46+
"org.scala-lang:scala-library:{}".format(scala_2_13_version),
47+
"org.scala-lang:scala-reflect:{}".format(scala_2_13_version),
48+
"org.scala-lang:scala3-compiler_3:{}".format(scala_3_version),
49+
"org.scala-lang:scala3-library_3:{}".format(scala_3_version),
50+
"org.scala-sbt:compiler-interface:{}".format(zinc_version),
51+
"org.scala-sbt:io_2.13:1.10.1",
52+
"org.scala-sbt:test-interface:1.0",
53+
"org.scala-sbt:util-interface:{}".format(zinc_version),
54+
"org.scala-sbt:util-logging_2.13:{}".format(zinc_version),
55+
"org.scala-sbt:zinc_2.13:{}".format(zinc_version),
56+
"org.scala-sbt:zinc-apiinfo_2.13:{}".format(zinc_version),
57+
"org.scala-sbt:zinc-classpath_2.13:{}".format(zinc_version),
58+
"org.scala-sbt:zinc-compile-core_2.13:{}".format(zinc_version),
59+
"org.scala-sbt:zinc-core_2.13:{}".format(zinc_version),
60+
"org.scala-sbt:zinc-persist_2.13:{}".format(zinc_version),
61+
],
62+
fetch_sources = True,
63+
lock_file = "//:annex_install.json",
64+
repositories = [
65+
"https://repo.maven.apache.org/maven2",
66+
"https://maven-central.storage-download.googleapis.com/maven2",
67+
"https://mirror.bazel.build/repo1.maven.org/maven2",
68+
],
69+
)
70+
71+
# The compiler bridge has a dependency on compiler-interface, which has a dependency on the Scala 2
72+
# library. We need to set this to neverlink = True to avoid this the Scala 2 library being pulled
73+
# onto the Scala 3, and other Scala versions like 2.12, compiler classpath during runtime.
74+
annex.artifact(
75+
name = "annex",
76+
artifact = "scala3-sbt-bridge",
77+
group = "org.scala-lang",
78+
neverlink = True,
79+
version = scala_3_version,
80+
)
81+
82+
# The compiler bridge has a dependency on compiler-interface, which has a dependency on the Scala 2
83+
# library. We need to set this to neverlink = True to avoid this the Scala 2 library being pulled
84+
# onto the Scala 3, and other Scala versions like 2.12, compiler classpath during runtime.
85+
annex.artifact(
86+
name = "annex",
87+
artifact = "compiler-bridge_2.13",
88+
group = "org.scala-sbt",
89+
neverlink = True,
90+
version = zinc_version,
91+
)
92+
use_repo(annex, "annex")
93+
94+
annex_scalafmt = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
95+
annex_scalafmt.install(
96+
name = "annex_scalafmt",
97+
artifacts = [
98+
"org.scalameta:parsers_2.13:4.9.7",
99+
"org.scalameta:metaconfig-core_2.13:0.13.0",
100+
"org.scalameta:scalafmt-core_2.13:3.8.2",
101+
],
102+
fetch_sources = True,
103+
lock_file = "//:annex_scalafmt_install.json",
104+
repositories = [
105+
"https://repo.maven.apache.org/maven2",
106+
"https://maven-central.storage-download.googleapis.com/maven2",
107+
"https://mirror.bazel.build/repo1.maven.org/maven2",
108+
],
109+
)
110+
use_repo(annex_scalafmt, "annex_scalafmt")
111+
112+
annex_proto = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
113+
annex_proto.install(
114+
name = "annex_proto",
115+
artifacts = [
116+
"com.github.os72:protoc-jar:3.11.4",
117+
"com.thesamet.scalapb:compilerplugin_2.13:0.11.17",
118+
"com.thesamet.scalapb:protoc-bridge_2.13:0.9.7",
119+
],
120+
fetch_sources = True,
121+
lock_file = "//:annex_proto_install.json",
122+
repositories = [
123+
"https://repo.maven.apache.org/maven2",
124+
"https://maven-central.storage-download.googleapis.com/maven2",
125+
"https://mirror.bazel.build/repo1.maven.org/maven2",
126+
],
127+
)
128+
use_repo(annex_proto, "annex_proto")
129+
130+
java_launcher_version = "7.4.1"
131+
132+
java_launcher_template_sha = "ee4aa47ae5e639632c67be5cc0ccbc4e941a67a1b884a1ce0c4329357a4b62b2"
133+
134+
java_stub_template_url = (
135+
"raw.githubusercontent.com/bazelbuild/bazel/" +
136+
java_launcher_version +
137+
"/src/main/java/com/google/devtools/build/lib/bazel/rules/java/" +
138+
"java_stub_template.txt"
139+
)
140+
141+
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
142+
143+
http_file(
144+
name = "anx_java_stub_template",
145+
sha256 = java_launcher_template_sha,
146+
urls = ["https://%s" % java_stub_template_url],
147+
)

0 commit comments

Comments
 (0)