blob: 047da6a480794e166b011b4d2d6b1a460b0de5fa [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")
David Pursehousefd0fcb22018-06-14 15:32:28 +090029load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_LOCAL", "maven_jar")
Luca Milanesio6b192142017-01-26 14:24:53 +000030load("//plugins:external_plugin_deps.bzl", "external_plugin_deps")
Nasser Grainawia5c2f8fb2021-12-06 13:16:59 -070031load("//tools:nongoogle.bzl", "declare_nongoogle_deps")
Andrew Z Allen3384a692021-11-15 04:28:33 +000032load("//tools:deps.bzl", "CAFFEINE_VERS", "java_dependencies")
Han-Wen Nienhuys28e7a6d2016-09-21 15:03:54 +020033
Kasper Nilsson1ea918b2017-04-25 13:55:01 +020034http_archive(
Matthias Sohn06b7b992022-04-25 15:53:40 +020035 name = "platforms",
36 sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
37 urls = [
38 "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
39 "https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
40 ],
41)
42
43http_archive(
David Ostrovsky001943d2020-12-20 21:36:25 +010044 name = "rbe_jdk11",
David Ostrovskycad44f02022-11-08 16:31:48 +010045 sha256 = "dbcfd6f26589ef506b91fe03a12dc559ca9c84699e4cf6381150522287f0e6f6",
46 strip_prefix = "rbe_autoconfig-3.1.0",
David Ostrovsky22e6e982021-05-22 11:26:40 +020047 urls = [
David Ostrovskycad44f02022-11-08 16:31:48 +010048 "https://gerrit-bazel.storage.googleapis.com/rbe_autoconfig/v3.1.0.tar.gz",
49 "https://github.com/davido/rbe_autoconfig/archive/v3.1.0.tar.gz",
David Ostrovsky22e6e982021-05-22 11:26:40 +020050 ],
David Ostrovsky001943d2020-12-20 21:36:25 +010051)
Han-Wen Nienhuys9c15e2b2019-05-16 16:59:33 +020052
53http_archive(
David Ostrovsky9eeddbc2020-02-02 15:40:12 +010054 name = "com_google_protobuf",
David Ostrovskybaae1eb2022-02-12 15:56:33 +010055 sha256 = "3bd7828aa5af4b13b99c191e8b1e884ebfa9ad371b0ce264605d347f135d2568",
56 strip_prefix = "protobuf-3.19.4",
Luca Milanesiod849fb42020-04-23 15:25:19 +010057 urls = [
David Ostrovskybaae1eb2022-02-12 15:56:33 +010058 "https://github.com/protocolbuffers/protobuf/archive/v3.19.4.tar.gz",
Luca Milanesiod849fb42020-04-23 15:25:19 +010059 ],
Kasper Nilsson1ea918b2017-04-25 13:55:01 +020060)
61
David Ostrovsky9eeddbc2020-02-02 15:40:12 +010062load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
63
64protobuf_deps()
65
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010066http_archive(
67 name = "build_bazel_rules_nodejs",
Paladox noned0c5c642022-10-22 14:47:39 +000068 sha256 = "c29944ba9b0b430aadcaf3bf2570fece6fc5ebfb76df145c6cdad40d65c20811",
69 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.7.0/rules_nodejs-5.7.0.tar.gz"],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +010070)
71
72load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
73
74build_bazel_rules_nodejs_dependencies()
75
76# This is required just because we have a dependency on @bazel/concatjs.
77# We don't actually use any of this web_testing stuff.
78# TODO: Remove this dependency.
79http_archive(
80 name = "io_bazel_rules_webtesting",
81 sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a",
82 urls = [
83 "https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz",
84 ],
85)
86
87# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
88load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
89
90# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
91web_test_repositories()
92
93# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
94load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl", "browser_repositories")
95
96# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
97browser_repositories(
98 chromium = True,
99 firefox = True,
Dmitrii Filippov3f49f912020-01-09 15:12:45 +0100100)
101
David Ostrovsky21a891c2020-12-19 12:57:06 +0100102register_toolchains("//tools:error_prone_warnings_toolchain_java11_definition")
103
104register_toolchains("//tools:error_prone_warnings_toolchain_java17_definition")
105
David Ostrovsky8bec8552019-06-19 01:07:43 +0200106# JGit external repository consumed from git submodule
107local_repository(
108 name = "jgit",
109 path = "modules/jgit",
110)
111
Andrew Z Allen3384a692021-11-15 04:28:33 +0000112java_dependencies()
David Ostrovsky06c86042019-11-09 12:38:13 +0100113
Marco Miller2cdbc4e2020-10-19 14:01:40 -0400114CAFFEINE_GUAVA_SHA256 = "6e48965614557ba4d3c55a197e20c38f23a20032ef8aace37e95ed64d2ebc9a6"
David Ostrovsky9262cce2020-01-17 22:06:20 +0100115
David Ostrovsky06c86042019-11-09 12:38:13 +0100116# TODO(davido): Rename guava.jar to caffeine-guava.jar on fetch to prevent potential
David Pursehouse0461b432020-05-17 10:44:00 +0900117# naming collision between caffeine guava adapter and guava library itself.
David Ostrovsky06c86042019-11-09 12:38:13 +0100118# Remove this renaming procedure, once this upstream issue is fixed:
119# https://github.com/ben-manes/caffeine/issues/364.
120http_file(
121 name = "caffeine-guava-renamed",
David Ostrovsky9262cce2020-01-17 22:06:20 +0100122 canonical_id = "caffeine-guava-" + CAFFEINE_VERS + ".jar-" + CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100123 downloaded_file_path = "caffeine-guava-" + CAFFEINE_VERS + ".jar",
David Ostrovsky9262cce2020-01-17 22:06:20 +0100124 sha256 = CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100125 urls = [
126 "https://repo1.maven.org/maven2/com/github/ben-manes/caffeine/guava/" +
127 CAFFEINE_VERS +
128 "/guava-" +
129 CAFFEINE_VERS +
130 ".jar",
131 ],
132)
133
Han-Wen Nienhuysf37b8202019-04-17 17:19:55 +0200134declare_nongoogle_deps()
David Ostrovskyb81b4f72016-05-21 19:55:01 +0200135
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100136load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
137
138node_repositories(
paladoxecefaa22022-08-17 21:09:49 -0400139 node_version = "17.9.1",
paladox84c10072022-08-17 21:06:45 -0400140 yarn_version = "1.22.19",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100141)
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200142
143yarn_install(
144 name = "npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100145 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100146 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200147 package_json = "//:package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200148 package_path = "",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100149 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200150 yarn_lock = "//:yarn.lock",
151)
152
153yarn_install(
154 name = "ui_npm",
Dmitrii Filippovba3dc7a2021-06-28 14:42:15 +0200155 args = [
156 "--prod",
157 # By default, yarn install all optional dependencies.
158 # In some cases, it installs a lot of additional dependencies which
159 # are not required (for example, "resemblejs" has one optional
160 # dependencies "canvas" that leads to tens of additional dependencies).
161 # Each additional dependency requires a license even if it is not used
162 # in our code. We want to ensure that all optional dependencies are
163 # explicitly added to package.json.
164 "--ignore-optional",
165 ],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100166 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100167 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200168 package_json = "//:polygerrit-ui/app/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200169 package_path = "polygerrit-ui/app",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100170 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200171 yarn_lock = "//:polygerrit-ui/app/yarn.lock",
172)
173
174yarn_install(
175 name = "ui_dev_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100176 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100177 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200178 package_json = "//:polygerrit-ui/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200179 package_path = "polygerrit-ui",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100180 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200181 yarn_lock = "//:polygerrit-ui/yarn.lock",
182)
183
184yarn_install(
185 name = "tools_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100186 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100187 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200188 package_json = "//:tools/node_tools/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200189 package_path = "tools/node_tools",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100190 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200191 yarn_lock = "//:tools/node_tools/yarn.lock",
192)
193
194yarn_install(
195 name = "plugins_npm",
196 args = ["--prod"],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100197 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100198 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200199 package_json = "//:plugins/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200200 package_path = "plugins",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100201 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200202 yarn_lock = "//:plugins/yarn.lock",
203)
204
Luca Milanesio6b192142017-01-26 14:24:53 +0000205external_plugin_deps()