Add support for Bazel in Gerrit tree build
Change-Id: I2f7e5e394afaffe947531e67249d4961a3e5dd11
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..a28f52c
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,36 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load(
+ "//tools/bzl:plugin.bzl",
+ "gerrit_plugin",
+ "PLUGIN_DEPS",
+ "PLUGIN_TEST_DEPS",
+)
+
+gerrit_plugin(
+ name = "cfoauth",
+ srcs = glob(["src/main/java/**/*.java"]),
+ resources = glob(["src/main/resources/**/*"]),
+ manifest_entries = [
+ "Gerrit-PluginName: cfoauth",
+ "Gerrit-Module: com.googlesource.gerrit.plugins.cfoauth.OAuthModule",
+ "Gerrit-HttpModule: com.googlesource.gerrit.plugins.cfoauth.HttpModule",
+ "Gerrit-InitStep: com.googlesource.gerrit.plugins.cfoauth.InitOAuthConfig",
+ "Implementation-Title: Cloud Foundry UAA OAuth 2.0 Authentication Provider",
+ "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/cfoauth",
+ ],
+ deps = [
+ "@scribe//jar",
+ "@commons_codec//jar:neverlink",
+ ],
+)
+
+junit_tests(
+ name = "cfoauth_tests",
+ srcs = glob(["src/test/java/**/*.java"]),
+ tags = ["cfoauth"],
+ deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+ ":cfoauth__plugin",
+ "@scribe//jar",
+ "@commons_codec//jar",
+ ],
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..9ad5bf5
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,14 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+ maven_jar(
+ name = 'scribe',
+ artifact = 'org.scribe:scribe:1.3.7',
+ sha1 = '583921bed46635d9f529ef5f14f7c9e83367bc6e',
+ )
+
+ maven_jar(
+ name = 'commons_codec',
+ artifact = 'commons-codec:commons-codec:1.4',
+ sha1 = '4216af16d38465bbab0f3dff8efa14204f7a399a',
+ )
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index dd62be3..b9619e7 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,67 +1,55 @@
Build
=====
-This plugin can be built with Buck.
-Buck
-----
-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
-
-Clone bucklets library:
-
-```
- git clone https://gerrit.googlesource.com/bucklets
-```
-
-and link it to @PLUGIN@ plugin directory:
-
-```
- cd @PLUGIN@ && ln -s ../bucklets .
-```
-
-Add link to the .buckversion file:
-
-```
- cd @PLUGIN@ && ln -s bucklets/buckversion .buckversion
-```
-
-Add link to the .watchmanconfig file:
-
-```
- cd @PLUGIN@ && ln -s bucklets/watchmanconfig .watchmanconfig
-```
-
-To build the plugin, issue the following command:
-
-```
- buck build plugin
-```
-
-The output is created in
-
-```
- buck-out/gen/@PLUGIN@.jar
-```
-
-### Build in Gerrit tree
+This plugin is built using Bazel.
+Only the Gerrit in-tree build is supported.
Clone or link this plugin to the plugins directory of Gerrit's source
-tree, and issue the command:
+tree.
```
- buck build plugins/@PLUGIN@
+ git clone https://gerrit.googlesource.com/gerrit
+ git clone https://gerrit.googlesource.com/plugins/@PLUGIN@
+ cd gerrit/plugins
+ ln -s ../../@PLUGIN@ .
+```
+
+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 .
+```
+
+From Gerrit source tree issue the command:
+
+```
+ bazel build plugins/@PLUGIN@
```
The output is created in
```
- buck-out/gen/plugins/@PLUGIN@/@PLUGIN@.jar
+ bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar
```
-This project can be imported into the Eclipse IDE:
+To execute the tests run:
+
+```
+ bazel test plugins/@PLUGIN@:@PLUGIN@_tests
+```
+
+or filtering using the comma separated tags:
+
+````
+ bazel test --test_tag_filters=@PLUGIN@ //...
+````
+
+This project can be imported into the Eclipse IDE.
+Add the plugin name to the `CUSTOM_PLUGINS` set in
+Gerrit core in `tools/bzl/plugins.bzl`, and execute:
```
./tools/eclipse/project.py