Implement buck driven build

Bug: Issue 2684
Change-Id: Ib19a0748c214f55e51856590331b62c294c06872
diff --git a/BUCK b/BUCK
new file mode 100644
index 0000000..16ec787
--- /dev/null
+++ b/BUCK
@@ -0,0 +1,60 @@
+include_defs('//bucklets/gerrit_plugin.bucklet')
+
+DEPS = [
+  '//lib/commons:lang',
+  '//lib:guava',
+  '//lib/guice:guice',
+  '//lib/jgit:jgit',
+  '//lib/log:api',
+  '//lib:parboiled-core',
+  '//lib:velocity',
+]
+
+gerrit_plugin(
+  name = 'its-base',
+  srcs = glob(['src/main/java/**/*.java']),
+  provided_deps = DEPS,
+)
+
+TEST_UTIL_SRC = glob(['src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/**/*.java'])
+
+java_library(
+  name = 'its-base_tests-utils',
+  srcs = TEST_UTIL_SRC,
+  deps = DEPS + [
+    '//lib/easymock:easymock',
+    '//lib/log:impl_log4j',
+    '//lib/log:log4j',
+    '//lib:junit',
+    '//lib/powermock:powermock-api-easymock',
+    '//lib/powermock:powermock-api-support',
+    '//lib/powermock:powermock-core',
+    '//lib/powermock:powermock-module-junit4',
+    '//lib/powermock:powermock-module-junit4-common',
+  ],
+)
+
+java_test(
+  name = 'its-base_tests',
+  srcs = glob(
+    ['src/test/java/**/*.java'],
+    excludes = TEST_UTIL_SRC
+  ),
+  labels = ['its-base'],
+  source_under_test = [':its-base__plugin'],
+  deps = DEPS + [
+    ':its-base__plugin',
+    ':its-base_tests-utils',
+    '//gerrit-plugin-api:lib',
+    '//lib:gwtorm',
+    '//lib/easymock:easymock',
+    '//lib/log:impl_log4j',
+    '//lib/log:log4j',
+    '//lib:junit',
+    '//lib/powermock:powermock-api-easymock',
+    '//lib/powermock:powermock-api-support',
+    '//lib/powermock:powermock-core',
+    '//lib/powermock:powermock-module-junit4',
+    '//lib/powermock:powermock-module-junit4-common',
+  ],
+)
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
new file mode 100644
index 0000000..441519f
--- /dev/null
+++ b/src/main/resources/Documentation/build.md
@@ -0,0 +1,56 @@
+Build
+=====
+
+This base library for ITS-based plugins is built with Buck.
+
+Clone or link this plugin to the plugins directory of Gerrit's source
+tree, and issue the command:
+
+```
+  buck build plugins/its-base
+```
+
+The output is created in
+
+```
+  buck-out/gen/plugins/its-base/its-base.jar
+  buck-out/gen/plugins/its-base/lib__its-base__plugin__output/its-base__plugin.jar
+```
+
+This project can be imported into the Eclipse IDE:
+
+```
+  ./tools/eclipse/project.py
+```
+
+To execute the tests run:
+
+```
+  buck test --all --include its-base
+```
+
+Note that for compatibility reasons a Maven build is provided, but is
+considered to be deprecated and will be removed in a future version of
+this plugin.
+
+To build with Maven, change directory to the plugin folder and issue the
+command:
+
+```
+  mvn clean package
+```
+
+When building with Maven, the Gerrit Plugin API must be available.
+
+Note that the ITS-based plugins require `its-base__plugin` library:
+
+```
+[...]
+  deps = [
+    '//plugins/its-base:its-base__plugin',
+  ],
+[...]
+```
+
+How to build the Gerrit Plugin API is described in the [Gerrit
+documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files).