blob: 71f3dbe44169b66455736e41dff458992fe9cf76 [file] [log] [blame]
David Ostrovsky122d4ce2022-06-08 10:53:11 +02001# npm packages are split into different node_modules directories based on their
2# usage.
3# 1. @npm (node_modules) - contains packages to run tests, check code, etc...
4# It is expected that @npm is used ONLY to run tools. No packages from @npm
5# are used by other code in gerrit.
6# 2. @tools_npm (tools/node_tools/node_modules) - the tools/node_tools folder
7# contains self-written tools which are run for building and/or testing. The
8# @tools_npm directory contains all the packages needed to run this tools.
9# 3. @ui_npm (polygerrit-ui/app/node_modules) - packages with source code which
10# are necessary to run polygerrit and to bundle it. Only code from these
11# packages can be included in the final bundle for polygerrit. @ui_npm folder
12# must not have devDependencies. All devDependencies must be placed in
13# @ui_dev_npm.
14# 4. @ui_dev_npm (polygerrit-ui/node_modules) - devDependencies for polygerrit.
15# The packages from these folder can be used for testing, but must not be
16# included in the final bundle.
17# 5. @plugins_npm (plugins/node_modules) - plugin dependencies for polygerrit
18# plugins. The packages here are expected to be used in plugins.
19# Note: separation between @ui_npm and @ui_dev_npm is necessary because with
20# rules_nodejs we can't generate two external repositories from the same
21# package.json. At the same time we want to avoid accidental usages of code
22# from devDependencies in polygerrit bundle.
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010023workspace(
24 name = "gerrit",
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010025)
David Ostrovskyfa189072016-11-30 08:52:06 +010026
Logan Hanks784849c2018-09-12 14:35:10 -070027load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
David Ostrovsky6dc8c422018-06-02 09:07:09 +020028load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
Luca Milanesio6b192142017-01-26 14:24:53 +000029load("//plugins:external_plugin_deps.bzl", "external_plugin_deps")
Nasser Grainawia5c2f8fb2021-12-06 13:16:59 -070030load("//tools:nongoogle.bzl", "declare_nongoogle_deps")
Andrew Z Allen3384a692021-11-15 04:28:33 +000031load("//tools:deps.bzl", "CAFFEINE_VERS", "java_dependencies")
Han-Wen Nienhuys28e7a6d2016-09-21 15:03:54 +020032
Kasper Nilsson1ea918b2017-04-25 13:55:01 +020033http_archive(
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010034 name = "build_bazel_rules_nodejs",
David Ostrovsky16b9aa372024-06-26 07:16:21 +020035 sha256 = "a1295b168f183218bc88117cf00674bcd102498f294086ff58318f830dd9d9d1",
36 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.5/rules_nodejs-5.8.5.tar.gz"],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +010037)
38
39load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
40
41build_bazel_rules_nodejs_dependencies()
42
43# This is required just because we have a dependency on @bazel/concatjs.
44# We don't actually use any of this web_testing stuff.
45# TODO: Remove this dependency.
46http_archive(
47 name = "io_bazel_rules_webtesting",
48 sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a",
49 urls = [
50 "https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz",
51 ],
52)
53
54# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
55load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
56
57# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
58web_test_repositories()
59
60# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
61load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl", "browser_repositories")
62
63# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
64browser_repositories(
65 chromium = True,
66 firefox = True,
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010067)
68
David Ostrovsky7f4793d2023-12-26 14:40:22 +010069declare_nongoogle_deps()
David Ostrovsky21a891c2020-12-19 12:57:06 +010070
David Ostrovsky7f4793d2023-12-26 14:40:22 +010071load("//tools:defs.bzl", "gerrit_init")
David Ostrovsky21a891c2020-12-19 12:57:06 +010072
David Ostrovsky7f4793d2023-12-26 14:40:22 +010073gerrit_init()
David Ostrovskyd7734082023-09-28 16:49:06 +020074
David Ostrovsky04219df2023-09-29 10:23:22 +020075# Java-Prettify external repository consumed from git submodule
76local_repository(
77 name = "java-prettify",
78 path = "modules/java-prettify",
79)
80
David Ostrovsky8bec8552019-06-19 01:07:43 +020081# JGit external repository consumed from git submodule
82local_repository(
83 name = "jgit",
84 path = "modules/jgit",
85)
86
Andrew Z Allen3384a692021-11-15 04:28:33 +000087java_dependencies()
David Ostrovsky06c86042019-11-09 12:38:13 +010088
Paladox none7fbf5ee2025-10-12 07:14:36 -070089CAFFEINE_GUAVA_SHA256 = "e45c7c2db18810644c12bb3396cd38dbf4efaa1fa2402f27aaef6e662d8a0af5"
David Ostrovsky9262cce2020-01-17 22:06:20 +010090
David Ostrovsky06c86042019-11-09 12:38:13 +010091# TODO(davido): Rename guava.jar to caffeine-guava.jar on fetch to prevent potential
David Pursehouse0461b432020-05-17 10:44:00 +090092# naming collision between caffeine guava adapter and guava library itself.
David Ostrovsky06c86042019-11-09 12:38:13 +010093# Remove this renaming procedure, once this upstream issue is fixed:
94# https://github.com/ben-manes/caffeine/issues/364.
95http_file(
96 name = "caffeine-guava-renamed",
David Ostrovsky9262cce2020-01-17 22:06:20 +010097 canonical_id = "caffeine-guava-" + CAFFEINE_VERS + ".jar-" + CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +010098 downloaded_file_path = "caffeine-guava-" + CAFFEINE_VERS + ".jar",
David Ostrovsky9262cce2020-01-17 22:06:20 +010099 sha256 = CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100100 urls = [
101 "https://repo1.maven.org/maven2/com/github/ben-manes/caffeine/guava/" +
102 CAFFEINE_VERS +
103 "/guava-" +
104 CAFFEINE_VERS +
105 ".jar",
106 ],
107)
108
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100109load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
110
Paladox nonef8200fd2025-10-09 08:46:49 -0700111NODE_20_REPO = {
112 "20.19.5-darwin_arm64": ("node-v20.19.5-darwin-arm64.tar.gz", "node-v20.19.5-darwin-arm64", "cfed7503d8d99fbcf2f52e408ec52f616058eb0867b34dbc3437259993ef5cba"),
113 "20.19.5-darwin_amd64": ("node-v20.19.5-darwin-x64.tar.gz", "node-v20.19.5-darwin-x64", "f9cff058f2766d4d0631dc69b5f7f27664b3a42ff186e25ac7e1ac269af7e696"),
114 "20.19.5-linux_arm64": ("node-v20.19.5-linux-arm64.tar.xz", "node-v20.19.5-linux-arm64", "d462267863ae8ee556039ebdf559055a8ec562c633889ef1403f3adb449ba1dd"),
115 "20.19.5-linux_ppc64le": ("node-v20.19.5-linux-ppc64le.tar.xz", "node-v20.19.5-linux-ppc64le", "ef98025e71d6d498476a95f144e353be074b24431b22eaa81bc64f921ea7d57f"),
116 "20.19.5-linux_s390x": ("node-v20.19.5-linux-s390x.tar.xz", "node-v20.19.5-linux-s390x", "a2e56c4b7fbffd0e6eef3a89e1c5945962fe85b4e2acfa59edc77a9238cc7901"),
117 "20.19.5-linux_amd64": ("node-v20.19.5-linux-x64.tar.xz", "node-v20.19.5-linux-x64", "315046739a513a70e03a4a55a8afda8cf979f30852e576075c340084e3f8ac0f"),
118 "20.19.5-windows_amd64": ("node-v20.19.5-win-x64.zip", "node-v20.19.5-win-x64", "c48159529572a5a947eef2d55d6485dfdc4ce8e67216402e2f6de52ad5d95695"),
119}
120
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100121node_repositories(
Paladox nonef8200fd2025-10-09 08:46:49 -0700122 node_repositories = NODE_20_REPO,
123 node_version = "20.19.5",
paladox84c10072022-08-17 21:06:45 -0400124 yarn_version = "1.22.19",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100125)
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200126
127yarn_install(
128 name = "npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100129 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100130 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200131 package_json = "//:package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200132 package_path = "",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100133 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200134 yarn_lock = "//:yarn.lock",
135)
136
137yarn_install(
138 name = "ui_npm",
Dmitrii Filippovba3dc7a2021-06-28 14:42:15 +0200139 args = [
140 "--prod",
141 # By default, yarn install all optional dependencies.
142 # In some cases, it installs a lot of additional dependencies which
143 # are not required (for example, "resemblejs" has one optional
144 # dependencies "canvas" that leads to tens of additional dependencies).
145 # Each additional dependency requires a license even if it is not used
146 # in our code. We want to ensure that all optional dependencies are
147 # explicitly added to package.json.
148 "--ignore-optional",
149 ],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100150 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100151 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200152 package_json = "//:polygerrit-ui/app/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200153 package_path = "polygerrit-ui/app",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100154 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200155 yarn_lock = "//:polygerrit-ui/app/yarn.lock",
156)
157
158yarn_install(
159 name = "ui_dev_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100160 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100161 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200162 package_json = "//:polygerrit-ui/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200163 package_path = "polygerrit-ui",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100164 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200165 yarn_lock = "//:polygerrit-ui/yarn.lock",
166)
167
168yarn_install(
169 name = "tools_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100170 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100171 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200172 package_json = "//:tools/node_tools/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200173 package_path = "tools/node_tools",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100174 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200175 yarn_lock = "//:tools/node_tools/yarn.lock",
176)
177
178yarn_install(
179 name = "plugins_npm",
180 args = ["--prod"],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100181 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100182 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200183 package_json = "//:plugins/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200184 package_path = "plugins",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100185 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200186 yarn_lock = "//:plugins/yarn.lock",
187)
188
Luca Milanesio6b192142017-01-26 14:24:53 +0000189external_plugin_deps()