Merge "Fix Buck build"
diff --git a/.buckconfig b/.buckconfig
new file mode 100644
index 0000000..109254c
--- /dev/null
+++ b/.buckconfig
@@ -0,0 +1,14 @@
+[alias]
+  imagare = //:imagare
+  plugin = //:imagare
+
+[java]
+  src_roots = java, resources
+
+[project]
+  ignore = .git
+
+[cache]
+  mode = dir
+  dir = buck-out/cache
+
diff --git a/.gitignore b/.gitignore
index 80d6257..b4277e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,8 @@
+/.buckversion
+/.buckd
+/.watchmanconfig
+/buck-out
+/bucklets
 /target
 /.classpath
 /.project
diff --git a/BUCK b/BUCK
index 29f882f..1ae337b 100644
--- a/BUCK
+++ b/BUCK
@@ -1,10 +1,23 @@
+include_defs('//bucklets/gerrit_plugin.bucklet')
+
+MODULE = 'com.googlesource.gerrit.plugins.imagare.Imagare'
+
 gerrit_plugin(
   name = 'imagare',
   srcs = glob(['src/main/java/**/*.java']),
-  resources = glob(['src/main/resources/**/*']),
+  resources = glob(['src/main/**/*']),
+  gwt_module = MODULE,
   manifest_entries = [
     'Gerrit-PluginName: imagare',
     'Gerrit-Module: com.googlesource.gerrit.plugins.imagare.Module',
-    'Gerrit-Module: com.googlesource.gerrit.plugins.imagare.HttpModule',
+    'Gerrit-HttpModule: com.googlesource.gerrit.plugins.imagare.HttpModule',
   ]
 )
+
+java_library(
+  name = 'classpath',
+  deps = GERRIT_GWT_API + GERRIT_PLUGIN_API + [
+    ':imagare__plugin',
+    '//lib/gwt:user',
+  ],
+)
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
new file mode 100644
index 0000000..38948b7
--- /dev/null
+++ b/lib/gerrit/BUCK
@@ -0,0 +1,22 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+VER = '2.12-rc0'
+REPO = MAVEN_CENTRAL
+
+maven_jar(
+  name = 'plugin-api',
+  id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
+  sha1 = '8fd408e0eedc5e891ac779ab26491fb377800e74',
+  license = 'Apache2.0',
+  attach_source = False,
+  repository = REPO,
+)
+
+maven_jar(
+  name = 'gwtui-api',
+  id = 'com.google.gerrit:gerrit-plugin-gwtui:' + VER,
+  sha1 = 'b2df95ec5181a64ee03bf9caaa73381a7c11fc88',
+  license = 'Apache2.0',
+  attach_source = False,
+  repository = REPO,
+)
diff --git a/lib/gwt/BUCK b/lib/gwt/BUCK
new file mode 100644
index 0000000..b8d9491
--- /dev/null
+++ b/lib/gwt/BUCK
@@ -0,0 +1,34 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+VERSION = '2.7.0'
+
+maven_jar(
+  name = 'user',
+  id = 'com.google.gwt:gwt-user:' + VERSION,
+  sha1 = 'bdc7af42581745d3d79c2efe0b514f432b998a5b',
+  license = 'Apache2.0',
+  attach_source = False,
+)
+
+maven_jar(
+  name = 'dev',
+  id = 'com.google.gwt:gwt-dev:' + VERSION,
+  sha1 = 'c2c3dd5baf648a0bb199047a818be5e560f48982',
+  license = 'Apache2.0',
+  deps = [
+    ':javax-validation',
+    ':javax-validation_src',
+  ],
+  attach_source = False,
+  exclude = ['org/eclipse/jetty/*'],
+)
+
+maven_jar(
+  name = 'javax-validation',
+  id = 'javax.validation:validation-api:1.0.0.GA',
+  bin_sha1 = 'b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e',
+  src_sha1 = '7a561191db2203550fbfa40d534d4997624cd369',
+  license = 'Apache2.0',
+  visibility = [],
+)
+
diff --git a/lib/ow2/BUCK b/lib/ow2/BUCK
new file mode 100644
index 0000000..db6c76c
--- /dev/null
+++ b/lib/ow2/BUCK
@@ -0,0 +1,32 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+VERSION = '5.0.3'
+
+maven_jar(
+  name = 'ow2-asm',
+  id = 'org.ow2.asm:asm:' + VERSION,
+  sha1 = 'dcc2193db20e19e1feca8b1240dbbc4e190824fa',
+  license = 'ow2',
+)
+
+maven_jar(
+  name = 'ow2-asm-analysis',
+  id = 'org.ow2.asm:asm-analysis:' + VERSION,
+  sha1 = 'c7126aded0e8e13fed5f913559a0dd7b770a10f3',
+  license = 'ow2',
+)
+
+maven_jar(
+  name = 'ow2-asm-tree',
+  id = 'org.ow2.asm:asm-tree:' + VERSION,
+  sha1 = '287749b48ba7162fb67c93a026d690b29f410bed',
+  license = 'ow2',
+)
+
+maven_jar(
+  name = 'ow2-asm-util',
+  id = 'org.ow2.asm:asm-util:' + VERSION,
+  sha1 = '1512e5571325854b05fb1efce1db75fcced54389',
+  license = 'ow2',
+)
+
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 1ff454f..7aee3fd 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,7 +1,51 @@
 Build
 =====
 
-This plugin is built with Buck.
+This plugin can be built with Buck or Maven.
+
+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 reviewers plugin directory:
+
+```
+  cd reviewers && ln -s ../bucklets .
+```
+
+Add link to the .buckversion file:
+
+```
+  cd reviewers && ln -s bucklets/buckversion .buckversion
+```
+
+To build the plugin, issue the following command:
+
+
+```
+  buck build plugin
+```
+
+The output is created in
+
+```
+  buck-out/gen/imagare.jar
+```
+
+### Build in Gerrit tree
+
 Clone or link this plugin to the plugins directory of Gerrit tree
 and issue the command:
 
@@ -21,14 +65,21 @@
   ./tools/eclipse/project.py
 ```
 
-Note for compatibility reasons Maven build is provided, but it considered to
-be deprecated and is going to be removed in one of the future versions of this
-plugin.
+Maven
+-----
+
+Note that the Maven build is provided for compatibility reasons, but
+it is considered to be deprecated and will be removed in a future
+version of this plugin.
+
+To build with Maven, run
 
 ```
   mvn clean package
 ```
 
 When building with Maven, the Gerrit Plugin API must be available.
+
 How to build the Gerrit Plugin API is described in the [Gerrit
 documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files).
+