Remove PowerMock and replace with EasyMock

Remove PowerMock 2.0.9 (powermock-api-easymock, powermock-module-junit4
and their five transitive siblings) and the javassist version pin that
only existed to override PowerMock's older transitive. PowerMock 2.0.9
is the last release from 2020 and its classloader rewriting is
incompatible with EasyMock 5's MethodHandles.Lookup-based ByteBuddy
class injection on Java 17+: the generated proxy lands in
org.easymock.mocks.* but the Lookup is anchored at
org.easymock.internal.ClassProxyFactory and the JVM refuses the
cross-package define.

PowerMock's only feature this codebase used was mockStatic on
JgitWrapper. Convert JgitWrapper from static utility to a stateless
instance class so its method becomes invokevirtual on a mocked
instance, which plain EasyMock instance mocking handles. PathOwners
gains a package-private 11-arg constructor that accepts the wrapper
for tests; the public 10-arg overloads default to a real
new JgitWrapper(), so all production callers in plugins/owners are
unchanged.

Keeping a single mocking framework on the test classpath was preferred
over adopting Mockito.mockStatic on a still-static JgitWrapper.

Bump org.easymock:easymock to 5.6.0 for a byte-buddy that knows recent
JDK class-file versions.

Co-Authored-By: Daniele Sassoli <danielesassoli@gmail.com>
Change-Id: I5079628f6f3cde4786800e4810939e40b8a4ac48
7 files changed
tree: 0b597ee415058e7e2524a6d70afab404e3934d98
  1. src/
  2. .gitignore
  3. BUILD
  4. external_plugin_deps.bzl
  5. LICENSE
  6. README.md
README.md

Gerrit Owners-Common-API Plugin

This repository contains the basic infrastructure and API for building and running two separate plugins, owners and owners-autoassign.

It provides the ability to parse the OWNERS file format and it's parsing across branches and repositories.

Building the plugins

This plugin is built with Bazel in Gerrit tree

Create symbolic links of the owners-common-api folderd and of the external_plugin_deps.bzl file to the Gerrit source code /plugins directory.

Then build the owners-common-api plugin with the usual Gerrit plugin compile command.

Example:

  git clone https://gerrit.googlesource.com/plugins/owners-common-api
  git clone --recurse-submodules https://gerrit.googlesource.com/gerrit
  cd gerrit/plugins
  ln -s ../../owners/owners-common-api .
  ln -sf owners-common-api/external_plugin_deps.bzl .
  cd ..
  bazel build plugins/owners-common-api

The output is created in

  bazel-bin/plugins/owners-common-api/owners-common-api.jar

To execute the tests run:

  bazel test plugins/owners-common-api/...

This project can be imported into the Eclipse IDE:

Add the plugin name to the CUSTOM_PLUGINS (and in case when you want to run tests from the IDE to CUSTOM_PLUGINS_TEST_DEPS) in Gerrit core in tools/bzl/plugins.bzl file and run:

  ./tools/eclipse/project.py