Buck: Add standalone build mode
diff --git a/.buckconfig b/.buckconfig
new file mode 100644
index 0000000..be09823
--- /dev/null
+++ b/.buckconfig
@@ -0,0 +1,13 @@
+[alias]
+  gerrit-oauth-provider = //:gerrit-oauth-provider
+  plugin = //:gerrit-oauth-provider
+
+[java]
+  src_roots = java, resources
+
+[project]
+  ignore = .git
+
+[cache]
+  mode = dir
+  dir = buck-out/cache
diff --git a/.buckversion b/.buckversion
new file mode 120000
index 0000000..6203e53
--- /dev/null
+++ b/.buckversion
@@ -0,0 +1 @@
+bucklets/buckversion
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..038506e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+/.buckd
+/buck-out
+/.classpath
+/.project
+/.settings/org.maven.ide.eclipse.prefs
+/.settings/org.eclipse.m2e.core.prefs
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..f088c56
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "bucklets"]
+	path = bucklets
+	url = https://github.com/davido/bucklets
diff --git a/.watchmanconfig b/.watchmanconfig
new file mode 120000
index 0000000..65be7a7
--- /dev/null
+++ b/.watchmanconfig
@@ -0,0 +1 @@
+bucklets/watchmanconfig
\ No newline at end of file
diff --git a/BUCK b/BUCK
index e90d89b..0b16609 100644
--- a/BUCK
+++ b/BUCK
@@ -1,5 +1,8 @@
-include_defs('//lib/maven.defs')
-define_license('scribe')
+include_defs('//bucklets/gerrit_plugin.bucklet')
+include_defs('//bucklets/maven_jar.bucklet')
+
+# TODO(davido): Uncomment when maven_jar.bucklet supports it
+#define_license('scribe')
 
 gerrit_plugin(
   name = 'gerrit-oauth-provider',
@@ -14,7 +17,7 @@
     '//lib:gson',
     '//lib/commons:codec',
   ],
-  deps = [':scribe-oauth'],
+  deps = [':scribe'],
 )
 
 java_library(
@@ -23,9 +26,11 @@
 )
 
 maven_jar(
-  name = 'scribe-oauth',
+  name = 'scribe',
   id = 'org.scribe:scribe:1.3.7',
   sha1 = '583921bed46635d9f529ef5f14f7c9e83367bc6e',
-  license = 'scribe',
-  local_license = True,
+  license = 'Apache2.0',
+#  license = 'scribe',
+#  local_license = True,
 )
+
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..8c9842a
--- /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 = '0.1'
diff --git a/bucklets b/bucklets
new file mode 160000
index 0000000..bdd7f97
--- /dev/null
+++ b/bucklets
@@ -0,0 +1 @@
+Subproject commit bdd7f97fd64a6bdcd6e42d677394f4f9b7cdb4dd
diff --git a/lib/BUCK b/lib/BUCK
new file mode 100644
index 0000000..ab803a7
--- /dev/null
+++ b/lib/BUCK
@@ -0,0 +1,15 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+maven_jar(
+  name = 'gson',
+  id = 'com.google.code.gson:gson:2.3.1',
+  sha1 = 'ecb6e1f8e4b0e84c4b886c2f14a1500caf309757',
+  license = 'Apache2.0',
+)
+
+maven_jar(
+  name = 'guava',
+  id = 'com.google.guava:guava:18.0',
+  sha1 = 'cce0823396aa693798f8882e64213b1772032b09',
+  license = 'Apache2.0',
+)
diff --git a/lib/commons/BUCK b/lib/commons/BUCK
new file mode 100644
index 0000000..7aafa82
--- /dev/null
+++ b/lib/commons/BUCK
@@ -0,0 +1,9 @@
+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'],
+)
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
new file mode 100644
index 0000000..e92eeb8
--- /dev/null
+++ b/lib/gerrit/BUCK
@@ -0,0 +1,13 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+VER = '2.10-SNAPSHOT'
+REPO = MAVEN_LOCAL
+
+maven_jar(
+  name = 'plugin-api',
+  id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
+  sha1 = '686c942bc41cd8f1c9adcdc54a94bcf3e862f4af',
+  license = 'Apache2.0',
+  attach_source = False,
+  repository = REPO,
+)
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index fbd7483..4c0fd4a 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -3,7 +3,24 @@
 
 This plugin is built with Buck.
 
-Only in Gerrit tree build mode is supported.
+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 in Standalone mode
+------------------------
+
+```
+  git clone --recursive https://github.com/davido/gerrit-oauth-provider
+  cd gerrit-oauth-provider
+  buck build plugin
+```
+
+The output is created in
+
+```
+  buck-out/gen/@PLUGIN@.jar
+```
 
 Build in Gerrit tree
 --------------------
@@ -18,7 +35,7 @@
 The output is created in
 
 ```
-  buck-out/gen/plugins/gerrit-oauth-provider/gerrit-oauth-provider.jar
+  buck-out/gen/plugins/@PLUGIN@/@PLUGIN@.jar
 ```
 
 This project can be imported into the Eclipse IDE: