blob: 1c168c62710e66b003fe50daa7ae8972cecad9e8 [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(
David Ostrovsky8d03c3a2023-11-14 07:55:44 +010034 name = "rules_nodejs",
35 patch_args = ["-p1"],
36 patches = ["//tools:rules_nodejs-5.8.4-node_versions.bzl.patch"],
37 sha256 = "8fc8e300cb67b89ceebd5b8ba6896ff273c84f6099fc88d23f24e7102319d8fd",
38 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-core-5.8.4.tar.gz"],
39)
40
41http_archive(
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010042 name = "build_bazel_rules_nodejs",
Paladox none511ca192023-10-21 16:01:41 +000043 sha256 = "709cc0dcb51cf9028dd57c268066e5bc8f03a119ded410a13b5c3925d6e43c48",
44 urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-5.8.4.tar.gz"],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +010045)
46
47load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
48
49build_bazel_rules_nodejs_dependencies()
50
51# This is required just because we have a dependency on @bazel/concatjs.
52# We don't actually use any of this web_testing stuff.
53# TODO: Remove this dependency.
54http_archive(
55 name = "io_bazel_rules_webtesting",
56 sha256 = "e9abb7658b6a129740c0b3ef6f5a2370864e102a5ba5ffca2cea565829ed825a",
57 urls = [
58 "https://github.com/bazelbuild/rules_webtesting/releases/download/0.3.5/rules_webtesting.tar.gz",
59 ],
60)
61
62# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
63load("@io_bazel_rules_webtesting//web:repositories.bzl", "web_test_repositories")
64
65# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
66web_test_repositories()
67
68# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
69load("@io_bazel_rules_webtesting//web/versioned:browsers-0.3.3.bzl", "browser_repositories")
70
71# TODO: Remove this, see comments on `io_bazel_rules_webtesting`.
72browser_repositories(
73 chromium = True,
74 firefox = True,
Dmitrii Filippov3f49f912020-01-09 15:12:45 +010075)
76
David Ostrovsky7f4793d2023-12-26 14:40:22 +010077declare_nongoogle_deps()
David Ostrovsky21a891c2020-12-19 12:57:06 +010078
David Ostrovsky7f4793d2023-12-26 14:40:22 +010079load("//tools:defs.bzl", "gerrit_init")
David Ostrovsky21a891c2020-12-19 12:57:06 +010080
David Ostrovsky7f4793d2023-12-26 14:40:22 +010081gerrit_init()
David Ostrovskyd7734082023-09-28 16:49:06 +020082
David Ostrovsky04219df2023-09-29 10:23:22 +020083# Java-Prettify external repository consumed from git submodule
84local_repository(
85 name = "java-prettify",
86 path = "modules/java-prettify",
87)
88
David Ostrovsky8bec8552019-06-19 01:07:43 +020089# JGit external repository consumed from git submodule
90local_repository(
91 name = "jgit",
92 path = "modules/jgit",
93)
94
Andrew Z Allen3384a692021-11-15 04:28:33 +000095java_dependencies()
David Ostrovsky06c86042019-11-09 12:38:13 +010096
Marco Miller2cdbc4e2020-10-19 14:01:40 -040097CAFFEINE_GUAVA_SHA256 = "6e48965614557ba4d3c55a197e20c38f23a20032ef8aace37e95ed64d2ebc9a6"
David Ostrovsky9262cce2020-01-17 22:06:20 +010098
David Ostrovsky06c86042019-11-09 12:38:13 +010099# TODO(davido): Rename guava.jar to caffeine-guava.jar on fetch to prevent potential
David Pursehouse0461b432020-05-17 10:44:00 +0900100# naming collision between caffeine guava adapter and guava library itself.
David Ostrovsky06c86042019-11-09 12:38:13 +0100101# Remove this renaming procedure, once this upstream issue is fixed:
102# https://github.com/ben-manes/caffeine/issues/364.
103http_file(
104 name = "caffeine-guava-renamed",
David Ostrovsky9262cce2020-01-17 22:06:20 +0100105 canonical_id = "caffeine-guava-" + CAFFEINE_VERS + ".jar-" + CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100106 downloaded_file_path = "caffeine-guava-" + CAFFEINE_VERS + ".jar",
David Ostrovsky9262cce2020-01-17 22:06:20 +0100107 sha256 = CAFFEINE_GUAVA_SHA256,
David Ostrovsky06c86042019-11-09 12:38:13 +0100108 urls = [
109 "https://repo1.maven.org/maven2/com/github/ben-manes/caffeine/guava/" +
110 CAFFEINE_VERS +
111 "/guava-" +
112 CAFFEINE_VERS +
113 ".jar",
114 ],
115)
116
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100117load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")
118
119node_repositories(
David Ostrovsky8d03c3a2023-11-14 07:55:44 +0100120 node_version = "20.9.0",
paladox84c10072022-08-17 21:06:45 -0400121 yarn_version = "1.22.19",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100122)
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200123
124yarn_install(
125 name = "npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100126 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100127 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200128 package_json = "//:package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200129 package_path = "",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100130 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200131 yarn_lock = "//:yarn.lock",
132)
133
134yarn_install(
135 name = "ui_npm",
Dmitrii Filippovba3dc7a2021-06-28 14:42:15 +0200136 args = [
137 "--prod",
138 # By default, yarn install all optional dependencies.
139 # In some cases, it installs a lot of additional dependencies which
140 # are not required (for example, "resemblejs" has one optional
141 # dependencies "canvas" that leads to tens of additional dependencies).
142 # Each additional dependency requires a license even if it is not used
143 # in our code. We want to ensure that all optional dependencies are
144 # explicitly added to package.json.
145 "--ignore-optional",
146 ],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100147 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100148 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200149 package_json = "//:polygerrit-ui/app/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200150 package_path = "polygerrit-ui/app",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100151 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200152 yarn_lock = "//:polygerrit-ui/app/yarn.lock",
153)
154
155yarn_install(
156 name = "ui_dev_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100157 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100158 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200159 package_json = "//:polygerrit-ui/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200160 package_path = "polygerrit-ui",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100161 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200162 yarn_lock = "//:polygerrit-ui/yarn.lock",
163)
164
165yarn_install(
166 name = "tools_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100167 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100168 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200169 package_json = "//:tools/node_tools/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200170 package_path = "tools/node_tools",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100171 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200172 yarn_lock = "//:tools/node_tools/yarn.lock",
173)
174
175yarn_install(
176 name = "plugins_npm",
177 args = ["--prod"],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100178 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100179 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200180 package_json = "//:plugins/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200181 package_path = "plugins",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100182 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200183 yarn_lock = "//:plugins/yarn.lock",
184)
185
Luca Milanesio6b192142017-01-26 14:24:53 +0000186external_plugin_deps()