Merge branch 'stable-2.13'

* stable-2.13:
  Fix compilation error

Change-Id: I1b5b20873e2b194b618052d14c5b4ca31c0b9b2f
diff --git a/.buckconfig b/.buckconfig
index 1e032e5..97c50e0 100644
--- a/.buckconfig
+++ b/.buckconfig
@@ -5,6 +5,8 @@
 
 [java]
   src_roots = java, resources
+  source_level = 8
+  target_level = 8
 
 [project]
   ignore = .git, eclipse-out
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/lib/gerrit/BUCK b/lib/gerrit/BUCK
index f83d917..8d5f0e9 100644
--- a/lib/gerrit/BUCK
+++ b/lib/gerrit/BUCK
@@ -1,12 +1,11 @@
 include_defs('//bucklets/maven_jar.bucklet')
 
-VER = '2.13'
-REPO = MAVEN_CENTRAL
+VER = '2.14-SNAPSHOT'
+REPO = MAVEN_LOCAL
 
 maven_jar(
   name = 'acceptance-framework',
   id = 'com.google.gerrit:gerrit-acceptance-framework:' + VER,
-  sha1 = 'a6913a61196a8fccdb45e761f43a0b7e21867c90',
   license = 'Apache2.0',
   attach_source = False,
   repository = REPO,
@@ -15,7 +14,6 @@
 maven_jar(
   name = 'plugin-api',
   id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
-  sha1 = 'e25d55b8f41627c4ae6b9d2069ec398638b219a3',
   license = 'Apache2.0',
   attach_source = False,
   repository = REPO,
diff --git a/src/main/java/com/ericsson/gerrit/plugins/eventslog/sql/SQLQueryMaker.java b/src/main/java/com/ericsson/gerrit/plugins/eventslog/sql/SQLQueryMaker.java
index a82f0c5..b01de71 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/eventslog/sql/SQLQueryMaker.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/eventslog/sql/SQLQueryMaker.java
@@ -37,20 +37,10 @@
   private static final int TWO = 2;
   private static final String TIME_ONE = "t1";
   private static final String TIME_TWO = "t2";
-  private static final ThreadLocal<DateFormat> DATE_TIME_FORMAT =
-      new ThreadLocal<DateFormat>() {
-        @Override
-        protected DateFormat initialValue() {
-          return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        }
-      };
-  private static final ThreadLocal<DateFormat> DATE_ONLY_FORMAT =
-      new ThreadLocal<DateFormat>() {
-        @Override
-        protected DateFormat initialValue() {
-          return new SimpleDateFormat("yyyy-MM-dd");
-        }
-      };
+  private static final ThreadLocal<DateFormat> DATE_TIME_FORMAT = ThreadLocal
+      .withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
+  private static final ThreadLocal<DateFormat> DATE_ONLY_FORMAT = ThreadLocal
+      .withInitial(() -> new SimpleDateFormat("yyyy-MM-dd"));
 
   private final int returnLimit;
 
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/EventsLogIT.java b/src/test/java/com/ericsson/gerrit/plugins/eventslog/EventsLogIT.java
index 45391c0..af0180b 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/eventslog/EventsLogIT.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/eventslog/EventsLogIT.java
@@ -17,11 +17,17 @@
 import static com.google.common.truth.Truth.assertThat;
 
 import com.google.gerrit.acceptance.GerritConfig;
-import com.google.gerrit.acceptance.PluginDaemonTest;
+import com.google.gerrit.acceptance.LightweightPluginDaemonTest;
+import com.google.gerrit.acceptance.TestPlugin;
 
 import org.junit.Test;
 
-public class EventsLogIT extends PluginDaemonTest {
+@TestPlugin(
+    name = "events-log",
+    sysModule = "com.ericsson.gerrit.plugins.eventslog.sql.SQLModule",
+    httpModule = "com.ericsson.gerrit.plugins.eventslog.HttpModule"
+)
+public class EventsLogIT extends LightweightPluginDaemonTest {
 
   @Test
   @GerritConfig(name = "plugin.events-log.storeUrl", value = "jdbc:h2:mem:db")
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();
   }