Merge branch 'stable-2.13'
* stable-2.13:
Compile against Gerrit 2.13.9
Remove usage of java.util.Optional
"Remove usage of java.util.Optional" is reverted in this merge, this
commit was only needed on stable-2.13 branch.
Change-Id: I9220a5fdf443f8537aa58b23491c37c6b6b58e79
diff --git a/.buckconfig b/.buckconfig
deleted file mode 100644
index 8301d1b..0000000
--- a/.buckconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-[alias]
- quota = //:quota
- plugin = //:quota
-
-[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 4d527fb..0000000
--- a/BUCK
+++ /dev/null
@@ -1,30 +0,0 @@
-include_defs('//bucklets/gerrit_plugin.bucklet')
-
-gerrit_plugin(
- name = 'quota',
- srcs = glob(['src/main/java/**/*.java']),
- resources = glob(['src/main/resources/**/*']),
- manifest_entries = [
- 'Gerrit-PluginName: quota',
- 'Gerrit-Module: com.googlesource.gerrit.plugins.quota.Module',
- ],
- provided_deps = [
- '//lib/commons:lang',
- ]
-)
-
-TEST_DEPS = GERRIT_PLUGIN_API + GERRIT_TESTS + [
- ':quota__plugin'
-]
-
-java_library(
- name = 'classpath',
- deps = TEST_DEPS,
-)
-
-java_test(
- name = 'quota_tests',
- srcs = glob(['src/test/java/**/*.java']),
- labels = ['quota'],
- deps = TEST_DEPS,
-)
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..e4fda3a
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,26 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load(
+ "//tools/bzl:plugin.bzl",
+ "gerrit_plugin",
+ "PLUGIN_DEPS",
+ "PLUGIN_TEST_DEPS",
+)
+
+gerrit_plugin(
+ name = "quota",
+ srcs = glob(["src/main/java/**/*.java"]),
+ resources = glob(["src/main/resources/**/*"]),
+ manifest_entries = [
+ "Gerrit-PluginName: quota",
+ "Gerrit-Module: com.googlesource.gerrit.plugins.quota.Module",
+ ],
+)
+
+junit_tests(
+ name = "quota_tests",
+ srcs = glob(["src/test/java/**/*.java"]),
+ tags = ["quota"],
+ deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+ ":quota__plugin",
+ ],
+)
diff --git a/lib/commons/BUCK b/lib/commons/BUCK
deleted file mode 100644
index be9dfe5..0000000
--- a/lib/commons/BUCK
+++ /dev/null
@@ -1,11 +0,0 @@
-include_defs('//bucklets/maven_jar.bucklet')
-
-maven_jar(
- name = 'lang',
- id = 'commons-lang:commons-lang:2.5',
- sha1 = 'b0236b252e86419eef20c31a44579d2aee2f0a69',
- exclude = ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt'],
- attach_source = False,
- license = 'Apache2.0',
-)
-
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
deleted file mode 100644
index a28cf4e..0000000
--- a/lib/gerrit/BUCK
+++ /dev/null
@@ -1,22 +0,0 @@
-include_defs('//bucklets/maven_jar.bucklet')
-
-VER = '2.13.9'
-REPO = MAVEN_CENTRAL
-
-maven_jar(
- name = 'plugin-api',
- id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
- sha1 = 'a9b00025900f68c1f86036ea07591a2876b10c37',
- attach_source = False,
- repository = REPO,
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'acceptance-framework',
- id = 'com.google.gerrit:gerrit-acceptance-framework:' + VER,
- sha1 ='53a6e2baca19303bbf3967b861cf9814323c31f6',
- license = 'Apache2.0',
- attach_source = False,
- repository = REPO,
-)
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 0c61ba6..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,109 +0,0 @@
-<!--
-Copyright (C) 2014 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>com.googlesource.gerrit.plugins.quota</groupId>
- <artifactId>quota</artifactId>
- <packaging>jar</packaging>
- <version>2.13-SNAPSHOT</version>
- <name>quota</name>
-
- <properties>
- <Gerrit-ApiType>plugin</Gerrit-ApiType>
- <Gerrit-ApiVersion>${project.version}</Gerrit-ApiVersion>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.4</version>
- <configuration>
- <archive>
- <manifestEntries>
- <Gerrit-PluginName>quota</Gerrit-PluginName>
- <Gerrit-Module>com.googlesource.gerrit.plugins.quota.Module</Gerrit-Module>
-
- <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor>
- <Implementation-URL>http://code.google.com/p/gerrit/</Implementation-URL>
-
- <Implementation-Title>${Gerrit-ApiType} ${project.artifactId}</Implementation-Title>
- <Implementation-Version>${project.version}</Implementation-Version>
-
- <Gerrit-ApiType>${Gerrit-ApiType}</Gerrit-ApiType>
- <Gerrit-ApiVersion>${Gerrit-ApiVersion}</Gerrit-ApiVersion>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- <encoding>UTF-8</encoding>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>com.google.gerrit</groupId>
- <artifactId>gerrit-${Gerrit-ApiType}-api</artifactId>
- <version>${Gerrit-ApiVersion}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>3.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.7.7</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <repositories>
- <repository>
- <id>gerrit-api-repository</id>
- <url>https://gerrit-api.storage.googleapis.com/snapshot/</url>
- </repository>
- </repositories>
-</project>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsConfig.java
index c29ae7f..7567855 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsConfig.java
@@ -14,13 +14,13 @@
package com.googlesource.gerrit.plugins.quota;
-import com.google.common.base.Optional;
import com.google.common.collect.ArrayTable;
import com.google.common.collect.Table;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Locale;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
@@ -183,8 +183,8 @@
*/
Optional<Map<String, RateLimit>> getRatelimits(Type type) {
if (rateLimits != null) {
- return Optional.fromNullable(rateLimits.row(type));
+ return Optional.ofNullable(rateLimits.row(type));
}
- return Optional.absent();
+ return Optional.empty();
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsFinder.java b/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsFinder.java
index 2cf7d6f..751735c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsFinder.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/AccountLimitsFinder.java
@@ -15,7 +15,6 @@
import static com.googlesource.gerrit.plugins.quota.AccountLimitsConfig.KEY;
-import com.google.common.base.Optional;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.GroupMembership;
@@ -31,6 +30,7 @@
import org.slf4j.LoggerFactory;
import java.util.Map;
+import java.util.Optional;
public class AccountLimitsFinder {
private static final Logger log =
@@ -64,11 +64,11 @@
log.error("Ignoring limits for unknown group ''{}'' in quota.config",
groupName);
} else if (memberShip.contains(d.getGroupUUID())) {
- return Optional.fromNullable(limits.get().get(groupName));
+ return Optional.ofNullable(limits.get().get(groupName));
}
}
}
- return Optional.absent();
+ return Optional.empty();
}
/**
@@ -78,9 +78,9 @@
*/
public Optional<RateLimit> getRateLimit(Type type, String groupName) {
if (getRatelimits(type).isPresent()) {
- return Optional.fromNullable(getRatelimits(type).get().get(groupName));
+ return Optional.ofNullable(getRatelimits(type).get().get(groupName));
}
- return Optional.absent();
+ return Optional.empty();
}
/**
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/Module.java b/src/main/java/com/googlesource/gerrit/plugins/quota/Module.java
index 240f42e..935498a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/Module.java
@@ -19,7 +19,6 @@
import static com.google.gerrit.server.project.ProjectResource.PROJECT_KIND;
import static com.googlesource.gerrit.plugins.quota.QuotaResource.QUOTA_KIND;
-import com.google.common.base.Optional;
import com.google.common.cache.CacheLoader;
import com.google.common.util.concurrent.RateLimiter;
import com.google.gerrit.extensions.events.GarbageCollectorListener;
@@ -40,6 +39,7 @@
import com.google.inject.Scopes;
import com.google.inject.internal.UniqueAnnotations;
import com.googlesource.gerrit.plugins.quota.AccountLimitsConfig.RateLimit;
+import java.util.Optional;
import org.eclipse.jgit.transport.PostReceiveHook;
class Module extends CacheModule {
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index e22de10..5ff0924 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,102 +1,35 @@
Build
=====
-This plugin can be built with Buck or Maven.
+This plugin is built with Bazel.
-Buck
+Bazel
----
-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 (or link) this plugin to the `plugins` directory of Gerrit's source tree.
-
-### Build standalone
-
-Clone bucklets library:
+Build the plugin from Gerrit's root directory:
```
- git clone https://gerrit.googlesource.com/bucklets
-
-```
-and link it to quota plugin directory:
-
-```
- cd quota && ln -s ../bucklets .
-```
-
-Add link to the .buckversion file:
-
-```
- cd quota && ln -s bucklets/buckversion .buckversion
-```
-
-Add link to the .watchmanconfig file:
-```
- cd server-config && ln -s bucklets/watchmanconfig .watchmanconfig
-```
-
-To build the plugin, issue the following command:
-
-
-```
- buck build plugin
+ bazel build plugins/quota
```
The output is created in
```
- buck-out/gen/quota.jar
+ bazel-genfiles/plugins/quota/quota.jar
```
-Test are executed with
-
-```
- buck test
-```
-
-This project can be imported into the Eclipse IDE:
-
-```
- ./bucklets/tools/eclipse.py
-```
-
-### 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/quota
-```
-
-The output is created in
-
-```
- buck-out/gen/plugins/quota/quota.jar
-```
-
-This project can be imported into the Eclipse IDE:
+This project can be imported into the Eclipse IDE.
+Add the plugin name to the `CUSTOM_PLUGINS` set in Gerrit's
+`tools/bzl/plugins.bzl` and execute:
```
./tools/eclipse/project.py
```
-Test are executed with
+To execute the tests run:
```
- buck test --include quota-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
+ bazel test plugins/quota:quota_tests
```
diff --git a/src/test/java/com/googlesource/gerrit/plugins/quota/PublisherExceptionTest.java b/src/test/java/com/googlesource/gerrit/plugins/quota/PublisherExceptionTest.java
index 291b4dd..8018a86 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/quota/PublisherExceptionTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/quota/PublisherExceptionTest.java
@@ -57,7 +57,7 @@
@Before
public void setupLogging() {
- captor = EasyMock.newCapture();
+ captor = new Capture();
appender = createMock(Appender.class);
appender.doAppend(capture(captor));
expectLastCall().anyTimes();