blob: 3d329370772e6fd54f37ca7ea9267ea2bb46ff95 [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
Marco Miller2cdbc4e2020-10-19 14:01:40 -040089CAFFEINE_GUAVA_SHA256 = "6e48965614557ba4d3c55a197e20c38f23a20032ef8aace37e95ed64d2ebc9a6"
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
111node_repositories(
David Ostrovsky16b9aa372024-06-26 07:16:21 +0200112 node_version = "20.14.0",
paladox84c10072022-08-17 21:06:45 -0400113 yarn_version = "1.22.19",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100114)
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200115
116yarn_install(
117 name = "npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100118 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100119 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200120 package_json = "//:package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200121 package_path = "",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100122 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200123 yarn_lock = "//:yarn.lock",
124)
125
126yarn_install(
127 name = "ui_npm",
Dmitrii Filippovba3dc7a2021-06-28 14:42:15 +0200128 args = [
129 "--prod",
130 # By default, yarn install all optional dependencies.
131 # In some cases, it installs a lot of additional dependencies which
132 # are not required (for example, "resemblejs" has one optional
133 # dependencies "canvas" that leads to tens of additional dependencies).
134 # Each additional dependency requires a license even if it is not used
135 # in our code. We want to ensure that all optional dependencies are
136 # explicitly added to package.json.
137 "--ignore-optional",
138 ],
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100139 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100140 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200141 package_json = "//:polygerrit-ui/app/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200142 package_path = "polygerrit-ui/app",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100143 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200144 yarn_lock = "//:polygerrit-ui/app/yarn.lock",
145)
146
147yarn_install(
148 name = "ui_dev_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100149 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100150 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200151 package_json = "//:polygerrit-ui/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200152 package_path = "polygerrit-ui",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100153 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200154 yarn_lock = "//:polygerrit-ui/yarn.lock",
155)
156
157yarn_install(
158 name = "tools_npm",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100159 exports_directories_only = False,
David Ostrovsky6cb69ef2020-11-21 09:30:20 +0100160 frozen_lockfile = False,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200161 package_json = "//:tools/node_tools/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200162 package_path = "tools/node_tools",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100163 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200164 yarn_lock = "//:tools/node_tools/yarn.lock",
165)
166
167yarn_install(
168 name = "plugins_npm",
169 args = ["--prod"],
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 = "//:plugins/package.json",
Ben Rohlfsa935bd02021-08-03 15:48:59 +0200173 package_path = "plugins",
David Ostrovskyf2c9a3d2022-02-12 14:53:31 +0100174 symlink_node_modules = True,
David Ostrovskyffa5cce2020-06-27 11:00:10 +0200175 yarn_lock = "//:plugins/yarn.lock",
176)
177
Luca Milanesio6b192142017-01-26 14:24:53 +0000178external_plugin_deps()