Skip to content

Commit b9c96df

Browse files
davidomaczech
authored andcommitted
Add Bazel build
This change adds Bazel build. Frontend build is not addressed in this change. One complication is the usage of lombok library, that has a known issue with bazel Turbine processor. Add a workaround to disable running Turbine processor for related dependencies. The plugin is split in two different artifacts: github-oauth library and github-plugin. TEST PLAN: Clone the plugin into gerrit's plugins directory. Copy plugin's own external_plugin_deps.bzl into gerrit's plugins directory. To build the github-oauth library run: $> bazel build \ plugins/github/github-oauth:github-oauth_deploy.jar To build the github-plugin run: $> bazel build plugins/github/github-plugin To run the tests: $> bazel test plugins/github/... Feature: Issue 10271 Change-Id: I21e90d50f0a4db36a74a0c34123b3da6c0ec28da
1 parent bf31249 commit b9c96df

File tree

11 files changed

+340
-0
lines changed

11 files changed

+340
-0
lines changed

BUILD

Whitespace-only changes.

external_plugin_deps.bzl

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
load("@bazel_tools//tools/build_defs/repo:java.bzl", "java_import_external")
2+
load("//tools/bzl:maven_jar.bzl", "maven_jar")
3+
4+
JENKINS = "JENKINS:"
5+
ECLIPSE_EGIT = "ECLIPSE_EGIT:"
6+
7+
def external_plugin_deps():
8+
maven_jar(
9+
name = "github-api",
10+
artifact = "org.kohsuke:github-api:1.316",
11+
sha1 = "90ea530f3aeceb46be27b924ae25b4b7b2388c9d",
12+
)
13+
14+
maven_jar(
15+
name = "axis",
16+
artifact = "org.apache.axis:axis:1.4",
17+
sha1 = "94a9ce681a42d0352b3ad22659f67835e560d107",
18+
attach_source = False,
19+
)
20+
21+
maven_jar(
22+
name = "axis-jaxrpc",
23+
artifact = "org.apache.axis:axis-jaxrpc:1.4",
24+
sha1 = "b393f1f0c0d95b68c86d0b1ab2e687bb71f3c075",
25+
attach_source = False,
26+
)
27+
28+
maven_jar(
29+
name = "eclipse-mylyn-github",
30+
artifact = "org.eclipse.mylyn.github:org.eclipse.egit.github.core:6.1.0.202203080745-r",
31+
repository = ECLIPSE_EGIT,
32+
sha1 = "a0bc7ce9f17e2d41bbfbf08e4bc63c3ae0ec15b7",
33+
attach_source = False,
34+
)
35+
36+
maven_jar(
37+
name = "commons-discovery",
38+
artifact = "commons-discovery:commons-discovery:0.5",
39+
sha1 = "3a8ac816bbe02d2f88523ef22cbf2c4abd71d6a8",
40+
attach_source = False,
41+
)
42+
43+
maven_jar(
44+
name = "velocity",
45+
artifact = "org.apache.velocity:velocity-engine-core:2.3",
46+
sha1 = "e2133b723d0e42be74880d34de6bf6538ea7f915",
47+
)
48+
49+
maven_jar(
50+
name = "lombok",
51+
artifact = "org.projectlombok:lombok:1.18.32",
52+
sha1 = "17d46b3e205515e1e8efd3ee4d57ce8018914163",
53+
)
54+
55+
maven_jar(
56+
name = "com-sun-mail",
57+
artifact = "com.sun.mail:javax.mail:1.6.2",
58+
sha1 = "935151eb71beff17a2ffac15dd80184a99a0514f",
59+
)
60+
61+
maven_jar(
62+
name = "javax-activation",
63+
artifact = "javax.activation:activation:1.1",
64+
sha1 = "e6cb541461c2834bdea3eb920f1884d1eb508b50",
65+
)
66+
67+
maven_jar(
68+
name = "jackson-core",
69+
artifact = "com.fasterxml.jackson.core:jackson-core:2.15.2",
70+
sha1 = "a6fe1836469a69b3ff66037c324d75fc66ef137c",
71+
)
72+
73+
maven_jar(
74+
name = "jackson-databind",
75+
artifact = "com.fasterxml.jackson.core:jackson-databind:2.15.2",
76+
sha1 = "9353b021f10c307c00328f52090de2bdb4b6ff9c",
77+
)
78+
79+
maven_jar(
80+
name = "jackson-annotations",
81+
artifact = "com.fasterxml.jackson.core:jackson-annotations:2.15.2",
82+
sha1 = "4724a65ac8e8d156a24898d50fd5dbd3642870b8",
83+
)
84+
85+
maven_jar(
86+
name = "org-ow2-asm",
87+
artifact = "org.ow2.asm:asm:9.6",
88+
sha1 = "aa205cf0a06dbd8e04ece91c0b37c3f5d567546a",
89+
)
90+
91+
maven_jar(
92+
name = "org-ow2-asm-tree",
93+
artifact = "org.ow2.asm:asm-tree:9.6",
94+
sha1 = "c0cdda9d211e965d2a4448aa3fd86110f2f8c2de",
95+
)
96+
97+
maven_jar(
98+
name = "org-ow2-asm-commons",
99+
artifact = "org.ow2.asm:asm-commons:9.6",
100+
sha1 = "f1a9e5508eff490744144565c47326c8648be309",
101+
)
102+
103+
maven_jar(
104+
name = "bridge-method-injector",
105+
artifact = "com.infradna.tool:bridge-method-injector:1.29",
106+
repository = JENKINS,
107+
sha1 = "5b6c616c7a6e04beb4178327d616af4f1bbe88da",
108+
)
109+
110+
maven_jar(
111+
name = "bridge-method-annotation",
112+
artifact = "com.infradna.tool:bridge-method-annotation:1.29",
113+
repository = JENKINS,
114+
sha1 = "55dd67d0578d107697803a95cb9c235a9bd83ec1",
115+
)

