Skip to content

Commit a8f1d2d

Browse files
authored
Migrate rules_closure to bzlmod (bazelbuild#635)
* Migrate rules_closure to Bzlmod * Migrate rules_closure to Bzlmod * Migrate rules_closure to Bzlmod * import the change of abseil cpp's fix of Compilation error for filesystem * More polish * Update protobuf test to use jssuite from forked files * Update bazel version * Migrate to bzlmod * Update protobuf test to use jssuite from forked files * Update protobuf test to use jssuite from forked files and remove usage of assertHTMLEquals * remove repositories.bzl * Remove legacy protobuf test * Add back legacy test * Add a blank line at the end of legacy example test * Update legacy test to use forked jsunit and asserts * Update legacy test to use forked jsunit and asserts * Add back require line and remove additional msg.field() * Rename BUILD.bazel to BUILD * rename remaining files of BUILD.bazel to BUILD * Remove unused deps * Revert unneccessary change * Remove some leftovers * Remove duplicate bazel_dep for javacc and modify README * Move stylesheet compiler target to local and add back stylesheet test and modify readme * Resolve some comments * Respond to comments * Clean up some unneccessary deps * Move stylesheets compiler to its own build file * More polish * Modify README.md command * Override archive for rules_webtesting * Modify readme to be consisitent with module name * Remove dev_dependency in platform dep as it is needed in j2cl * Resolve some comments * Revert Order * Remove guava dagger and autovalue deps * More cleanup * Remove more deps with bazel_common deps * Clean up some deps * revert mockito deps as it breaks WorkerTestSuite * Replace more deps to use indirect deps from bazel_common * Modify readme and resolve mockito * Some cleanup * Revert * Add a commit for the work around * Update MODULE.bazel README.md and delete bazelversion * Add abseil to fix linux build error * Remove WORKSPACE * Remove unneeded files * More polish * More polish * Resolve more comments
1 parent c8508a6 commit a8f1d2d

33 files changed

Lines changed: 365 additions & 1191 deletions

File tree

.bazelversion

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/bazel-*
2+
MODULE.bazel.lock
3+

MODULE.bazel

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
module(
2+
name = "io_bazel_rules_closure",
3+
version = "0.15.0",
4+
)
5+
6+
bazel_dep(
7+
name = "bazel_skylib",
8+
version = "1.7.1",
9+
)
10+
11+
bazel_dep(
12+
name = "platforms",
13+
version = "0.0.5",
14+
)
15+
16+
# TODO(mollyibot): Remove this in the future.
17+
bazel_dep(
18+
name = "rules_proto",
19+
version = "7.0.2",
20+
)
21+
22+
bazel_dep(
23+
name = "protobuf",
24+
version = "29.1",
25+
repo_name = "com_google_protobuf",
26+
)
27+
28+
#TODO(mollyibot):Remove this after switching to new protobuf release
29+
bazel_dep(
30+
name = "abseil-cpp",
31+
version = "20240722.0",
32+
)
33+
34+
bazel_dep(name = "google_bazel_common")
35+
36+
git_override(
37+
module_name = "google_bazel_common",
38+
commit = "34102e4cf748e2922697f28f629ecea687345254",
39+
remote = "https://github.com/google/bazel-common",
40+
)
41+
42+
# TODO: Switch to a release version once it's available in BCR.
43+
# Otherwise, the root module has to declare the same override.
44+
bazel_dep(
45+
name = "rules_webtesting",
46+
repo_name = "io_bazel_rules_webtesting",
47+
)
48+
49+
git_override(
50+
module_name = "rules_webtesting",
51+
commit = "46b744fa916b5cefce6f0f84252f4ec89128a01b",
52+
remote = "https://github.com/bazelbuild/rules_webtesting",
53+
)
54+
55+
# TODO(mollyibot): Needed by rules_webtesting.
56+
git_override(
57+
module_name = "rules_scala",
58+
commit = "031fb0d3a63467d87f25397eb8e23faa57d1d3a6",
59+
remote = "https://github.com/mbland/rules_scala",
60+
)
61+
62+
##### Java dependencies #####
63+
bazel_dep(
64+
name = "rules_java",
65+
version = "8.6.1",
66+
)
67+
68+
bazel_dep(
69+
name = "rules_jvm_external",
70+
version = "6.6",
71+
)
72+
73+
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
74+
75+
maven.install(
76+
artifacts = [
77+
"args4j:args4j:2.33",
78+
"com.google.closure-stylesheets:closure-stylesheets:1.5.0",
79+
"com.google.dagger:dagger-producers:2.43.2",
80+
"com.google.jimfs:jimfs:1.1",
81+
"net.java.dev.javacc:javacc:7.0.13",
82+
"org.jsoup:jsoup:1.16.1",
83+
"org.seleniumhq.selenium:selenium-remote-driver:4.27.0",
84+
"org.seleniumhq.selenium:selenium-api:4.27.0",
85+
"org.seleniumhq.selenium:selenium-support:4.27.0",
86+
],
87+
)
88+
89+
# Using maven.artifact here because the version number vxxxxx cannot parsed correctly.
90+
maven.artifact(
91+
artifact = "closure-compiler",
92+
group = "com.google.javascript",
93+
version = "v20240317",
94+
)
95+
96+
# javacc:javacc was not updated since 2008 and relocated to net.java.dev.javacc
97+
maven.override(
98+
coordinates = "javacc:javacc",
99+
target = "@maven//:net_java_dev_javacc_javacc",
100+
)
101+
102+
use_repo(maven, "maven")
103+
104+
##### Python dependencies #####
105+
bazel_dep(
106+
name = "rules_python",
107+
version = "1.0.0",
108+
)
109+
110+
##### Other dependencies #####
111+
http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
112+
113+
http_file(
114+
name = "fonts_noto_mono_deb",
115+
sha256 = "71ff715cf50a74a8cc11b02e7c906b69a242d3d677e739e0b2d18cd23b7de375",
116+
urls = [
117+
"https://mirror.bazel.build/http.us.debian.org/debian/pool/main/f/fonts-noto/fonts-noto-mono_20161116-1_all.deb",
118+
"http://http.us.debian.org/debian/pool/main/f/fonts-noto/fonts-noto-mono_20161116-1_all.deb",
119+
],
120+
)
121+
122+
http_file(
123+
name = "libexpat_amd64_deb",
124+
sha256 = "682d2321297c56dec327770efa986d4bef43a5acb1a5528b3098e05652998fae",
125+
urls = [
126+
"https://mirror.bazel.build/http.us.debian.org/debian/pool/main/e/expat/libexpat1_2.1.0-6+deb8u3_amd64.deb",
127+
"http://http.us.debian.org/debian/pool/main/e/expat/libexpat1_2.1.0-6+deb8u3_amd64.deb",
128+
],
129+
)
130+
131+
http_file(
132+
name = "libpng_amd64_deb",
133+
sha256 = "a57b6d53169c67a7754719f4b742c96554a18f931ca5b9e0408fb6502bb77e80",
134+
urls = [
135+
"https://mirror.bazel.build/http.us.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u2_amd64.deb",
136+
"http://http.us.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u2_amd64.deb",
137+
],
138+
)
139+
140+
http_file(
141+
name = "libfontconfig_amd64_deb",
142+
sha256 = "0bb54d61c13aa5b5253cb5e08aaca0dfc4c626a05ee30f51d0e3002cda166fec",
143+
urls = [
144+
"https://mirror.bazel.build/http.us.debian.org/debian/pool/main/f/fontconfig/libfontconfig1_2.11.0-6.3+deb8u1_amd64.deb",
145+
"http://http.us.debian.org/debian/pool/main/f/fontconfig/libfontconfig1_2.11.0-6.3+deb8u1_amd64.deb",
146+
],
147+
)
148+
149+
http_file(
150+
name = "libfreetype_amd64_deb",
151+
sha256 = "80184d932f9b0acc130af081c60a2da114c7b1e7531c18c63174498fae47d862",
152+
urls = [
153+
"https://mirror.bazel.build/http.us.debian.org/debian/pool/main/f/freetype/libfreetype6_2.5.2-3+deb8u1_amd64.deb",
154+
"http://http.us.debian.org/debian/pool/main/f/freetype/libfreetype6_2.5.2-3+deb8u1_amd64.deb",
155+
],
156+
)
157+
158+
http_file(
159+
name = "fonts_noto_hinted_deb",
160+
sha256 = "a71fcee2bc7820fc4e0c780bb9c7c6db8364fd2c5bac20867c5c33eed470dc51",
161+
urls = [
162+
"https://mirror.bazel.build/http.us.debian.org/debian/pool/main/f/fonts-noto/fonts-noto-hinted_20161116-1_all.deb",
163+
"http://http.us.debian.org/debian/pool/main/f/fonts-noto/fonts-noto-hinted_20161116-1_all.deb",
164+
],
165+
)
166+
167+
platform_http_file = use_repo_rule("//closure/private:platform_http_file.bzl", "platform_http_file")
168+
169+
platform_http_file(
170+
name = "phantomjs",
171+
amd64_sha256 = "86dd9a4bf4aee45f1a84c9f61cf1947c1d6dce9b9e8d2a907105da7852460d2f",
172+
amd64_urls = [
173+
"https://mirror.bazel.build/bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2",
174+
"https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2",
175+
],
176+
macos_sha256 = "538cf488219ab27e309eafc629e2bcee9976990fe90b1ec334f541779150f8c1",
177+
macos_urls = [
178+
"https://mirror.bazel.build/bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip",
179+
"https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip",
180+
],
181+
)

README.md

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -59,70 +59,20 @@ notes.
5959

6060
## Setup
6161

62-
First you must [install Bazel]. Then you add the following to your `WORKSPACE`
63-
file:
62+
First you must [install Bazel].
6463

65-
```starlark
66-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
67-
68-
http_archive(
69-
name = "io_bazel_rules_closure",
70-
sha256 = "9498e57368efb82b985db1ed426a767cbf1ba0398fd7aed632fc3908654e1b1e",
71-
strip_prefix = "rules_closure-0.12.0",
72-
urls = [
73-
"https://mirror.bazel.build/github.com/bazelbuild/rules_closure/archive/0.12.0.tar.gz",
74-
"https://github.com/bazelbuild/rules_closure/archive/0.12.0.tar.gz",
75-
],
76-
)
77-
78-
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
79-
rules_closure_dependencies()
80-
rules_closure_toolchains()
64+
Then you add the following to your MODULE.bazel file:
8165

82-
# Only needed if you want to run your tests on headless Chrome
83-
load("@io_bazel_rules_closure//closure:defs.bzl", "setup_web_test_repositories")
84-
setup_web_test_repositories(
85-
chromium = True,
86-
)
66+
```bzl
67+
bazel_dep(name = "io_bazel_rules_closure")
8768
```
69+
The root module has to declare the same override for rules_webtesting,
70+
rules_scala, and google_bazel_common temporarily until they are registered
71+
in BCR.
8872

8973
You are not required to install the Closure Tools, PhantomJS, or anything else
9074
for that matter; they will be fetched automatically by Bazel.
9175

92-
### Overriding Dependency Versions
93-
94-
When you call `rules_closure_dependencies()` in your `WORKSPACE` file, it causes a
95-
few dozen external dependencies to be added to your project, e.g. Guava, Guice,
96-
JSR305, etc. You might need to customize this behavior.
97-
98-
To override the version of any dependency, modify your `WORKSPACE` file to pass
99-
`omit_<dependency_name>=True` to `rules_closure_dependencies()`. Next define your
100-
custom dependency version. A full list of dependencies is available from
101-
[repositories.bzl]. For example, to override the version of Guava:
102-
103-
```starlark
104-
load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies", "rules_closure_toolchains")
105-
rules_closure_dependencies(
106-
omit_com_google_guava=True,
107-
)
108-
rules_closure_toolchains()
109-
110-
load("@bazel_tools//tools/build_defs/repo:java.bzl", "java_import_external")
111-
java_import_external(
112-
name = "com_google_guava",
113-
licenses = ["notice"], # Apache 2.0
114-
jar_urls = [
115-
"https://mirror.bazel.build/repo1.maven.org/maven2/com/google/guava/guava/24.1-jre/guava-24.1-jre.jar",
116-
"https://repo1.maven.org/maven2/com/google/guava/guava/24.1-jre/guava-24.1-jre.jar",
117-
],
118-
jar_sha256 = "31bfe27bdf9cba00cb4f3691136d3bc7847dfc87bfe772ca7a9eb68ff31d79f5",
119-
exports = [
120-
"@com_google_code_findbugs_jsr305",
121-
"@com_google_errorprone_error_prone_annotations",
122-
],
123-
)
124-
```
125-
12676
## Examples
12777

12878
Please see the test directories within this project for concrete examples of usage:
@@ -654,7 +604,7 @@ This rule can be referenced as though it were the following:
654604

655605
- **defs:** (List of strings; optional) Specifies additional flags to be passed
656606
to the Closure Stylesheets compiler. To see what flags are available, run:
657-
`bazel run @com_google_closure_stylesheets//:ClosureCommandLineCompiler -- --help`
607+
`bazel run //closure/stylesheets:ClosureCommandLineCompiler -- --help`
658608

659609

660610
[Bazel]: http://bazel.build/
@@ -695,5 +645,3 @@ This rule can be referenced as though it were the following:
695645
[output-wrapper-faq]: https://github.com/google/closure-compiler/wiki/FAQ#when-using-advanced-optimizations-closure-compiler-adds-new-variables-to-the-global-scope-how-do-i-make-sure-my-variables-dont-collide-with-other-scripts-on-the-page
696646
[phantomjs-bug]: https://github.com/ariya/phantomjs/issues/14028
697647
[phantomjs_test]: #phantomjs_test
698-
[repositories.bzl]: https://github.com/bazelbuild/rules_closure/tree/master/closure/repositories.bzl
699-
[verbose]: https://github.com/google/closure-library/blob/master/closure/goog/html/safehtml.js

0 commit comments

Comments
 (0)