Add support for gerrit v3.10.1-596-g83d0243eef or later

Replace usage of Consumer<AccountDelta.Builder> with new interface
AccountsUpdate.ConfigureStatelessDelta as introduced in change
I86e1b30f65ad23.

Also remove support for standalone build so that gerrit CI passes
successfully. gerrit CI uses build command [1] that only supports
in-tree builds.

[1] bazelisk build plugins/${pluginName}/...

Change-Id: If2fb4b479fa1d6c8185c857fbe3033d3081906fb
diff --git a/.bazelrc b/.bazelrc
deleted file mode 100644
index f9248ea..0000000
--- a/.bazelrc
+++ /dev/null
@@ -1,2 +0,0 @@
-build --workspace_status_command="python3 ./tools/workspace_status.py"
-test --build_tests_only
diff --git a/.bazelversion b/.bazelversion
deleted file mode 100644
index 91e4a9f..0000000
--- a/.bazelversion
+++ /dev/null
@@ -1 +0,0 @@
-6.3.2
diff --git a/BUILD b/BUILD
index 7562452..05321c7 100644
--- a/BUILD
+++ b/BUILD
@@ -5,7 +5,6 @@
     "PLUGIN_TEST_DEPS",
     "gerrit_plugin",
 )
-load("@rules_java//java:defs.bzl", "java_library", "java_plugin")
 
 plugin_name = "remote-gerrit-account-cache"
 
@@ -23,3 +22,9 @@
         "Implementation-Title: remote-gerrit-account-cache Plugin",
     ],
 )
+
+sh_test(
+    name = "always_pass_test",
+    size = "small",
+    srcs = ["src/test/always_pass_test.sh"],
+)
diff --git a/README.md b/README.md
index df14343..f61d6c1 100644
--- a/README.md
+++ b/README.md
@@ -53,20 +53,43 @@
 
 
 # How to build
+This libModule is built like a Gerrit in-tree plugin, using Bazelisk.
 
-This lib can be built either standalone or in-tree.
+Build in Gerrit tree
+Create a symbolic link of the repository source to the Gerrit source tree /plugins/remote-gerrit-account-cache directory.
 
 Example:
-
 ```
-bazel build remote-gerrit-account-cache
+git clone https://gerrit.googlesource.com/gerrit
+git clone https://gerrit.googlesource.com/modules/remote-gerrit-account-cache
+cd gerrit/plugins
+ln -s ../../remote-gerrit-account-cache .
+```
+From the Gerrit source tree issue the command bazelisk build plugins/remote-gerrit-account-cache
+
+Example:
+```
+bazelisk build plugins/remote-gerrit-account-cache
+```
+The libModule jar file is created under bazel-bin/plugins/remote-gerrit-account-cache/remote-gerrit-account-cache.jar
+
+To execute the tests run bazelisk test plugins/remote-gerrit-account-cache/... from the Gerrit source tree.
+
+Example:
+```
+bazelisk test plugins/remote-gerrit-account-cache/...
 ```
 
-The output module jar is created in:
+# How to import into Eclipse as a project
+Add remote-gerrit-account-cache in the CUSTOM_PLUGINS section of the tools/bzl/plugins.bzl.
 
+Example:
 ```
-bazel-bin/remote-gerrit-account-cache.jar
+CUSTOM_PLUGINS = [
+    "remote-gerrit-account-cache",
+]
 ```
+Run tools/eclipse/project.py for generating or updating the Eclipse project.
 
 # How to install
 
diff --git a/WORKSPACE b/WORKSPACE
deleted file mode 100644
index 653549f..0000000
--- a/WORKSPACE
+++ /dev/null
@@ -1,18 +0,0 @@
-workspace(name = "remote-gerrit-account-cache")
-
-load("//:bazlets.bzl", "load_bazlets")
-
-load_bazlets(
-    commit = "f9c119e45d9a241bee720b7fbd6c7fdbc952da5f",
-)
-
-load(
-    "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
-    "gerrit_api",
-)
-
-# Load release Plugin API
-gerrit_api(
-    plugin_api_sha1 = "f381f9c10d09e08494c8ca442e978fb6bd84ff7e",
-    version = "3.10.0-rc2-20-g95d1c1c80d",
-)
diff --git a/bazlets.bzl b/bazlets.bzl
deleted file mode 100644
index f089af4..0000000
--- a/bazlets.bzl
+++ /dev/null
@@ -1,18 +0,0 @@
-load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
-
-NAME = "com_googlesource_gerrit_bazlets"
-
-def load_bazlets(
-        commit,
-        local_path = None):
-    if not local_path:
-        git_repository(
-            name = NAME,
-            remote = "https://gerrit.googlesource.com/bazlets",
-            commit = commit,
-        )
-    else:
-        native.local_repository(
-            name = NAME,
-            path = local_path,
-        )
diff --git a/src/main/java/com/googlesource/gerrit/plugins/remotegerritaccountcache/AccountCacheImpl.java b/src/main/java/com/googlesource/gerrit/plugins/remotegerritaccountcache/AccountCacheImpl.java
index d6d8a1f..ab7dcd0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/remotegerritaccountcache/AccountCacheImpl.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/remotegerritaccountcache/AccountCacheImpl.java
@@ -33,7 +33,6 @@
 import com.google.gerrit.server.ModuleImpl;
 import com.google.gerrit.server.account.AccountCache;
 import com.google.gerrit.server.account.AccountConfig;
-import com.google.gerrit.server.account.AccountDelta;
 import com.google.gerrit.server.account.AccountState;
 import com.google.gerrit.server.account.AccountsUpdate;
 import com.google.gerrit.server.account.CachedAccountDetails;
@@ -74,7 +73,6 @@
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.eclipse.jgit.lib.ObjectId;
@@ -295,7 +293,7 @@
       } catch (Exception ignore) {
       }
 
-      Consumer<AccountDelta.Builder> update =
+      AccountsUpdate.ConfigureStatelessDelta update =
           u ->
               u.setFullName(accountInfo.name)
                   .setDisplayName(accountInfo.displayName)
diff --git a/tools/bzl/always_pass_test.sh b/src/test/always_pass_test.sh
similarity index 92%
rename from tools/bzl/always_pass_test.sh
rename to src/test/always_pass_test.sh
index e172ff6..204ee2c 100755
--- a/tools/bzl/always_pass_test.sh
+++ b/src/test/always_pass_test.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 #
-# Copyright (C) 2023 The Android Open Source Project
+# Copyright (C) 2024 The Android Open Source Project
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -19,4 +19,3 @@
 # https://github.com/bazelbuild/bazel/issues/11465
 
 exit 0
-
diff --git a/tools/BUILD b/tools/BUILD
deleted file mode 100644
index 1fa2160..0000000
--- a/tools/BUILD
+++ /dev/null
@@ -1 +0,0 @@
-# Empty file - bazel treat directories with BUILD file as a package
\ No newline at end of file
diff --git a/tools/bzl/BUILD b/tools/bzl/BUILD
deleted file mode 100644
index c117c67..0000000
--- a/tools/bzl/BUILD
+++ /dev/null
@@ -1,5 +0,0 @@
-sh_test(
-    name = "always_pass_test",
-    srcs = ["always_pass_test.sh"],
-)
-
diff --git a/tools/bzl/classpath.bzl b/tools/bzl/classpath.bzl
deleted file mode 100644
index c921d01..0000000
--- a/tools/bzl/classpath.bzl
+++ /dev/null
@@ -1,6 +0,0 @@
-load(
-    "@com_googlesource_gerrit_bazlets//tools:classpath.bzl",
-    _classpath_collector = "classpath_collector",
-)
-
-classpath_collector = _classpath_collector
diff --git a/tools/bzl/junit.bzl b/tools/bzl/junit.bzl
deleted file mode 100644
index 97307bd..0000000
--- a/tools/bzl/junit.bzl
+++ /dev/null
@@ -1,6 +0,0 @@
-load(
-    "@com_googlesource_gerrit_bazlets//tools:junit.bzl",
-    _junit_tests = "junit_tests",
-)
-
-junit_tests = _junit_tests
diff --git a/tools/bzl/maven_jar.bzl b/tools/bzl/maven_jar.bzl
deleted file mode 100644
index ed1504d..0000000
--- a/tools/bzl/maven_jar.bzl
+++ /dev/null
@@ -1,4 +0,0 @@
-load("@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl", _gerrit = "GERRIT", _maven_jar = "maven_jar")
-
-maven_jar = _maven_jar
-GERRIT = _gerrit
diff --git a/tools/bzl/plugin.bzl b/tools/bzl/plugin.bzl
deleted file mode 100644
index 4d2dbdd..0000000
--- a/tools/bzl/plugin.bzl
+++ /dev/null
@@ -1,10 +0,0 @@
-load(
-    "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl",
-    _gerrit_plugin = "gerrit_plugin",
-    _plugin_deps = "PLUGIN_DEPS",
-    _plugin_test_deps = "PLUGIN_TEST_DEPS",
-)
-
-gerrit_plugin = _gerrit_plugin
-PLUGIN_DEPS = _plugin_deps
-PLUGIN_TEST_DEPS = _plugin_test_deps
diff --git a/tools/eclipse/BUILD b/tools/eclipse/BUILD
deleted file mode 100644
index 8811f30..0000000
--- a/tools/eclipse/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-load("//tools/bzl:plugin.bzl", "PLUGIN_DEPS")
-load("//tools/bzl:classpath.bzl", "classpath_collector")
-
-classpath_collector(
-    name = "main_classpath_collect",
-    deps = PLUGIN_DEPS + [
-        "//:remote-gerrit-account-cache__plugin",
-    ],
-)
diff --git a/tools/eclipse/project.sh b/tools/eclipse/project.sh
deleted file mode 100755
index 45bd4b1..0000000
--- a/tools/eclipse/project.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-# Copyright (C) 2023 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-`bazel query @com_googlesource_gerrit_bazlets//tools/eclipse:project --output location | sed s/BUILD:.*//`project.py -n remote-gerrit-account-cache -r .
diff --git a/tools/workspace_status.py b/tools/workspace_status.py
deleted file mode 100644
index 5c16612..0000000
--- a/tools/workspace_status.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env python3
-
-# This script will be run by bazel when the build process starts to
-# generate key-value information that represents the status of the
-# workspace. The output should be like
-#
-# KEY1 VALUE1
-# KEY2 VALUE2
-#
-# If the script exits with non-zero code, it's considered as a failure
-# and the output will be discarded.
-
-from __future__ import print_function
-import subprocess
-import sys
-
-CMD = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty']
-
-
-def revision():
-    try:
-        return subprocess.check_output(CMD).strip().decode("utf-8")
-    except OSError as err:
-        print('could not invoke git: %s' % err, file=sys.stderr)
-        sys.exit(1)
-    except subprocess.CalledProcessError as err:
-        print('error using git: %s' % err, file=sys.stderr)
-        sys.exit(1)
-
-
-print("STABLE_BUILD_REMOTE-GERRIT-ACCOUNT-CACHE_LABEL %s" % revision())