Add support for standalone Buck build

Change-Id: I5a334cbe35669eab9b866a1f603f7ce282df2c52
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
diff --git a/.buckconfig b/.buckconfig
new file mode 100644
index 0000000..3addd70
--- /dev/null
+++ b/.buckconfig
@@ -0,0 +1,14 @@
+[alias]
+  reviewers-by-blame = //:reviewers-by-blame
+  plugin = //:reviewers-by-blame
+
+[java]
+  src_roots = java, resources
+
+[project]
+  ignore = .git
+
+[cache]
+  mode = dir
+  dir = buck-out/cache
+
diff --git a/.gitignore b/.gitignore
index 194bedc..b4277e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,10 @@
+/.buckversion
+/.buckd
+/.watchmanconfig
+/buck-out
+/bucklets
 /target
 /.classpath
 /.project
 /.settings/org.maven.ide.eclipse.prefs
-/.settings/org.eclipse.m2e.core.prefs
\ No newline at end of file
+/.settings/org.eclipse.m2e.core.prefs
diff --git a/BUCK b/BUCK
index af807f2..c422070 100644
--- a/BUCK
+++ b/BUCK
@@ -1,3 +1,5 @@
+include_defs('//bucklets/gerrit_plugin.bucklet')
+
 gerrit_plugin(
   name = 'reviewers-by-blame',
   srcs = glob(['src/main/java/**/*.java']),
@@ -6,6 +8,8 @@
     'Implementation-Title: Reviewers By Blame',
     'Implementation-URL: https://gerrit.googlesource.com/plugins/reviewers-by-blame',
     'Gerrit-PluginName: reviewers-by-blame',
+    'Gerrit-ApiType: plugin',
+    'Gerrit-ApiVersion: 2.11',
     'Gerrit-Module: com.googlesource.gerrit.plugins.reviewersbyblame.ReviewersByBlameModule',
   ],
 )
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
new file mode 100644
index 0000000..31c52aa
--- /dev/null
+++ b/lib/gerrit/BUCK
@@ -0,0 +1,12 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+VER = '2.11'
+REPO = MAVEN_CENTRAL
+
+maven_jar(
+  name = 'plugin-api',
+  id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
+  attach_source = False,
+  repository = REPO,
+  license = 'Apache2.0',
+)
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 6763a3a..fb9dc40 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -3,17 +3,64 @@
 
 This plugin is built with Buck.
 
-Clone or link this plugin to the plugins directory of Gerrit's source
-tree, and issue the command:
+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:
 
 ```
-  buck build plugins/reviewers-by-blame
+  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/plugins/reviewers-by-blame/reviewers-by-blame.jar
+  buck-out/gen/@PLUGIN@.jar
+```
+
+### Build in Gerrit tree
+
+Clone or link this plugin to the plugins directory of Gerrit's source
+tree, and issue the command:
+
+```
+  buck build plugins/@PLUGIN@
+```
+
+The output is created in
+
+```
+  buck-out/gen/plugins/@PLUGIN@/@PLUGIN@.jar
 ```
 
 This project can be imported into the Eclipse IDE: