blob: 39560c50e97308b4acf8b70546bfa6012912bfbd [file] [log] [blame]
David Pursehouse31c82402019-09-04 15:02:32 +09001load("@rules_java//java:defs.bzl", "java_binary", "java_library")
David Ostrovskyfa189072016-11-30 08:52:06 +01002load("//tools/bzl:genrule2.bzl", "genrule2")
David Pursehouse1d536682019-01-10 21:44:13 +09003load("//tools/bzl:javadoc.bzl", "java_doc")
Jacek Centkowski75d1c182017-02-24 14:59:15 +01004load(
5 "//tools/bzl:plugins.bzl",
6 "CORE_PLUGINS",
7 "CUSTOM_PLUGINS",
8)
Ben Rohlfse510fa72022-12-20 09:42:41 +01009load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test")
Ben Rohlfsb3e7cd52021-08-10 11:42:54 +020010
11package(default_visibility = ["//visibility:public"])
12
Ben Rohlfsaf3ea832021-08-17 13:10:16 +020013exports_files([
14 ".eslintrc.js",
15 ".eslintignore",
16 ".prettierrc.js",
17 "rollup.config.js",
18 "tsconfig-plugins-base.json",
19])
Ben Rohlfsb3e7cd52021-08-10 11:42:54 +020020
David Ostrovskyaf719682016-09-28 20:31:18 +020021genrule2(
David Ostrovskyfa189072016-11-30 08:52:06 +010022 name = "core",
Jacek Centkowski75d1c182017-02-24 14:59:15 +010023 srcs = ["//plugins/%s:%s.jar" % (n, n) for n in CORE_PLUGINS + CUSTOM_PLUGINS],
David Ostrovskyfa189072016-11-30 08:52:06 +010024 outs = ["core.zip"],
25 cmd = "mkdir -p $$TMP/WEB-INF/plugins;" +
26 "for s in $(SRCS) ; do " +
27 "ln -s $$ROOT/$$s $$TMP/WEB-INF/plugins;done;" +
28 "cd $$TMP;" +
29 "zip -qr $$ROOT/$@ .",
David Ostrovskyaf719682016-09-28 20:31:18 +020030)
David Ostrovsky32c69332017-08-24 22:10:33 +020031
32PLUGIN_API = [
David Ostrovsky590071e2017-09-21 22:54:20 +020033 "//java/com/google/gerrit/server",
Han-Wen Nienhuysfd6962b2018-07-06 15:39:30 +020034 "//java/com/google/gerrit/server/ioutil",
David Ostrovskye1f11c72018-01-18 06:35:24 +010035 "//java/com/google/gerrit/server/restapi",
David Ostrovsky32c69332017-08-24 22:10:33 +020036 "//java/com/google/gerrit/pgm/init/api",
David Ostrovsky32c69332017-08-24 22:10:33 +020037 "//java/com/google/gerrit/httpd",
38 "//java/com/google/gerrit/sshd",
39]
40
41EXPORTS = [
David Ostrovskyf51cf232018-08-31 06:19:26 +020042 "//antlr3:query_parser",
David Ostrovsky32c69332017-08-24 22:10:33 +020043 "//java/com/google/gerrit/common:annotations",
44 "//java/com/google/gerrit/common:server",
Dave Borowitz62f32fc2019-01-15 18:45:22 -080045 "//java/com/google/gerrit/exceptions",
David Ostrovsky32c69332017-08-24 22:10:33 +020046 "//java/com/google/gerrit/extensions:api",
Dave Borowitz3770c702018-11-13 17:07:14 -080047 "//java/com/google/gerrit/git",
David Ostrovsky32c69332017-08-24 22:10:33 +020048 "//java/com/google/gerrit/index",
Luca Milanesiobd73b492018-12-29 20:11:41 +000049 "//java/com/google/gerrit/index/project",
David Ostrovsky32c69332017-08-24 22:10:33 +020050 "//java/com/google/gerrit/index:query_exception",
Dave Borowitz87bfe682018-12-18 17:59:29 -080051 "//java/com/google/gerrit/json",
David Ostrovsky32c69332017-08-24 22:10:33 +020052 "//java/com/google/gerrit/lifecycle",
David Ostrovskye994e852019-10-06 00:13:58 +020053 "//java/com/google/gerrit/lucene",
David Ostrovskyda429b72019-01-29 09:04:01 +010054 "//java/com/google/gerrit/mail",
David Ostrovsky32c69332017-08-24 22:10:33 +020055 "//java/com/google/gerrit/metrics",
56 "//java/com/google/gerrit/metrics/dropwizard",
David Ostrovskyb03a6e92019-05-26 14:11:47 +020057 "//java/com/google/gerrit/entities",
David Ostrovskyfc1a9c72019-04-17 07:51:58 -070058 "//java/com/google/gerrit/server/api",
David Ostrovsky37748ec2018-08-14 08:36:11 +020059 "//java/com/google/gerrit/server/audit",
David Pursehousea1dacf12019-01-25 11:37:14 +090060 "//java/com/google/gerrit/server/cache/mem",
Dave Borowitzdd504042019-05-02 07:39:11 -070061 "//java/com/google/gerrit/server/cache/serialize",
David Ostrovskydd562522020-07-03 06:25:53 +020062 "//java/com/google/gerrit/server/data",
Edwin Kempinf2c38302021-04-19 12:54:23 +020063 "//java/com/google/gerrit/server/git/receive",
Edwin Kempin87527aa2018-09-06 16:12:54 +020064 "//java/com/google/gerrit/server/logging",
David Ostrovsky460a3f32018-09-04 08:13:51 +020065 "//java/com/google/gerrit/server/schema",
Edwin Kempinad196262018-09-18 17:55:51 +020066 "//java/com/google/gerrit/server/util/time",
David Ostrovskyf9f77be2022-05-14 10:27:35 +020067 "//java/com/google/gerrit/proto",
David Pursehouse562b1662018-11-17 00:31:41 -080068 "//java/com/google/gerrit/util/cli",
Dave Borowitz791da3a642018-06-12 10:52:22 -040069 "//java/com/google/gerrit/util/http",
Jacek Centkowskia215f3e2020-03-10 20:25:33 +010070 "//java/com/google/gerrit/util/logging",
David Ostrovskyfc1a9c72019-04-17 07:51:58 -070071 "//lib/antlr:java-runtime",
72 "//lib/auto:auto-value-annotations",
David Ostrovskyab6d2a12021-03-25 21:36:51 +010073 "//lib/auto:auto-value-gson",
David Pursehouse4610fca2018-07-17 12:56:33 +090074 "//lib/commons:compress",
David Ostrovsky32c69332017-08-24 22:10:33 +020075 "//lib/commons:dbcp",
Youssef Elghareeb9d0393c2021-10-07 17:29:11 +020076 "//lib/commons:lang3",
David Ostrovsky32c69332017-08-24 22:10:33 +020077 "//lib/dropwizard:dropwizard-core",
Edwin Kempin8860e8e2018-05-08 11:19:37 +020078 "//lib/flogger:api",
David Ostrovsky32c69332017-08-24 22:10:33 +020079 "//lib/guice:guice",
80 "//lib/guice:guice-assistedinject",
81 "//lib/guice:guice-servlet",
David Ostrovskye1359a32018-06-08 09:16:50 +020082 "//lib/guice:javax_inject",
David Ostrovsky32c69332017-08-24 22:10:33 +020083 "//lib/httpcomponents:httpclient",
84 "//lib/httpcomponents:httpcore",
David Ostrovsky8bec8552019-06-19 01:07:43 +020085 "//lib:jgit-servlet",
86 "//lib:jgit",
David Pursehouse5adfd1b2019-06-30 16:24:48 +090087 "//lib:jsr305",
David Ostrovsky32c69332017-08-24 22:10:33 +020088 "//lib/log:api",
89 "//lib/log:log4j",
90 "//lib/mina:sshd",
91 "//lib/ow2:ow2-asm",
92 "//lib/ow2:ow2-asm-analysis",
93 "//lib/ow2:ow2-asm-commons",
94 "//lib/ow2:ow2-asm-util",
95 "//lib:args4j",
96 "//lib:blame-cache",
97 "//lib:guava",
98 "//lib:guava-retrying",
99 "//lib:gson",
David Ostrovsky32c69332017-08-24 22:10:33 +0200100 "//lib:icu4j",
David Ostrovsky32c69332017-08-24 22:10:33 +0200101 "//lib:mime-util",
102 "//lib:protobuf",
David Ostrovsky753738b2019-09-23 22:41:19 +0200103 "//lib:servlet-api-without-neverlink",
David Ostrovsky32c69332017-08-24 22:10:33 +0200104 "//lib:soy",
105 "//prolog:gerrit-prolog-common",
106]
107
108java_binary(
David Ostrovskya8f47b52020-01-24 20:17:37 +0100109 name = "bouncycastle-deploy-env",
110 main_class = "Dummy",
Ben Rohlfsb3e7cd52021-08-10 11:42:54 +0200111 visibility = ["//visibility:private"],
David Ostrovskya8f47b52020-01-24 20:17:37 +0100112 runtime_deps = [
113 "//lib/bouncycastle:bcpg",
114 "//lib/bouncycastle:bcpkix",
115 "//lib/bouncycastle:bcprov",
116 ],
117)
118
119java_binary(
David Ostrovsky32c69332017-08-24 22:10:33 +0200120 name = "plugin-api",
David Ostrovskya8f47b52020-01-24 20:17:37 +0100121 deploy_env = ["bouncycastle-deploy-env"],
David Ostrovsky32c69332017-08-24 22:10:33 +0200122 main_class = "Dummy",
David Ostrovsky32c69332017-08-24 22:10:33 +0200123 runtime_deps = [":plugin-lib"],
124)
125
126java_library(
127 name = "plugin-lib",
David Ostrovsky32c69332017-08-24 22:10:33 +0200128 exports = PLUGIN_API + EXPORTS,
129)
130
131java_library(
132 name = "plugin-lib-neverlink",
133 neverlink = 1,
David Ostrovsky32c69332017-08-24 22:10:33 +0200134 exports = PLUGIN_API + EXPORTS,
135)
136
137java_binary(
138 name = "plugin-api-sources",
139 main_class = "Dummy",
David Ostrovsky32c69332017-08-24 22:10:33 +0200140 runtime_deps = [
David Ostrovskyf51cf232018-08-31 06:19:26 +0200141 "//antlr3:libquery_parser-src.jar",
David Ostrovsky32c69332017-08-24 22:10:33 +0200142 "//java/com/google/gerrit/common:libannotations-src.jar",
143 "//java/com/google/gerrit/common:libserver-src.jar",
David Ostrovskyb03a6e92019-05-26 14:11:47 +0200144 "//java/com/google/gerrit/entities:libentities-src.jar",
David Ostrovsky32c69332017-08-24 22:10:33 +0200145 "//java/com/google/gerrit/extensions:libapi-src.jar",
146 "//java/com/google/gerrit/httpd:libhttpd-src.jar",
147 "//java/com/google/gerrit/index:libindex-src.jar",
148 "//java/com/google/gerrit/index:libquery_exception-src.jar",
David Ostrovsky32c69332017-08-24 22:10:33 +0200149 "//java/com/google/gerrit/pgm/init/api:libapi-src.jar",
David Ostrovsky590071e2017-09-21 22:54:20 +0200150 "//java/com/google/gerrit/server:libserver-src.jar",
David Ostrovskye1f11c72018-01-18 06:35:24 +0100151 "//java/com/google/gerrit/server/restapi:librestapi-src.jar",
David Ostrovsky32c69332017-08-24 22:10:33 +0200152 "//java/com/google/gerrit/sshd:libsshd-src.jar",
Dave Borowitz791da3a642018-06-12 10:52:22 -0400153 "//java/com/google/gerrit/util/http:libhttp-src.jar",
David Ostrovsky32c69332017-08-24 22:10:33 +0200154 ],
155)
156
David Ostrovsky32c69332017-08-24 22:10:33 +0200157java_doc(
158 name = "plugin-api-javadoc",
159 libs = PLUGIN_API + [
David Ostrovskyf51cf232018-08-31 06:19:26 +0200160 "//antlr3:query_parser",
David Ostrovsky32c69332017-08-24 22:10:33 +0200161 "//java/com/google/gerrit/index",
162 "//java/com/google/gerrit/index:query_exception",
David Ostrovsky32c69332017-08-24 22:10:33 +0200163 "//java/com/google/gerrit/common:annotations",
164 "//java/com/google/gerrit/common:server",
165 "//java/com/google/gerrit/extensions:api",
David Ostrovskyb03a6e92019-05-26 14:11:47 +0200166 "//java/com/google/gerrit/entities",
Dave Borowitz791da3a642018-06-12 10:52:22 -0400167 "//java/com/google/gerrit/util/http",
David Ostrovsky32c69332017-08-24 22:10:33 +0200168 ],
169 pkgs = ["com.google.gerrit"],
170 title = "Gerrit Review Plugin API Documentation",
David Ostrovsky32c69332017-08-24 22:10:33 +0200171)
Ben Rohlfse510fa72022-12-20 09:42:41 +0100172
173# This is a generic test target for TypeScript plugins.
174#
175# `nodejs_test` needs to run in the directory where the `package.json` and
176# `node_modules` are, so unfortunately we cannot move this target into the
177# BUILD files of individual plugins. On the other hand one common target
178# for all plugins also has the advantage of being re-usable.
179#
180# For making this work for a specific plugin you have make the source files
181# of the plugin available as a `filegroup` and add it to the `data` attribute.
182# And you have to specify the `PLUGIN_DIR` in the `env` attribute.
183nodejs_test(
184 name = "web-test-runner",
185 size = "large",
186 chdir = package_name(),
187 data = [
188 ":package.json",
189 ":web-test-runner.config.mjs",
190 # This is an example of how you could reference your plugin sources:
191 # "//plugins/codemirror-editor/web:codemirror-test-sources",
192 "@plugins_npm//:node_modules",
193 ],
194 entry_point = "@plugins_npm//:node_modules/@web/test-runner/dist/bin.js",
195 env = {"PLUGIN_DIR": "codemirror-editor"},
196 tags = [
197 "local",
198 "manual",
199 ],
200)