Remove standalone build mode

Since I16370e57f2 JGit is consumed as a submodule in Gerrit core. This
makes it easier to upgrade JGit in gerrit core, which means it can be
any arbitrary revision that doesn't have corresponding artifacts
available for download from a maven repository (unless they are manually
built and deployed by someone).

Change-Id: I1232264584173c9a1e2c7312d75be009c830d6ee
diff --git a/.bazelrc b/.bazelrc
deleted file mode 100644
index 6e4e0ba..0000000
--- a/.bazelrc
+++ /dev/null
@@ -1,3 +0,0 @@
-build --workspace_status_command="python ./tools/workspace_status.py"
-test --build_tests_only
-
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index a4ec9de..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-/.classpath
-/.project
-/.settings
-/bazel-bin
-/bazel-out
-/bazel-lfs
-/bazel-testlogs
-/eclipse-out
diff --git a/BUILD b/BUILD
index 81ab40d..d00bb76 100644
--- a/BUILD
+++ b/BUILD
@@ -7,9 +7,30 @@
     "gerrit_plugin",
 )
 
+LFS_DEPS = [
+    "@jgit//org.eclipse.jgit.lfs.server:jgit-lfs-server",
+    "@jgit//org.eclipse.jgit.lfs:jgit-lfs",
+]
+
+DEPLOY_ENV = [
+    "//lib:gson",
+    "//lib/httpcomponents:httpclient",
+    "//lib:jgit",
+    "//lib:servlet-api-without-neverlink",
+]
+
+# TODO(davido): Remove this workaround, when provided_deps attribute is added:
+# https://github.com/bazelbuild/bazel/issues/1402
+java_binary(
+    name = "gerrit_core_provided_env",
+    main_class = "Dummy",
+    runtime_deps = DEPLOY_ENV,
+)
+
 gerrit_plugin(
     name = "lfs",
     srcs = glob(["src/main/java/**/*.java"]),
+    deploy_env = ["gerrit_core_provided_env"],
     manifest_entries = [
         "Gerrit-PluginName: lfs",
         "Gerrit-Module: com.googlesource.gerrit.plugins.lfs.Module",
@@ -18,11 +39,7 @@
         "Gerrit-InitStep: com.googlesource.gerrit.plugins.lfs.InitLfs",
     ],
     resources = glob(["src/main/resources/**/*"]),
-    deps = [
-        "@jgit-http-apache//jar",
-        "@jgit-lfs-server//jar",
-        "@jgit-lfs//jar",
-    ],
+    deps = LFS_DEPS,
 )
 
 junit_tests(
@@ -38,8 +55,7 @@
     name = "lfs__plugin_test_deps",
     testonly = 1,
     visibility = ["//visibility:public"],
-    exports = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+    exports = PLUGIN_DEPS + PLUGIN_TEST_DEPS + LFS_DEPS + [
         ":lfs__plugin",
-        "@jgit-lfs//jar",
     ],
 )
