Kill Buck, welcome Bazel build
Introduce Gerrit in-tree Bazel build and get rid of all
references to Buck.
Change-Id: Ia4ad2fe1a86cb40f22ae625dda24d22da3c28010
diff --git a/.buckconfig b/.buckconfig
deleted file mode 100644
index 109b4c0..0000000
--- a/.buckconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-[alias]
- uploadvalidator = //:uploadvalidator
- plugin = //:uploadvalidator
-
-[java]
- src_roots = java, resources
-
-[project]
- ignore = .git
-
-[cache]
- mode = dir
- dir = buck-out/cache
-
diff --git a/.gitignore b/.gitignore
index 43838b0..80d6257 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,3 @@
-/.buckversion
-/.buckd
-/buck-out
-/bucklets
/target
/.classpath
/.project
diff --git a/BUCK b/BUCK
deleted file mode 100644
index 9d8c705..0000000
--- a/BUCK
+++ /dev/null
@@ -1,48 +0,0 @@
-include_defs('//bucklets/gerrit_plugin.bucklet')
-include_defs('//bucklets/maven_jar.bucklet')
-
-gerrit_plugin(
- name = 'uploadvalidator',
- srcs = glob(['src/main/java/**/*.java']),
- resources = glob(['src/main/resources/**/*']),
- manifest_entries = [
- 'Gerrit-PluginName: uploadvalidator',
- 'Gerrit-ApiType: plugin',
- 'Gerrit-ApiVersion: 2.12-SNAPSHOT',
- 'Gerrit-Module: com.googlesource.gerrit.plugins.uploadvalidator.Module',
- ],
- deps = [
- ':commons-io',
- ':tika-core',
- ],
-)
-
-# this is required for bucklets/tools/eclipse/project.py to work
-java_library(
- name = 'classpath',
- deps = [':uploadvalidator__plugin'],
-)
-
-maven_jar(
- name = 'commons-io',
- id = 'commons-io:commons-io:1.4',
- sha1 = 'a8762d07e76cfde2395257a5da47ba7c1dbd3dce',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'tika-core',
- id = 'org.apache.tika:tika-core:1.12',
- sha1 = '5ab95580d22fe1dee79cffbcd98bb509a32da09b',
- license = 'Apache2.0',
-)
-
-java_test(
- name = 'uploadvalidator_tests',
- srcs = glob(['src/test/java/**/*.java']),
- labels = ['uploadvalidator'],
- deps = GERRIT_PLUGIN_API + GERRIT_TESTS + [
- ':commons-io',
- ':uploadvalidator__plugin',
- ],
-)
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..0c83ab9
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,44 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load("//tools/bzl:plugin.bzl", "gerrit_plugin", "PLUGIN_DEPS", "PLUGIN_TEST_DEPS")
+
+gerrit_plugin(
+ name = "uploadvalidator",
+ srcs = glob(["src/main/java/**/*.java"]),
+ manifest_entries = [
+ "Gerrit-PluginName: uploadvalidator",
+ "Gerrit-ApiVersion: 2.14-SNAPSHOT",
+ "Gerrit-Module: com.googlesource.gerrit.plugins.uploadvalidator.Module",
+ ],
+ resources = glob(["src/main/resources/**/*"]),
+ deps = [
+ "@commons_io//jar",
+ "@tika_core//jar",
+ ],
+)
+
+TEST_SRCS = "src/test/java/**/*Test.java"
+
+TEST_DEPS = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+ "@commons_io//jar",
+ ":uploadvalidator__plugin",
+]
+
+java_library(
+ name = "testutils",
+ testonly = 1,
+ srcs = glob(
+ include = ["src/test/java/**/*.java"],
+ exclude = [TEST_SRCS],
+ ),
+ deps = TEST_DEPS,
+)
+
+junit_tests(
+ name = "uploadvalidator_tests",
+ testonly = 1,
+ srcs = glob([TEST_SRCS]),
+ tags = ["uploadvalidator"],
+ deps = TEST_DEPS + [
+ ":testutils",
+ ],
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..d8ca858
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,8 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+ maven_jar(
+ name = 'tika_core',
+ artifact = 'org.apache.tika:tika-core:1.12',
+ sha1 = '5ab95580d22fe1dee79cffbcd98bb509a32da09b',
+ )
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
deleted file mode 100644
index 235ddf9..0000000
--- a/lib/gerrit/BUCK
+++ /dev/null
@@ -1,22 +0,0 @@
-include_defs('//bucklets/maven_jar.bucklet')
-
-VER = '2.12'
-REPO = MAVEN_CENTRAL
-
-maven_jar(
- name = 'plugin-api',
- id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
- sha1 = '8ce1f6e65078bbcf03a1758f96b3ebca19b7fe3c',
- attach_source = False,
- repository = REPO,
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'acceptance-framework',
- id = 'com.google.gerrit:gerrit-acceptance-framework:' + VER,
- sha1 = 'f35140148294239012b1a5052181783c0c9f4ffd',
- attach_source = False,
- repository = REPO,
- license = 'Apache2.0',
-)
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 8b5de99..13f24bc 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,59 +1,52 @@
Build
=====
-This plugin is built using 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.
-
-
-
-Clone bucklets library:
-
-```
- git clone https://gerrit.googlesource.com/bucklets
-
-```
-and link it to @PLUGIN@ plugin directory:
-
-```
- cd @PLUGIN@ && ln -s ../bucklets .
-```
-
-Add link to the .buckversion file:
-
-```
- cd @PLUGIN@ && ln -s bucklets/buckversion .buckversion
-```
-
-To build the plugin, issue the following command:
-
-
-```
- buck build plugin
-```
-
-The output is created in
-
-```
- buck-out/gen/@PLUGIN@.jar
-```
-
+This plugin is built using Bazel.
+Only the Gerrit in-tree build is supported.
Clone or link this plugin to the plugins directory of Gerrit's source
-tree, and issue the command:
+tree.
```
- buck build plugins/@PLUGIN@
+ git clone https://gerrit.googlesource.com/gerrit
+ git clone https://gerrit.googlesource.com/plugins/@PLUGIN@
+ cd gerrit/plugins
+ ln -s ../../@PLUGIN@ .
+```
+
+Put the external dependency Bazel build file into the Gerrit /plugins
+directory, replacing the existing empty one.
+
+```
+ cd gerrit/plugins
+ rm external_plugin_deps.bzl
+ ln -s @PLUGIN@/external_plugin_deps.bzl .
+```
+
+From Gerrit source tree issue the command:
+
+```
+ bazel build plugins/@PLUGIN@
```
The output is created in
```
- buck-out/gen/plugins/@PLUGIN@/@PLUGIN@.jar
+ bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar
```
+To execute the tests run:
+
+```
+ bazel test plugins/@PLUGIN@:@PLUGIN@_tests
+```
+
+or filtering using the comma separated tags:
+
+````
+ bazel test --test_tag_filters=@PLUGIN@ //...
+````
+
This project can be imported into the Eclipse IDE:
```