Add support for Bazel in Gerrit tree build Change-Id: Ic4f3648f56f2349770e2b939706f88da5e5c5d3b
diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..27591d3 --- /dev/null +++ b/BUILD
@@ -0,0 +1,36 @@ +load("//tools/bzl:junit.bzl", "junit_tests") +load( + "//tools/bzl:plugin.bzl", + "gerrit_plugin", + "PLUGIN_DEPS", + "PLUGIN_TEST_DEPS", +) + +gerrit_plugin( + name = "its-bugzilla", + srcs = glob(["src/main/java/**/*.java"]), + resources = glob(["src/main/resources/**/*"]), + manifest_entries = [ + "Gerrit-PluginName: its-bugzilla", + "Gerrit-Module: com.googlesource.gerrit.plugins.its.bugzilla.BugzillaModule", + "Gerrit-InitStep: com.googlesource.gerrit.plugins.its.bugzilla.InitBugzilla", + "Gerrit-ReloadMode: reload", + "Implementation-Title: Bugzilla ITS Plugin", + "Implementation-URL: https://www.wikimediafoundation.org", + ], + deps = [ + "//plugins/its-base", + "//plugins/its-bugzilla/lib:j2bugzilla", + ], +) + +junit_tests( + name = "its_bugzilla_tests", + srcs = glob(["src/test/java/**/*.java"]), + tags = ["its-bugzilla"], + deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [ + ":its-bugzilla__plugin", + "//plugins/its-base:its-base", + "//plugins/its-base:its-base_tests-utils", + ], +)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl new file mode 100644 index 0000000..c1e08a8 --- /dev/null +++ b/external_plugin_deps.bzl
@@ -0,0 +1,32 @@ +load("//tools/bzl:maven_jar.bzl", "maven_jar") + +def external_plugin_deps(): + maven_jar( + name = 'j2bugzilla', + artifact = 'com.j2bugzilla:j2bugzilla:2.2.1', + sha1 = '397e40c85bda1eb0a13bccf3cb7130d8f815290e', + ) + + maven_jar( + name = 'xmlrpc-client', + artifact = 'org.apache.xmlrpc:xmlrpc-client:3.1.3', + sha1 = 'e486ad917028b52265610206fb5a1e2b5914b94b', + ) + + maven_jar( + name = 'xmlrpc-common', + artifact = 'org.apache.xmlrpc:xmlrpc-common:3.1.3', + sha1 = '415daf1f1473a947452588906dc9f5b3575fb44d', + ) + + maven_jar( + name = 'ws-commons-util', + artifact = 'org.apache.ws.commons.util:ws-commons-util:1.0.2', + sha1 = '3f478e6def772c19d1053f61198fa1f6a6119238', + ) + + maven_jar( + name = 'xml-apis', + artifact = 'xml-apis:xml-apis:1.0.b2', + sha1 = '3136ca936f64c9d68529f048c2618bd356bf85c9', + )
diff --git a/lib/BUILD b/lib/BUILD new file mode 100644 index 0000000..d518c52 --- /dev/null +++ b/lib/BUILD
@@ -0,0 +1,30 @@ +package(default_visibility = ["//visibility:public"]) + +java_library( + name = 'j2bugzilla', + runtime_deps = [':xmlrpc-client'], + exports = ["@j2bugzilla//jar"], +) + +java_library( + name = 'xmlrpc-client', + runtime_deps = [':xmlrpc-common'], + exports = ["@xmlrpc-client//jar"], +) + +java_library( + name = 'xmlrpc-common', + runtime_deps = [':ws-commons-util'], + exports = ["@xmlrpc-common//jar"], +) + +java_library( + name = 'ws-commons-util', + runtime_deps = [':xml-apis'], + exports = ["@ws-commons-util//jar"], +) + +java_library( + name = 'xml-apis', + exports = ["@xml-apis//jar"], +)
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md index 6a40483..c8736df 100644 --- a/src/main/resources/Documentation/build.md +++ b/src/main/resources/Documentation/build.md
@@ -1,16 +1,25 @@ Build ===== -This @PLUGIN@ plugin is built with Buck. +This @PLUGIN@ plugin is built with Bazel. Clone (or link) both this plugin and also [plugins/its-base](https://gerrit-review.googlesource.com/#/admin/projects/plugins/its-base) to the `plugins` directory of Gerrit's source tree. +Put the external dependency Bazel build file into the Gerrit /plugins directory, +replacing the existing empty one. + +``` + cd gerrit/plugins + rm external_plugin_deps.bzl + ln -s @PLUGIN@/external_plugin_deps.bzl . +``` + Then issue ``` - buck build plugins/@PLUGIN@ + bazel build plugins/@PLUGIN@ ``` in the root of Gerrit's source tree to build @@ -18,10 +27,12 @@ The output is created in ``` - buck-out/gen/plugins/@PLUGIN@/@PLUGIN@.jar + bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar ``` -This project can be imported into the Eclipse IDE: +This project can be imported into the Eclipse IDE. +Add the plugin name to the `CUSTOM_PLUGINS` set in +Gerrit core in `tools/bzl/plugins.bzl`, and execute: ``` ./tools/eclipse/project.py @@ -30,7 +41,7 @@ To execute the tests run: ``` - buck test --all --include @PLUGIN@ + bazel test plugins/@PLUGIN@ ``` [Back to @PLUGIN@ documentation index][index]