diff --git a/WORKSPACE b/WORKSPACE
deleted file mode 100644
index 0a0d42d..0000000
--- a/WORKSPACE
+++ /dev/null
@@ -1,19 +0,0 @@
-workspace(name = "lfs")
-
-load("//:bazlets.bzl", "load_bazlets")
-
-load_bazlets(
-    commit = "56aafc4c0bb1b72fba34f5bdfb29ddb1e1a17801",
-    #local_path = "/home/<user>/projects/bazlets",
-)
-
-load(
-    "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
-    "gerrit_api",
-)
-
-gerrit_api()
-
-load(":external_plugin_deps.bzl", "external_plugin_deps")
-
-external_plugin_deps()
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
deleted file mode 100644
index 881a048..0000000
--- a/external_plugin_deps.bzl
+++ /dev/null
@@ -1,38 +0,0 @@
-load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_CENTRAL", "MAVEN_LOCAL", "maven_jar")
-
-JGIT_VERSION = "5.5.1.201910021850-r"
-REPO = MAVEN_CENTRAL
-
-def external_plugin_deps():
-    maven_jar(
-        name = "jgit-http-apache",
-        artifact = "org.eclipse.jgit:org.eclipse.jgit.http.apache:" + JGIT_VERSION,
-        sha1 = "aaf5367ff2cba4174b4165ed0a64dc92cac75871",
-        repository = REPO,
-        exclude = [
-            "about.html",
-            "plugin.properties",
-        ],
-    )
-
-    maven_jar(
-        name = "jgit-lfs",
-        artifact = "org.eclipse.jgit:org.eclipse.jgit.lfs:" + JGIT_VERSION,
-        sha1 = "c37af6b2d28df21942e935753922333c8612cef2",
-        repository = REPO,
-        exclude = [
-            "about.html",
-            "plugin.properties",
-        ],
-    )
-
-    maven_jar(
-        name = "jgit-lfs-server",
-        artifact = "org.eclipse.jgit:org.eclipse.jgit.lfs.server:" + JGIT_VERSION,
-        sha1 = "7df786dfb9843a01e46cbf48ef921c5aac087ca1",
-        repository = REPO,
-        exclude = [
-            "about.html",
-            "plugin.properties",
-        ],
-    )
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 5bd6251..630b0d6 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -3,48 +3,7 @@
 
 This @PLUGIN@ plugin is built with Bazel.
 
-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
-
-```
-  bazel build @PLUGIN@
-```
-
-The output is created in
-
-```
-  bazel-bin/@PLUGIN@.jar
-```
-
-To execute the tests run:
-
-```
-  bazel test //...
-```
-
-This project can be imported into the Eclipse IDE. Execute:
-
-```
-  ./tools/eclipse/project.sh
-```
-
-to generate the required files and then import the project.
-
-### Build in Gerrit tree
-
-Put the external dependency Bazel build file into the Gerrit /plugins directory,
-replacing the existing empty one.
-
-```
-  cd gerrit/plugins
-  rm external_plugin_deps.bzl
-  ln -s @PLUGIN@/external_plugin_deps.bzl .
-```
-
-Then issue
+Link the plugin directory in plugins directory in Gerrit core and run
 
 ```
   bazel build plugins/@PLUGIN@
@@ -76,4 +35,4 @@
 
 [Back to @PLUGIN@ documentation index][index]
 
-[index]: index.html
\ No newline at end of file
+[index]: index.html
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 c5ed0b7..0000000
--- a/tools/bzl/BUILD
+++ /dev/null
@@ -1 +0,0 @@
-# Empty file required by Bazel
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 fb20419..0000000
--- a/tools/bzl/maven_jar.bzl
+++ /dev/null
@@ -1,12 +0,0 @@
-load(
-    "@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl",
-    _gerrit = "GERRIT",
-    _maven_central = "MAVEN_CENTRAL",
-    _maven_jar = "maven_jar",
-    _maven_local = "MAVEN_LOCAL",
-)
-
-GERRIT = _gerrit
-MAVEN_CENTRAL = _maven_central
-MAVEN_LOCAL = _maven_local
-maven_jar = _maven_jar
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 56fe7de..0000000
--- a/tools/eclipse/BUILD
+++ /dev/null
@@ -1,9 +0,0 @@
-load("//tools/bzl:classpath.bzl", "classpath_collector")
-
-classpath_collector(
-    name = "main_classpath_collect",
-    testonly = 1,
-    deps = [
-        "//:lfs__plugin_test_deps",
-    ],
-)
diff --git a/tools/eclipse/project.sh b/tools/eclipse/project.sh
deleted file mode 100755
index 2e79913..0000000
--- a/tools/eclipse/project.sh
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-# Copyright (C) 2017 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 lfs -r .
diff --git a/tools/workspace_status.py b/tools/workspace_status.py
deleted file mode 100644
index fbb98ef..0000000
--- a/tools/workspace_status.py
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env python
-
-# 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_LFS_LABEL %s" % revision())