Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  Remove duplication of sha1 values; reuse arguments
  Unwrap `load` lines in README.md
  Allow plugins to override default API versions
  Dedupe gerrit_api and gerrit_api_maven_local
  Switch examples from GitHub to Gerrit Review
  Clarify that one needs to call gerrit_api in the README.md
  Re-format example directory tree in README.md

Update the gerrit_api README example so it fits with this target branch.

Change-Id: I9dac03faf80e3bb52ba416843cddb6a057f3fcc6
diff --git a/README.md b/README.md
index 2d2d339..725a35d 100644
--- a/README.md
+++ b/README.md
@@ -22,22 +22,32 @@
 
 ```python
 git_repository(
-  name = "com_github_davido_bazlets",
-  remote = "https://github.com/davido/bazlets.git",
-  commit = "2ede19cb2d2dd9d04bcb70ffc896439a27e5d50d",
+  name = "com_googlesource_gerrit_bazlets",
+  remote = "https://gerrit.googlesource.com/bazlets",
+  commit = "928c928345646ae958b946e9bbdb462f58dd1384",
 )
-load("@com_github_davido_bazlets//:gerrit_api.bzl",
-     "gerrit_api")
+load("@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", "gerrit_api")
+gerrit_api()
 ```
 
-Another option is to consume snapshot version of gerrit plugin API from local
-Maven repository (`~/.m2`). To use the snapshot version special method is
-provided:
+The `version` parameter allows to override the default API. For release version
+numbers, make sure to also provide artifacts' SHA1 sums via the
+`plugin_api_sha1` and `acceptance_framework_sha1` parameters:
 
 ```python
-load("@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
-     "gerrit_api_maven_local")
-gerrit_api_maven_local()
+load("@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", "gerrit_api")
+gerrit_api(version = "3.1.6",
+           plugin_api_sha1 = "e57f6465c9805f568082bffffd61a2771f10d68a",
+           acceptance_framework_sha1 = "ebfd50383f8593678b451c81dbc332db8e8da188")
+```
+
+If the version ends in `-SNAPSHOT`, the jars are consumed from the local
+Maven repository (`~/.m2`) per default assumed to be and the SHA1 sums can be
+omitted:
+
+```python
+load("@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", "gerrit_api")
+gerrit_api(version = "3.1.7-SNAPSHOT")
 ```
 
 <a name="basic-example"></a>
@@ -47,11 +57,12 @@
 
 ```
 [workspace]/
-    WORKSPACE
-	BUILD
-    src/main/java/
-	src/main/resources/
-	[...]
+├── src
+│   └── main
+│       ├── java
+│       └── resources
+├── BUILD
+└── WORKSPACE
 ```
 
 To build this plugin, your `BUILD` can look like this:
diff --git a/gerrit_api.bzl b/gerrit_api.bzl
index 4a08627..332a493 100644
--- a/gerrit_api.bzl
+++ b/gerrit_api.bzl
@@ -1,32 +1,36 @@
 load("//:bouncycastle.bzl", "bouncycastle_repos")
 load("//:gerrit_api_version.bzl", "gerrit_api_version")
 load("//:rules_python.bzl", "rules_python_repos")
-load("//tools:maven_jar.bzl", "maven_jar")
+load("//tools:maven_jar.bzl", "MAVEN_LOCAL", "MAVEN_CENTRAL", "maven_jar")
 
 """Bazel rule for building [Gerrit Code Review](https://www.gerritcodereview.com/)
 gerrit_api is rule for fetching Gerrit plugin API using Bazel.
 """
 
-VER = "3.1.6"
-
-def gerrit_api():
+def gerrit_api(version = "3.1.6",
+               plugin_api_sha1 = "e57f6465c9805f568082bffffd61a2771f10d68a",
+               acceptance_framework_sha1 = "ebfd50383f8593678b451c81dbc332db8e8da188"):
     gerrit_api_version(
         name = "gerrit_api_version",
-        version = VER,
+        version = version,
     )
 
     bouncycastle_repos()
     rules_python_repos()
 
+    local_repository = version.endswith("-SNAPSHOT")
+
     maven_jar(
         name = "gerrit_plugin_api",
-        artifact = "com.google.gerrit:gerrit-plugin-api:" + VER,
-        sha1 = "e57f6465c9805f568082bffffd61a2771f10d68a",
+        artifact = "com.google.gerrit:gerrit-plugin-api:" + version,
+        sha1 = "" if local_repository else plugin_api_sha1,
+        repository = MAVEN_LOCAL if local_repository else MAVEN_CENTRAL,
     )
     maven_jar(
         name = "gerrit_acceptance_framework",
-        artifact = "com.google.gerrit:gerrit-acceptance-framework:" + VER,
-        sha1 = "ebfd50383f8593678b451c81dbc332db8e8da188",
+        artifact = "com.google.gerrit:gerrit-acceptance-framework:" + version,
+        sha1 = "" if local_repository else acceptance_framework_sha1,
+        repository = MAVEN_LOCAL if local_repository else MAVEN_CENTRAL,
     )
     native.bind(
         name = "gerrit-plugin-api",
diff --git a/gerrit_api_maven_local.bzl b/gerrit_api_maven_local.bzl
deleted file mode 100644
index 7e9817b..0000000
--- a/gerrit_api_maven_local.bzl
+++ /dev/null
@@ -1,46 +0,0 @@
-load("//:bouncycastle.bzl", "bouncycastle_repos")
-load("//:gerrit_api_version.bzl", "gerrit_api_version")
-load("//:rules_python.bzl", "rules_python_repos")
-load("//tools:maven_jar.bzl", "MAVEN_LOCAL", "maven_jar")
-
-"""Bazel rule for building [Gerrit Code Review](https://www.gerritcodereview.com/)
-gerrit_api is rule for fetching Gerrit plugin API using Bazel.
-"""
-
-VER = "3.1.7-SNAPSHOT"
-
-def gerrit_api_maven_local():
-    gerrit_api_version(
-        name = "gerrit_api_version",
-        version = VER,
-    )
-
-    bouncycastle_repos()
-    rules_python_repos()
-
-    maven_jar(
-        name = "gerrit_plugin_api",
-        artifact = "com.google.gerrit:gerrit-plugin-api:" + VER,
-        repository = MAVEN_LOCAL,
-    )
-    maven_jar(
-        name = "gerrit_acceptance_framework",
-        artifact = "com.google.gerrit:gerrit-acceptance-framework:" + VER,
-        repository = MAVEN_LOCAL,
-    )
-    native.bind(
-        name = "gerrit-plugin-api",
-        actual = "@gerrit_plugin_api//jar",
-    )
-    native.bind(
-        name = "gerrit-acceptance-framework",
-        actual = "@gerrit_acceptance_framework//jar",
-    )
-    native.bind(
-        name = "gerrit-plugin-api-neverlink",
-        actual = "@gerrit_plugin_api//jar:neverlink",
-    )
-    native.bind(
-        name = "gerrit-acceptance-framework-neverlink",
-        actual = "@gerrit_acceptance_framework//jar:neverlink",
-    )