blob: 8ce21d57f5ed133bdfe98aa21aa510f44ebe98c2 [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",
David Ostrovsky37d22cb2023-09-26 12:00:17 +020036 sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
Matthias Sohn06b7b992022-04-25 15:53:40 +020037 urls = [
David Ostrovsky37d22cb2023-09-26 12:00:17 +020038 "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
39 "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
Matthias Sohn06b7b992022-04-25 15:53:40 +020040 ],
41)
42
43http_archive(
David Ostrovsky001943d2020-12-20 21:36:25 +010044 name = "rbe_jdk11",
Luca Milanesio95eb3152023-11-28 10:29:31 +000045 sha256 = "dbcfd6f26589ef506b91fe03a12dc559ca9c84699e4cf6381150522287f0e6f6",
46 strip_prefix = "rbe_autoconfig-3.1.0",
David Ostrovsky22e6e982021-05-22 11:26:40 +020047 urls = [
Luca Milanesio95eb3152023-11-28 10:29:31 +000048 "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",
Luca Milanesio0148c1b2023-11-28 10:29:30 +000068 sha256 = "94070eff79305be05b7699207fbac5d2608054dd53e6109f7d00d923919ff45a",
69 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.2/rules_nodejs-5.8.2.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 Ostrovsky04219df2023-09-29 10:23:22 +0200106# Java-Prettify external repository consumed from git submodule
107local_repository(
108 name = "java-prettify",
109 path = "modules/java-prettify",
110)
111
David Ostrovsky8bec8552019-06-19 01:07:43 +0200112# JGit external repository consumed from git submodule
113local_repository(
114 name = "jgit",
115 path = "modules/jgit",
116)
117
Andrew Z Allen3384a692021-11-15 04:28:33 +0000118java_dependencies()
David Ostrovsky06c86042019-11-09 12:38:13 +0100119
Marco Miller2cdbc4e2020-10-19 14:01:40 -0400120CAFFEINE_GUAVA_SHA256 = "6e48965614557ba4d3c55a197e20c38f23a20032ef8aace37e95ed64d2ebc9a6"
David Ostrovsky9262cce2020-01-17 22:06:20 +0100121
David Ostrovsky06c86042019-11-09 12:38:13 +0100122# TODO(davido): Rename guava.jar to caffeine-guava.jar on fetch to prevent potential
David Pursehouse0461b432020-05-17 10:44:00 +0900123# naming collision between caffeine guava adapter and guava library itself.
David Ostrovsky06c86042019-11-09 12:38:13 +0100124# Remove this renaming procedure, once this upstream issue is fixed:
125# https://github.com/ben-manes/caffeine/issues/364.
126http_file(
127 name = "caffeine-guava-renamed",
David Ostrovsky9262cce2020-01-17 22:06:20 +0100128 canonical_id = "caffeine-guava-" + CAFFEINE_VERS + ".jar-" + CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100129 downloaded_file_path = "caffeine-guava-" + CAFFEINE_VERS + ".jar",
David Ostrovsky9262cce2020-01-17 22:06:20 +0100130 sha256 = CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100131 urls = [
132 "https://repo1.maven.org/maven2/com/github/ben-manes/caffeine/guava/" +
133 CAFFEINE_VERS +
134 "/guava-" +
135 CAFFEINE_VERS +
136 ".jar",
137 ],
138)
139
Han-Wen Nienhuysf37b8202019-04-17 17:19:55 +0200140declare_nongoogle_deps()
David Ostrovskyb81b4f72016-05-21 19:55:01 +0200141
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100142load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
143
144node_repositories(
Luca Milanesio0148c1b2023-11-28 10:29:30 +0000145 node_version = "17.9.1",
paladox84c10072022-08-17 21:06:45 -0400146 yarn_version = "1.22.19",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100147)
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200148
149yarn_install(
150 name = "npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100151 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100152 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200153 package_json = "//:package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200154 package_path = "",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100155 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200156 yarn_lock = "//:yarn.lock",
157)
158
159yarn_install(
160 name = "ui_npm",
Dmitrii Filippovba3dc7a2021-06-28 14:42:15 +0200161 args = [
162 "--prod",
163 # By default, yarn install all optional dependencies.
164 # In some cases, it installs a lot of additional dependencies which
165 # are not required (for example, "resemblejs" has one optional
166 # dependencies "canvas" that leads to tens of additional dependencies).
167 # Each additional dependency requires a license even if it is not used
168 # in our code. We want to ensure that all optional dependencies are
169 # explicitly added to package.json.
170 "--ignore-optional",
171 ],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100172 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100173 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200174 package_json = "//:polygerrit-ui/app/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200175 package_path = "polygerrit-ui/app",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100176 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200177 yarn_lock = "//:polygerrit-ui/app/yarn.lock",
178)
179
180yarn_install(
181 name = "ui_dev_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100182 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100183 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200184 package_json = "//:polygerrit-ui/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200185 package_path = "polygerrit-ui",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100186 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200187 yarn_lock = "//:polygerrit-ui/yarn.lock",
188)
189
190yarn_install(
191 name = "tools_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100192 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100193 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200194 package_json = "//:tools/node_tools/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200195 package_path = "tools/node_tools",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100196 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200197 yarn_lock = "//:tools/node_tools/yarn.lock",
198)
199
200yarn_install(
201 name = "plugins_npm",
202 args = ["--prod"],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100203 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100204 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200205 package_json = "//:plugins/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200206 package_path = "plugins",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100207 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200208 yarn_lock = "//:plugins/yarn.lock",
209)
210
Luca Milanesio6b192142017-01-26 14:24:53 +0000211external_plugin_deps()