Merge "Fix javac warnings"
diff --git a/.buckconfig b/.buckconfig
deleted file mode 100644
index 112615b..0000000
--- a/.buckconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-[alias]
- automerger = //:automerger
- plugin = //:automerger
-[java]
- src_roots = java, resources
-[project]
- ignore = .git
-[cache]
- mode = dir
- dir = buck-out/cache
diff --git a/BUCK b/BUCK
deleted file mode 100644
index 95b0c44..0000000
--- a/BUCK
+++ /dev/null
@@ -1,58 +0,0 @@
-include_defs('//bucklets/gerrit_plugin.bucklet')
-include_defs('//bucklets/maven_jar.bucklet')
-
-gerrit_plugin(
- name = 'automerger',
- srcs = glob(['src/main/java/**/*.java']),
- resources = glob(['src/main/**/*']),
- manifest_entries = [
- 'Gerrit-PluginName: automerger',
- 'Gerrit-Module: com.googlesource.gerrit.plugins.automerger.AutomergerModule',
- 'Implementation-Title: Automerger plugin',
- 'Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/automerger',
- ],
- deps = [
- ':re2j',
- ':yaml',
- ],
-)
-
-define_license(name = 're2j')
-
-maven_jar(
- name = 'yaml',
- id = 'org.yaml:snakeyaml:1.17',
- sha1 = '7a27ea250c5130b2922b86dea63cbb1cc10a660c',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'mockito',
- id = 'org.mockito:mockito-all:1.10.19',
- sha1 = '539df70269cc254a58cccc5d8e43286b4a73bf30',
- license = 'DO_NOT_DISTRIBUTE',
-)
-
-maven_jar(
- name = 're2j',
- id = 'com.google.re2j:re2j:1.0',
- sha1 = 'd24ac5f945b832d93a55343cd1645b1ba3eca7c3',
- license = 're2j',
- local_license = True,
-)
-
-java_test(
- name = 'automerger_tests',
- srcs = glob(['src/test/java/**/*.java']),
- resources = glob(['src/test/resources/**/*']),
- labels = ['automerger'],
- deps = GERRIT_PLUGIN_API + GERRIT_TESTS + [
- ':automerger__plugin',
- ':mockito',
- ],
-)
-
-java_library(
- name = 'classpath',
- deps = [':automerger__plugin'] + GERRIT_PLUGIN_API,
-)
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..a8d88ae
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,29 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load("//tools/bzl:plugin.bzl", "gerrit_plugin", "PLUGIN_DEPS", "PLUGIN_TEST_DEPS")
+
+gerrit_plugin(
+ name = "automerger",
+ srcs = glob(["src/main/java/**/*.java"]),
+ manifest_entries = [
+ "Gerrit-PluginName: automerger",
+ "Gerrit-Module: com.googlesource.gerrit.plugins.automerger.AutomergerModule",
+ "Implementation-Title: Automerger plugin",
+ "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/automerger",
+ ],
+ resources = glob(["src/main/resources/**/*"]),
+ deps = [
+ "@re2j//jar",
+ "@yaml//jar",
+ ],
+)
+
+junit_tests(
+ name = "automerger_tests",
+ srcs = glob(["src/test/java/**/*.java"]),
+ resources = glob(["src/test/resources/**/*"]),
+ tags = ["automerger"],
+ deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+ ":automerger__plugin",
+ "@mockito//jar",
+ ],
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..0396eea
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,20 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+ maven_jar(
+ name = 'yaml',
+ artifact = 'org.yaml:snakeyaml:1.17',
+ sha1 = '7a27ea250c5130b2922b86dea63cbb1cc10a660c',
+ )
+
+ maven_jar(
+ name = 'mockito',
+ artifact = 'org.mockito:mockito-all:1.10.19',
+ sha1 = '539df70269cc254a58cccc5d8e43286b4a73bf30',
+ )
+
+ maven_jar(
+ name = 're2j',
+ artifact = 'com.google.re2j:re2j:1.0',
+ sha1 = 'd24ac5f945b832d93a55343cd1645b1ba3eca7c3',
+ )
diff --git a/src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java b/src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java
index e02ceb5..a067416 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreator.java
@@ -382,6 +382,7 @@
MergeInput mergeInput = new MergeInput();
mergeInput.source = sdsMergeInput.currentRevision;
+ mergeInput.strategy = "recursive";
log.debug("Creating downstream merge for {}", sdsMergeInput.currentRevision);
ChangeInput downstreamChangeInput = new ChangeInput();
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 24145f3..5ea4113 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,74 +1,56 @@
Build
=====
-This plugin can be built with Buck.
-
-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 automerger plugin directory:
-
-```
- cd automerger && ln -s ../bucklets .
-```
-
-Add link to the .buckversion file:
-
-```
- cd automerger && ln -s bucklets/buckversion .buckversion
-```
-
-Add link to the .watchmanconfig file:
-```
- cd automerger && ln -s bucklets/watchmanconfig .watchmanconfig
-```
-
-To build the plugin, issue the following command:
-
-
-```
- buck build plugin
-```
-
-The output is created in
-
-```
- buck-out/gen/automerger.jar
-```
-
-### Build in Gerrit tree
+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/automerger
+ git clone https://gerrit.googlesource.com/gerrit
+ git clone https://gerrit.googlesource.com/plugins/automerger
+ cd gerrit/plugins
+ ln -s ../../automerger .
+```
+
+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 automerger/external_plugin_deps.bzl .
+```
+
+From Gerrit source tree issue the command:
+
+```
+ bazel build plugins/automerger
```
The output is created in
```
- buck-out/gen/plugins/automerger/automerger.jar
+ bazel-genfiles/plugins/automerger/automerger.jar
```
-This project can be imported into the Eclipse IDE:
+To execute the tests run:
+
+```
+ bazel test plugins/automerger:automerger_tests
+```
+
+or filtering using the comma separated tags:
+
+````
+ bazel test --test_tag_filters=automerger //...
+````
+
+This project can be imported into the Eclipse IDE.
+Add the plugin name to the `CUSTOM_PLUGINS` set in
+Gerrit core in `tools/bzl/plugins.bzl`, and execute:
```
./tools/eclipse/project.py
```
-
-How to build the Gerrit Plugin API is described in the [Gerrit
-documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files).
diff --git a/src/test/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreatorTest.java b/src/test/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreatorTest.java
index c8fad3f..5be92c4 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreatorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/automerger/DownstreamCreatorTest.java
@@ -14,8 +14,12 @@
package com.googlesource.gerrit.plugins.automerger;
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
import com.google.gerrit.extensions.api.GerritApi;
-import com.google.gerrit.extensions.api.changes.AbandonInput;
import com.google.gerrit.extensions.api.changes.ChangeApi;
import com.google.gerrit.extensions.api.changes.RevisionApi;
import com.google.gerrit.extensions.client.ListChangesOption;
@@ -24,19 +28,14 @@
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.MergePatchSetInput;
import com.google.gerrit.extensions.common.RevisionInfo;
-import com.google.common.collect.ImmutableList;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-
-import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
-import static com.google.common.truth.Truth.assertThat;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
public class DownstreamCreatorTest {
private final String changeId = "testid";
@@ -117,6 +116,7 @@
assertThat("testds").isEqualTo(changeInput.branch);
assertThat(changeTopic).isEqualTo(changeInput.topic);
assertThat(changeInput.merge.source).isEqualTo(currentRevision);
+ assertThat(changeInput.merge.strategy).isEqualTo("recursive");
String expectedSubject = changeSubject + " am: " + currentRevision.substring(0, 10);
assertThat(expectedSubject).isEqualTo(changeInput.subject);
@@ -158,8 +158,7 @@
assertThat(changeInput.merge.source).isEqualTo(currentRevision);
// Check that it was actually skipped
- String expectedSubject =
- changeSubject + " skipped: " + currentRevision.substring(0, 10);
+ String expectedSubject = changeSubject + " skipped: " + currentRevision.substring(0, 10);
assertThat(changeInput.merge.strategy).isEqualTo("ours");
assertThat(expectedSubject).isEqualTo(changeInput.subject);
}
@@ -183,9 +182,16 @@
ArgumentCaptor<ChangeInput> changeInputCaptor = ArgumentCaptor.forClass(ChangeInput.class);
Mockito.verify(gApiMock.changes(), Mockito.times(2)).create(changeInputCaptor.capture());
- List<ChangeInput> capturedChangeInputs = changeInputCaptor.getAllValues();
- assertThat(capturedChangeInputs.get(0).branch).isEqualTo("testone");
- assertThat(capturedChangeInputs.get(1).branch).isEqualTo("testtwo");
+ List<String> capturedBranches =
+ Lists.transform(
+ changeInputCaptor.getAllValues(),
+ new Function<ChangeInput, String>() {
+ @Override
+ public String apply(ChangeInput c) {
+ return c.branch;
+ }
+ });
+ assertThat(capturedBranches).containsExactly("testone", "testtwo");
}
@Test