Allow plugins to override default API versions
Thereby, one no longer needs to have a local bazlet checkout and adjust
versions there when using snapshot API in a given version. This can now
all be done in the plugin alone using a public bazlet version.
Change-Id: I679c867008728181e32502e95caa144cdba73581
diff --git a/README.md b/README.md
index 22ea51a..ae0b14a 100644
--- a/README.md
+++ b/README.md
@@ -31,14 +31,26 @@
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.bzl",
"gerrit_api")
-gerrit_api(local_repository = True)
+gerrit_api(version = "3.0.9",
+ plugin_api_sha1 = "dbcadf2c198b1ee1b74678855e8e10b2c403de1f",
+ acceptance_framework_sha1 = "799cb104f2c0de4394528e38ad487557dd69bb49")
+```
+
+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.0.10-SNAPSHOT")
```
<a name="basic-example"></a>
diff --git a/gerrit_api.bzl b/gerrit_api.bzl
index 1efeb91..c9e64a2 100644
--- a/gerrit_api.bzl
+++ b/gerrit_api.bzl
@@ -7,26 +7,28 @@
gerrit_api is rule for fetching Gerrit plugin API using Bazel.
"""
-VER = "3.0.10"
-
-def gerrit_api(local_repository = False):
+def gerrit_api(version = "3.0.10",
+ plugin_api_sha1 = "90df648d9ef9e1a953e253972d9922fc1b753f83",
+ acceptance_framework_sha1 = "9c30ee281fa9016d460d16dd08a87ef16cedbf84"):
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,
+ artifact = "com.google.gerrit:gerrit-plugin-api:" + version,
sha1 = "" if local_repository else "90df648d9ef9e1a953e253972d9922fc1b753f83",
repository = MAVEN_LOCAL if local_repository else MAVEN_CENTRAL,
)
maven_jar(
name = "gerrit_acceptance_framework",
- artifact = "com.google.gerrit:gerrit-acceptance-framework:" + VER,
+ artifact = "com.google.gerrit:gerrit-acceptance-framework:" + version,
sha1 = "" if local_repository else "9c30ee281fa9016d460d16dd08a87ef16cedbf84",
repository = MAVEN_LOCAL if local_repository else MAVEN_CENTRAL,
)