Implement standalone Buck build

Change-Id: Ib3297e520419f7cd23e6478c130d220913067be0
diff --git a/.buckconfig b/.buckconfig
new file mode 100644
index 0000000..5238f0d
--- /dev/null
+++ b/.buckconfig
@@ -0,0 +1,13 @@
+[alias]
+  rabbitmq = //:rabbitmq
+  plugin = //:rabbitmq
+
+[java]
+  src_roots = java, resources
+
+[project]
+  ignore = .git
+
+[cache]
+  mode = dir
+  dir = buck-out/cache
diff --git a/.gitignore b/.gitignore
index 4a97be9..73faeb9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,15 @@
 work/
+buck-out/
+bucklets
 build/
 bin/
 target/
+.buckd/
+.buckversion
 .classpath
 .checkstyle
 .project
 .settings/
 .idea/
+.watchmanconfig
 *.iml
diff --git a/BUCK b/BUCK
index 5fed6c6..8a40806 100644
--- a/BUCK
+++ b/BUCK
@@ -24,6 +24,11 @@
   ],
 )
 
+java_library(
+  name = 'classpath',
+  deps = [':rabbitmq__plugin'],
+)
+
 maven_jar(
   name = 'amqp-client',
   id = 'com.rabbitmq:amqp-client:3.5.1',
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..9fe2542
--- /dev/null
+++ b/VERSION
@@ -0,0 +1,4 @@
+# Used by BUCK to include "Implementation-Version" in plugin Manifest.
+# If this file doesn't exist the output of 'git describe' is used
+# instead.
+PLUGIN_VERSION = '2.10'
diff --git a/lib/BUCK b/lib/BUCK
new file mode 100644
index 0000000..06f7c02
--- /dev/null
+++ b/lib/BUCK
@@ -0,0 +1,8 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+maven_jar(
+  name = 'gson',
+  id = 'com.google.code.gson:gson:2.3.1',
+  sha1 = 'ecb6e1f8e4b0e84c4b886c2f14a1500caf309757',
+  license = 'Apache2.0',
+)
diff --git a/lib/commons/BUCK b/lib/commons/BUCK
new file mode 100644
index 0000000..7b7f70f
--- /dev/null
+++ b/lib/commons/BUCK
@@ -0,0 +1,24 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+maven_jar(
+  name = 'codec',
+  id = 'commons-codec:commons-codec:1.4',
+  sha1 = '4216af16d38465bbab0f3dff8efa14204f7a399a',
+  license = 'Apache2.0',
+  exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
+)
+
+maven_jar(
+  name = 'lang',
+  id = 'commons-lang:commons-lang:2.5',
+  sha1 = 'b0236b252e86419eef20c31a44579d2aee2f0a69',
+  license = 'Apache2.0',
+  exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
+)
+
+maven_jar(
+  name = 'io',
+  id = 'commons-io:commons-io:1.4',
+  sha1 = 'a8762d07e76cfde2395257a5da47ba7c1dbd3dce',
+  license = 'Apache2.0',
+)
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
new file mode 100644
index 0000000..465d5e5
--- /dev/null
+++ b/lib/gerrit/BUCK
@@ -0,0 +1,13 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+VER = '2.10.3.1'
+REPO = MAVEN_CENTRAL
+
+maven_jar(
+  name = 'plugin-api',
+  id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
+  sha1 = '9245110dfdcf275c36e45a0465cd5399dfc18540',
+  license = 'Apache2.0',
+  attach_source = False,
+  repository = REPO,
+)
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
new file mode 100644
index 0000000..38c3bb5
--- /dev/null
+++ b/src/main/resources/Documentation/build.md
@@ -0,0 +1,73 @@
+Build
+=====
+
+This plugin is built with Buck.
+
+Two build modes are supported: Standalone and in Gerrit tree. Standalone
+build mode is recommended, as this mode doesn't require local Gerrit
+tree to exist.
+
+Build standalone
+----------------
+
+Clone bucklets library:
+
+```
+  git clone https://gerrit.googlesource.com/bucklets
+
+```
+and link it to rabbitmq directory:
+
+```
+  cd rabbitmq && ln -s ../bucklets .
+```
+
+Add link to the .buckversion file:
+
+```
+  cd rabbitmq && ln -s bucklets/buckversion .buckversion
+```
+
+Add link to the .watchmanconfig file:
+
+```
+  cd rabbitmq && ln -s bucklets/watchmanconfig .watchmanconfig
+```
+
+To build the plugin, issue the following command:
+
+
+```
+  buck build plugin
+```
+
+The output is created in
+
+```
+  buck-out/gen/rabbitmq.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/rabbitmq
+```
+
+The output is created in
+
+```
+  buck-out/gen/plugins/rabbitmq/rabbitmq.jar
+```
+
+This project can be imported into the Eclipse IDE:
+
+```
+  ./tools/eclipse/project.py
+```
+
+How to build the Gerrit Plugin API is described in the [Gerrit
+documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files).