blob: 51068e0babfac112bd96cf39e1916c5dab435c62 [file] [log] [blame]
Dmitrii Filippov3f49f912020-01-09 15:12:45 +01001# npm packages are split into different node_modules directories based on their usage.
2# 1. /node_modules (referenced as @npm) - contains packages to run tests, check code, etc...
3# It is expected that @npm is used ONLY to run tools. No packages from @npm are used by
4# other code in gerrit.
5# 2. @tools_npm (tools/node_tools/node_modules) - the tools/node_tools folder contains self-written tools
6# which are run for building and/or testing. The @tools_npm directory contains all the packages needed to
7# run this tools.
8# 3. @ui_npm (polygerrit-ui/app/node_modules) - packages with source code which are necessary to run polygerrit
9# and to bundle it. Only code from these packages can be included in the final bundle for polygerrit.
10# @ui_npm folder must not have devDependencies. All dev dependencies must be placed in @ui_dev_npm
11# 4. @ui_dev_npm (polygerrit-ui/node_modules) - devDependencies for polygerrit. The packages from these
12# folder can be used for testing, but must not be included in the final bundle.
Tao Zhou85b13462020-06-17 13:52:36 +020013# 5. @plugins_npm (plugins/node_modules) - plugin dependencies for polygerrit plugins.
14# The packages here are expected to be used in plugins.
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010015# Note: separation between @ui_npm and @ui_dev_npm is necessary because with bazel we can't generate
16# two managed directories from the same package.json. At the same time we want to avoid accidental
17# usages of code from devDependencies in polygerrit bundle.
18workspace(
19 name = "gerrit",
20 managed_directories = {
21 "@npm": ["node_modules"],
22 "@ui_npm": ["polygerrit-ui/app/node_modules"],
23 "@ui_dev_npm": ["polygerrit-ui/node_modules"],
24 "@tools_npm": ["tools/node_tools/node_modules"],
Tao Zhou85b13462020-06-17 13:52:36 +020025 "@plugins_npm": ["plugins/node_modules"],
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010026 },
27)
David Ostrovskyfa189072016-11-30 08:52:06 +010028
Logan Hanks784849c2018-09-12 14:35:10 -070029load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
David Ostrovsky6dc8c422018-06-02 09:07:09 +020030load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
David Pursehousefd0fcb22018-06-14 15:32:28 +090031load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_LOCAL", "maven_jar")
Luca Milanesio6b192142017-01-26 14:24:53 +000032load("//plugins:external_plugin_deps.bzl", "external_plugin_deps")
Nasser Grainawia5c2f8fb2021-12-06 13:16:59 -070033load("//tools:nongoogle.bzl", "declare_nongoogle_deps")
Andrew Z Allen3384a692021-11-15 04:28:33 +000034load("//tools:deps.bzl", "CAFFEINE_VERS", "java_dependencies")
Han-Wen Nienhuys28e7a6d2016-09-21 15:03:54 +020035
Kasper Nilsson1ea918b2017-04-25 13:55:01 +020036http_archive(
David Ostrovsky001943d2020-12-20 21:36:25 +010037 name = "rbe_jdk11",
David Ostrovsky65951c52020-03-28 18:23:20 +010038 sha256 = "5939e2a4e56d1fc53b6c44c6db97ee068c9f4bd18e86c762f6ab8b4fff5e294b",
39 strip_prefix = "rbe_autoconfig-3.0.0",
David Ostrovsky22e6e982021-05-22 11:26:40 +020040 urls = [
David Ostrovsky65951c52020-03-28 18:23:20 +010041 "https://gerrit-bazel.storage.googleapis.com/rbe_autoconfig/v3.0.0.tar.gz",
42 "https://github.com/davido/rbe_autoconfig/archive/v3.0.0.tar.gz",
David Ostrovsky22e6e982021-05-22 11:26:40 +020043 ],
David Ostrovsky001943d2020-12-20 21:36:25 +010044)
Han-Wen Nienhuys9c15e2b2019-05-16 16:59:33 +020045
46http_archive(
David Ostrovsky9eeddbc2020-02-02 15:40:12 +010047 name = "com_google_protobuf",
David Ostrovskybaae1eb2022-02-12 15:56:33 +010048 sha256 = "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568",
49 strip_prefix = "protobuf-3.19.4",
Luca Milanesiod849fb42020-04-23 15:25:19 +010050 urls = [
David Ostrovskybaae1eb2022-02-12 15:56:33 +010051 "https://github.com/protocolbuffers/protobuf/archive/v3.19.4.tar.gz",
Luca Milanesiod849fb42020-04-23 15:25:19 +010052 ],
Kasper Nilsson1ea918b2017-04-25 13:55:01 +020053)
54
David Ostrovsky9eeddbc2020-02-02 15:40:12 +010055load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
56
57protobuf_deps()
58
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010059http_archive(
60 name = "build_bazel_rules_nodejs",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +010061 sha256 = "c077680a307eb88f3e62b0b662c2e9c6315319385bc8c637a861ffdbed8ca247",
62 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.1.0/rules_nodejs-5.1.0.tar.gz"],
63)
64
65load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
66
67build_bazel_rules_nodejs_dependencies()
68
69# This is required just because we have a dependency on @bazel/concatjs.
70# We don't actually use any of this web_testing stuff.
71# TODO: Remove this dependency.
72http_archive(
73 name = "io_bazel_rules_webtesting",
74 sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a",
75 urls = [
76 "https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz",
77 ],
78)
79
80# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
81load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
82
83# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
84web_test_repositories()
85
86# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
87load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl", "browser_repositories")
88
89# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
90browser_repositories(
91 chromium = True,
92 firefox = True,
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010093)
94
Dmitrii Filippovaf1b1ba2021-01-08 21:00:29 +010095http_archive(
96 name = "rules_pkg",
97 sha256 = "038f1caa773a7e35b3663865ffb003169c6a71dc995e39bf4815792f385d837d",
98 urls = [
99 "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.4.0/rules_pkg-0.4.0.tar.gz",
100 "https://github.com/bazelbuild/rules_pkg/releases/download/0.4.0/rules_pkg-0.4.0.tar.gz",
101 ],
102)
103
104load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
105
106rules_pkg_dependencies()
107
Logan Hanks784849c2018-09-12 14:35:10 -0700108# Golang support for PolyGerrit local dev server.
109http_archive(
110 name = "io_bazel_rules_go",
David Ostrovsky9f419eb2022-02-12 16:13:20 +0100111 sha256 = "d6b2513456fe2229811da7eb67a444be7785f5323c6708b38d851d2b51e54d83",
Ole Rehmsen038ab172019-06-18 09:35:42 +0200112 urls = [
David Ostrovsky9f419eb2022-02-12 16:13:20 +0100113 "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
114 "https://github.com/bazelbuild/rules_go/releases/download/v0.30.0/rules_go-v0.30.0.zip",
Ole Rehmsen038ab172019-06-18 09:35:42 +0200115 ],
Logan Hanks784849c2018-09-12 14:35:10 -0700116)
117
David Ostrovsky3de4a032019-03-03 20:34:12 +0100118load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
Logan Hanks784849c2018-09-12 14:35:10 -0700119
120go_rules_dependencies()
121
David Ostrovsky9f419eb2022-02-12 16:13:20 +0100122go_register_toolchains(version = "1.17.6")
Logan Hanks784849c2018-09-12 14:35:10 -0700123
124http_archive(
125 name = "bazel_gazelle",
David Ostrovsky9f419eb2022-02-12 16:13:20 +0100126 sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
David Ostrovskye8cf5122020-06-04 07:18:31 +0200127 urls = [
David Ostrovsky9f419eb2022-02-12 16:13:20 +0100128 "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
129 "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.24.0/bazel-gazelle-v0.24.0.tar.gz",
David Ostrovskye8cf5122020-06-04 07:18:31 +0200130 ],
Logan Hanks784849c2018-09-12 14:35:10 -0700131)
132
133load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
134
135gazelle_dependencies()
136
137# Dependencies for PolyGerrit local dev server.
138go_repository(
Logan Hanks784849c2018-09-12 14:35:10 -0700139 name = "com_github_howeyc_fsnotify",
140 commit = "441bbc86b167f3c1f4786afae9931403b99fdacf",
141 importpath = "github.com/howeyc/fsnotify",
142)
143
David Ostrovsky21a891c2020-12-19 12:57:06 +0100144register_toolchains("//tools:error_prone_warnings_toolchain_java11_definition")
145
146register_toolchains("//tools:error_prone_warnings_toolchain_java17_definition")
147
David Ostrovsky8bec8552019-06-19 01:07:43 +0200148# JGit external repository consumed from git submodule
149local_repository(
150 name = "jgit",
151 path = "modules/jgit",
152)
153
Andrew Z Allen3384a692021-11-15 04:28:33 +0000154java_dependencies()
David Ostrovsky06c86042019-11-09 12:38:13 +0100155
Marco Miller2cdbc4e2020-10-19 14:01:40 -0400156CAFFEINE_GUAVA_SHA256 = "6e48965614557ba4d3c55a197e20c38f23a20032ef8aace37e95ed64d2ebc9a6"
David Ostrovsky9262cce2020-01-17 22:06:20 +0100157
David Ostrovsky06c86042019-11-09 12:38:13 +0100158# TODO(davido): Rename guava.jar to caffeine-guava.jar on fetch to prevent potential
David Pursehouse0461b432020-05-17 10:44:00 +0900159# naming collision between caffeine guava adapter and guava library itself.
David Ostrovsky06c86042019-11-09 12:38:13 +0100160# Remove this renaming procedure, once this upstream issue is fixed:
161# https://github.com/ben-manes/caffeine/issues/364.
162http_file(
163 name = "caffeine-guava-renamed",
David Ostrovsky9262cce2020-01-17 22:06:20 +0100164 canonical_id = "caffeine-guava-" + CAFFEINE_VERS + ".jar-" + CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100165 downloaded_file_path = "caffeine-guava-" + CAFFEINE_VERS + ".jar",
David Ostrovsky9262cce2020-01-17 22:06:20 +0100166 sha256 = CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100167 urls = [
168 "https://repo1.maven.org/maven2/com/github/ben-manes/caffeine/guava/" +
169 CAFFEINE_VERS +
170 "/guava-" +
171 CAFFEINE_VERS +
172 ".jar",
173 ],
174)
175
Han-Wen Nienhuysf37b8202019-04-17 17:19:55 +0200176declare_nongoogle_deps()
David Ostrovskyb81b4f72016-05-21 19:55:01 +0200177
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100178load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
179
180node_repositories(
181 node_version = "16.13.2",
182 yarn_version = "1.22.17",
183)
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200184
185yarn_install(
186 name = "npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100187 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100188 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200189 package_json = "//:package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200190 package_path = "",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100191 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200192 yarn_lock = "//:yarn.lock",
193)
194
195yarn_install(
196 name = "ui_npm",
Dmitrii Filippovba3dc7a2021-06-28 14:42:15 +0200197 args = [
198 "--prod",
199 # By default, yarn install all optional dependencies.
200 # In some cases, it installs a lot of additional dependencies which
201 # are not required (for example, "resemblejs" has one optional
202 # dependencies "canvas" that leads to tens of additional dependencies).
203 # Each additional dependency requires a license even if it is not used
204 # in our code. We want to ensure that all optional dependencies are
205 # explicitly added to package.json.
206 "--ignore-optional",
207 ],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100208 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100209 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200210 package_json = "//:polygerrit-ui/app/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200211 package_path = "polygerrit-ui/app",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100212 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200213 yarn_lock = "//:polygerrit-ui/app/yarn.lock",
214)
215
216yarn_install(
217 name = "ui_dev_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100218 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100219 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200220 package_json = "//:polygerrit-ui/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200221 package_path = "polygerrit-ui",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100222 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200223 yarn_lock = "//:polygerrit-ui/yarn.lock",
224)
225
226yarn_install(
227 name = "tools_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100228 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100229 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200230 package_json = "//:tools/node_tools/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200231 package_path = "tools/node_tools",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100232 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200233 yarn_lock = "//:tools/node_tools/yarn.lock",
234)
235
236yarn_install(
237 name = "plugins_npm",
238 args = ["--prod"],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100239 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100240 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200241 package_json = "//:plugins/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200242 package_path = "plugins",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100243 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200244 yarn_lock = "//:plugins/yarn.lock",
245)
246
Luca Milanesio6b192142017-01-26 14:24:53 +0000247external_plugin_deps()