Port build to Bazel.

Stop calling unregisterWorkqueue which was removed in gerrit

Change-Id: I24cccd171de6c396baebde3d580c2070f0069565
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..687c601
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,21 @@
+load("//tools/bzl:plugin.bzl", "gerrit_plugin")
+
+gerrit_plugin(
+    name = "repository-usage",
+    srcs = glob(["src/main/java/**/*.java"]),
+    manifest_entries = [
+        "Gerrit-PluginName: repository-usage",
+        "Gerrit-Module: com.googlesource.gerrit.plugins.repositoryuse.SuperManifestModule",
+        "Gerrit-SshModule: com.googlesource.gerrit.plugins.repositoryuse.SshModule",
+    ],
+    provided_deps = [
+        "//lib/commons:dbcp",
+        "//lib:gson",
+    ],
+    resources = glob(["src/main/**/*"]),
+    deps = [
+        "@beanutils//jar",
+        "@digester3//jar",
+        "@logging//jar",
+    ],
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..6c10baf
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,22 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar", "GERRIT", "MAVEN_CENTRAL")
+
+def external_plugin_deps():
+  maven_jar(
+    name = 'digester3',
+    artifact = 'org.apache.commons:commons-digester3:3.2',
+    sha1 = 'c3f68c5ff25ec5204470fd8fdf4cb8feff5e8a79',
+    exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
+  )
+
+  maven_jar(
+    name = 'beanutils',
+    artifact = 'commons-beanutils:commons-beanutils:1.8.3',
+    sha1 = '686ef3410bcf4ab8ce7fd0b899e832aaba5facf7',
+    exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
+  )
+
+  maven_jar(
+    name = 'logging',
+    artifact = 'commons-logging:commons-logging:1.1.1',
+    sha1 = '5043bfebc3db072ed80fbd362e7caf00e885d8ae',
+  )
diff --git a/src/main/java/com/googlesource/gerrit/plugins/repositoryuse/Module.java b/src/main/java/com/googlesource/gerrit/plugins/repositoryuse/Module.java
index 1ca0697..70ee3f7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/repositoryuse/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/repositoryuse/Module.java
@@ -24,6 +24,7 @@
 import com.google.inject.assistedinject.FactoryModuleBuilder;
 import com.google.inject.internal.UniqueAnnotations;
 
+import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 
 public class Module extends AbstractModule {
@@ -55,7 +56,7 @@
 
   @Provides
   @ScanningPool
-  ScheduledThreadPoolExecutor provideScanningPool(ScanningQueue queue) {
+  ScheduledExecutorService provideScanningPool(ScanningQueue queue) {
     return queue.getPool();
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/repositoryuse/ScanningQueue.java b/src/main/java/com/googlesource/gerrit/plugins/repositoryuse/ScanningQueue.java
index 8cbc3bd..0652a90 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/repositoryuse/ScanningQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/repositoryuse/ScanningQueue.java
@@ -18,11 +18,12 @@
 import com.google.gerrit.server.git.WorkQueue;
 import com.google.inject.Inject;
 
+import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 
 public class ScanningQueue implements LifecycleListener {
   private final WorkQueue queue;
-  private WorkQueue.Executor threadPool;
+  private ScheduledExecutorService threadPool;
 
   @Inject
   public ScanningQueue(WorkQueue queue) {
@@ -36,14 +37,11 @@
 
   @Override
   public void stop() {
-    if (threadPool != null) {
-      threadPool.unregisterWorkQueue();
-      threadPool = null;
-    }
+    threadPool = null;
   }
 
-  public ScheduledThreadPoolExecutor getPool() {
+  public ScheduledExecutorService getPool() {
     return threadPool;
-  }
+   }
 
 }