Add support for Bazel in Gerrit tree build
Self equality checks are removed because they are flagged by error
prone as violation of SelfEquals bug pattern:
The arguments to equals method are the same object, so it always returns
true.
http://errorprone.info/bugpattern/SelfEquals
Change-Id: Ic68dbe65b2fc89e7d008b476ea39e3e7f831c0ae
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..6746dd8
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,34 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load(
+ "//tools/bzl:plugin.bzl",
+ "gerrit_plugin",
+ "PLUGIN_DEPS",
+ "PLUGIN_TEST_DEPS",
+)
+
+gerrit_plugin(
+ name = "events-log",
+ srcs = glob(["src/main/java/**/*.java"]),
+ resources = glob(["src/main/resources/**/*"]),
+ manifest_entries = [
+ "Gerrit-PluginName: events-log",
+ "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/events-log",
+ "Gerrit-Module: com.ericsson.gerrit.plugins.eventslog.sql.SQLModule",
+ "Gerrit-HttpModule: com.ericsson.gerrit.plugins.eventslog.HttpModule",
+ ],
+ deps = [
+ "@gson//jar:neverlink",
+ "@commons_dbcp//jar:neverlink",
+ ],
+)
+
+junit_tests(
+ name = "events_log_tests",
+ srcs = glob(["src/test/java/**/*.java"]),
+ tags = ["events-log"],
+ deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+ ":events-log__plugin",
+ "@mockito//jar",
+ ],
+ testonly = 1,
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..53284f7
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,26 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+ 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 3756aa6..6c1ba49 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,82 +1,36 @@
Build
=====
-This plugin is built with Buck.
+This plugin is built with Bazel.
-Buck
-----
+Clone (or link) this plugin to the `plugins` directory of Gerrit's source tree.
-Two build modes are supported: Standalone and in Gerrit tree.
-The standalone build mode is recommended, as this mode doesn't require
-the Gerrit tree to exist locally.
-
-
-### 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://gerrit.googlesource.com/bucklets
-
-```
-and link it to events-log plugin directory:
-
-```
- cd events-log && 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 events-log && ln -s bucklets/buckversion .buckversion
+ bazel build plugins/@PLUGIN@
```
-Add link to the .watchmanconfig file:
-
-```
- cd events-log && ln -s bucklets/watchmanconfig .watchmanconfig
-```
-
-To build the plugin, issue the following command:
-
-```
- buck build plugin
-```
+in the root of Gerrit's source tree to build
The output is created in
```
- buck-out/gen/events-log.jar
+ bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar
```
-This project can be imported into the Eclipse IDE:
-
-```
- ./bucklets/tools/eclipse.py
-```
-
-To execute the tests run:
-
-```
- buck test
-```
-
-### 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/events-log
-```
-
-The output is created in
-
-```
- buck-out/gen/plugins/events-log/events-log.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
@@ -85,8 +39,8 @@
To execute the tests run:
```
- buck test --include events-log
+ bazel test plugins/@PLUGIN@:events_log_tests
```
More information about Buck can be found in the [Gerrit
-documentation](../../../Documentation/dev-buck.html).
+documentation](../../../Documentation/dev-bazel.html).
diff --git a/src/test/java/com/ericsson/gerrit/plugins/eventslog/sql/SQLEntryTest.java b/src/test/java/com/ericsson/gerrit/plugins/eventslog/sql/SQLEntryTest.java
index 09e7d07..c51dd3a 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/eventslog/sql/SQLEntryTest.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/eventslog/sql/SQLEntryTest.java
@@ -71,7 +71,6 @@
public void testEquals() throws Exception {
assertThat(entry1.equals(null)).isFalse();
assertThat(entry1.equals("String object")).isFalse();
- assertThat(entry1.equals(entry1)).isTrue();
assertThat(entry1.equals(entry2)).isFalse();
assertThat(entry1.equals(entry4)).isTrue();
}