Merge branch 'stable-2.11' into master
* origin/stable-2.11:
Fix buck test in standalone BUCK build
Add standalone BUCK build
Change-Id: Id849e37156268a04f125bff3b59c804427bbaa04
diff --git a/.buckconfig b/.buckconfig
new file mode 100644
index 0000000..c897236
--- /dev/null
+++ b/.buckconfig
@@ -0,0 +1,13 @@
+[alias]
+ ref-protection = //:ref-protection
+ plugin = //:ref-protection
+
+[java]
+ src_roots = java, resources
+
+[project]
+ ignore = .git
+
+[cache]
+ mode = dir
+ dir = buck-out/cache
diff --git a/.gitignore b/.gitignore
index 68892bf..cedbcae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,11 @@
-/target
-/.classpath
-/.project
-/.settings/org.maven.ide.eclipse.prefs
-/.settings/org.eclipse.m2e.core.prefs
-/.idea
+buck-out/
+bucklets
+target/
+.buckd/
+.buckversion
+.classpath
+.project
+.settings/org.maven.ide.eclipse.prefs
+.settings/org.eclipse.m2e.core.prefs
+.idea
+.watchmanconfig
diff --git a/BUCK b/BUCK
index 367d677..17cda8a 100644
--- a/BUCK
+++ b/BUCK
@@ -1,3 +1,17 @@
+include_defs('//bucklets/gerrit_plugin.bucklet')
+
+if STANDALONE_MODE:
+ TEST_DEPS = GERRIT_PLUGIN_API
+else:
+ TEST_DEPS = [
+ '//gerrit-common:server',
+ '//gerrit-reviewdb:server',
+ '//gerrit-server:server',
+ '//lib/jgit:jgit',
+ '//lib:guava',
+ '//lib:gwtorm',
+ ]
+
gerrit_plugin(
name = 'ref-protection',
srcs = glob(['src/main/java/**/*.java']),
@@ -10,18 +24,18 @@
],
)
+java_library(
+ name = 'classpath',
+ deps = [':ref-protection__plugin'],
+)
+
java_test(
name = 'ref-protection_tests',
srcs = glob(['src/test/java/**/*.java']),
- deps = [
+ labels = ['ref-protection'],
+ deps = TEST_DEPS + [
':ref-protection__plugin',
- '//gerrit-common:server',
- '//gerrit-reviewdb:server',
- '//gerrit-server:server',
- '//lib:guava',
- '//lib:gwtorm',
'//lib:junit',
'//lib:truth',
- '//lib/jgit:jgit',
],
)
diff --git a/lib/BUCK b/lib/BUCK
new file mode 100644
index 0000000..f501067
--- /dev/null
+++ b/lib/BUCK
@@ -0,0 +1,27 @@
+include_defs('//bucklets/maven_jar.bucklet')
+
+maven_jar(
+ name = 'junit',
+ id = 'junit:junit:4.10',
+ sha1 = 'e4f1766ce7404a08f45d859fb9c226fc9e41a861',
+ license = 'DO_NOT_DISTRIBUTE',
+ deps = [':hamcrest-core'],
+)
+
+maven_jar(
+ name = 'hamcrest-core',
+ id = 'org.hamcrest:hamcrest-core:1.3',
+ sha1 = '42a25dc3219429f0e5d060061f71acb49bf010a0',
+ license = 'DO_NOT_DISTRIBUTE',
+ visibility = ['//lib:junit'],
+)
+
+maven_jar(
+ name = 'truth',
+ id = 'com.google.truth:truth:0.26',
+ sha1 = 'b5802815625d82f39c33219299771f3d64301b06',
+ license = 'DO_NOT_DISTRIBUTE',
+ deps = [
+ ':junit',
+ ],
+)
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
new file mode 100644
index 0000000..96d016a
--- /dev/null
+++ b/lib/gerrit/BUCK
@@ -0,0 +1,13 @@
+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,
+ sha1 = 'be80ff991f7b9f8669b7a2a399003ec1ae69ed31',
+ 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..c1ea124
--- /dev/null
+++ b/src/main/resources/Documentation/build.md
@@ -0,0 +1,84 @@
+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 ref-protection directory:
+
+```
+ cd ref-protection && ln -s ../bucklets .
+```
+
+Add link to the .buckversion file:
+
+```
+ cd ref-protection && ln -s bucklets/buckversion .buckversion
+```
+
+Add link to the .watchmanconfig file:
+
+```
+ cd ref-protection && ln -s bucklets/watchmanconfig .watchmanconfig
+```
+
+To build the plugin, issue the following command:
+
+```
+ buck build plugin
+```
+
+The output is created in
+
+```
+ buck-out/gen/ref-protection.jar
+```
+
+To run unit tests, issue the following command:
+
+```
+ buck test
+```
+
+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/ref-protection
+```
+
+The output is created in
+
+```
+ buck-out/gen/plugins/ref-protection/ref-protection.jar
+```
+
+This project can be imported into the Eclipse IDE:
+
+```
+ ./tools/eclipse/project.py
+```
+
+To run the unit tests and restrict to run only the tests from this plugin:
+
+```
+ buck test --include ref-protection
+```
+
+How to build the Gerrit Plugin API is described in the [Gerrit
+documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files).