github-oauth/BUILD

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
load("//tools/bzl:junit.bzl", "junit_tests")
2+
load("//tools/bzl:plugin.bzl", "PLUGIN_DEPS", "PLUGIN_DEPS_NEVERLINK")
3+
4+
java_binary(
5+
name = "github-oauth",
6+
main_class = "Dummy",
7+
runtime_deps = [":github-oauth-lib"],
8+
)
9+
10+
java_library(
11+
name = "github-oauth-lib",
12+
srcs = glob(["src/main/java/**/*.java"]),
13+
visibility = ["//visibility:public"],
14+
deps = PLUGIN_DEPS_NEVERLINK + [
15+
"//lib:servlet-api",
16+
"@bridge-method-annotation//jar",
17+
"@bridge-method-injector//jar",
18+
"@commons-io//jar",
19+
"@github-api//jar",
20+
"@jackson-annotations//jar",
21+
"@jackson-core//jar",
22+
"@jackson-databind//jar",
23+
"@org-ow2-asm-commons//jar",
24+
"@org-ow2-asm-tree//jar",
25+
"@org-ow2-asm//jar",
26+
],
27+
)
28+
29+
junit_tests(
30+
name = "github-oauth_tests",
31+
srcs = glob(["src/test/java/**/*.java"]),
32+
tags = ["github"],
33+
deps = PLUGIN_DEPS + [
34+
":github-oauth-lib",
35+
],
36+
)

github-plugin/BUILD

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
load(
2+
"//plugins/github:java_library_without_header_compilation.bzl",
3+
"java_library_without_header_compilation",
4+
)
5+
load("//tools/bzl:junit.bzl", "junit_tests")
6+
load("//tools/bzl:plugin.bzl", "PLUGIN_DEPS", "PLUGIN_DEPS_NEVERLINK", "PLUGIN_TEST_DEPS", "gerrit_plugin")
7+
8+
SOURCES_WITH_LOMBOK_USAGE = [
9+
"src/main/java/com/googlesource/gerrit/plugins/github/git/GitHubRepository.java",
10+
"src/main/java/com/googlesource/gerrit/plugins/github/GitHubURL.java",
11+
]
12+
13+
gerrit_plugin(
14+
name = "github-plugin",
15+
srcs = glob(
16+
["src/main/java/**/*.java"],
17+
exclude = SOURCES_WITH_LOMBOK_USAGE,
18+
),
19+
dir_name = "github",
20+
manifest_entries = [
21+
"Gerrit-PluginName: github-plugin",
22+
"Gerrit-Module: com.googlesource.gerrit.plugins.github.GuiceModule",
23+
"Gerrit-HttpModule: com.googlesource.gerrit.plugins.github.GuiceHttpModule",
24+
"Gerrit-InitStep: com.googlesource.gerrit.plugins.github.InitGitHub",
25+
"Implementation-Title: GitHub plugin",
26+
"Implementation-Vendor: GerritForge",
27+
"Implementation-URL: http://www.gerritforge.com",
28+
],
29+
resource_jars = ["//plugins/github/github-plugin/web:github-plugin"],
30+
resources = glob(["src/main/resources/**/*"]),
31+
deps = [
32+
":github-plugin-lib",
33+
"//plugins/github/github-oauth:github-oauth-lib",
34+
"@axis-jaxrpc//jar",
35+
"@axis//jar",
36+
"@com-sun-mail//jar",
37+
"@commons-codec//jar",
38+
"@commons-discovery//jar",
39+
"@commons-io//jar",
40+
"@eclipse-mylyn-github//jar",
41+
"@github-api//jar",
42+
"@javax-activation//jar",
43+
"@velocity//jar",
44+
],
45+
)
46+
47+
java_library_without_header_compilation(
48+
name = "github-plugin-lib",
49+
dep = ":github-plugin-lib_impl",
50+
visibility = ["//visibility:public"],
51+
)
52+
53+
java_library(
54+
name = "github-plugin-lib_impl",
55+
srcs = SOURCES_WITH_LOMBOK_USAGE,
56+
deps = PLUGIN_DEPS_NEVERLINK + [
57+
":lombok",
58+
"//plugins/github/github-oauth:github-oauth-lib",
59+
"@axis-jaxrpc//jar",
60+
"@axis//jar",
61+
"@commons-codec//jar",
62+
"@commons-discovery//jar",
63+
"@commons-io//jar",
64+
"@eclipse-mylyn-github//jar",
65+
"@github-api//jar",
66+
"@velocity//jar",
67+
],
68+
)
69+
70+
junit_tests(
71+
name = "github-plugin_tests",
72+
srcs = glob(["src/test/java/**/*.java"]),
73+
tags = ["github"],
74+
deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
75+
":github-plugin-lib",
76+
":github-plugin__plugin",
77+
"//javatests/com/google/gerrit/util/http/testutil",
78+
"//plugins/github/github-oauth:github-oauth-lib",
79+
"@commons-io//jar",
80+
],
81+
)
82+
83+
java_plugin(
84+
name = "lombok_plugin",
85+
generates_api = True,
86+
processor_class = "lombok.launch.AnnotationProcessorHider$AnnotationProcessor",
87+
deps = ["@lombok//jar"],
88+
)
89+
90+
java_library(
91+
name = "lombok",
92+
exported_plugins = [":lombok_plugin"],
93+
neverlink = True,
94+
exports = ["@lombok//jar"],
95+
)

github-plugin/src/test/java/com/googlesource/gerrit/plugins/github/FakeHttpSession.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import javax.servlet.ServletContext;
2020
import javax.servlet.http.HttpSession;
2121
import javax.servlet.http.HttpSessionContext;
22+
import org.junit.Ignore;
2223

24+
@Ignore
2325
public class FakeHttpSession implements HttpSession {
2426
private final HashMap<String, Object> attributes;
2527

github-plugin/web/.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @license
3+
* Copyright 2022 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
__plugindir = "github/github-plugin/web";
7+
module.exports = {
8+
extends: "../../../.eslintrc.js",
9+
};

github-plugin/web/BUILD

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
load("//tools/js:eslint.bzl", "plugin_eslint")
2+
load("//tools/bzl:js.bzl", "gerrit_js_bundle")
3+
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
4+
5+
package_group(
6+
name = "visibility",
7+
packages = ["//plugins/github/github-plugin/..."],
8+
)
9+
10+
package(default_visibility = [":visibility"])
11+
12+
ts_config(
13+
name = "tsconfig",
14+
src = "tsconfig.json",
15+
deps = [
16+
"//plugins:tsconfig-plugins-base.json",
17+
],
18+
)
19+
20+
ts_project(
21+
name = "github-plugin-ts",
22+
srcs = glob(
23+
["**/*.ts"],
24+
),
25+
incremental = True,
26+
out_dir = "_bazel_ts_out",
27+
tsc = "//tools/node_tools:tsc-bin",
28+
tsconfig = ":tsconfig",
29+
deps = [
30+
"@plugins_npm//@gerritcodereview/typescript-api",
31+
"@plugins_npm//lit",
32+
"@plugins_npm//rxjs",
33+
],
34+
)
35+
36+
gerrit_js_bundle(
37+
name = "github-plugin",
38+
srcs = [":github-plugin-ts"],
39+
entry_point = "_bazel_ts_out/main.js",
40+
)
41+
42+
plugin_eslint()
File renamed without changes.

github-plugin/web/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../../tsconfig-plugins-base.json",
3+
"compilerOptions": {
4+
"experimentalDecorators": true,
5+
/* outDir for IDE (overridden by Bazel rule arg) */
6+
"outDir": "../../../../.ts-out/plugins/github-plugin/ui",
7+
},
8+
"include": [
9+
"**/*",
10+
],
11+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See https://github.com/bazelbuild/bazel/issues/12837
2+
# for workaround suggestion for incompatibility between
3+
# Bazel Turbine processor and Lombok library.
4+
5+
def _java_header_compilation_transition(settings, attr):
6+
_ignore = (settings, attr)
7+
return {"//command_line_option:java_header_compilation": "False"}
8+
9+
java_header_compilation_transition = transition(
10+
implementation = _java_header_compilation_transition,
11+
inputs = [],
12+
outputs = ["//command_line_option:java_header_compilation"],
13+
)
14+
15+
def _java_library_without_header_compilation(ctx):
16+
return [java_common.merge([d[JavaInfo] for d in ctx.attr.dep])]
17+
18+
java_library_without_header_compilation = rule(
19+
implementation = _java_library_without_header_compilation,
20+
attrs = {
21+
"dep": attr.label(
22+
providers = [JavaInfo],
23+
mandatory = True,
24+
cfg = java_header_compilation_transition,
25+
),
26+
"_allowlist_function_transition": attr.label(
27+
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
28+
),
29+
},
30+
)

0 commit comments

Comments
 (0)