reviewers-by-blame plugin not loading

532 views
Skip to first unread message

Vince Thyng

unread,
Apr 29, 2015, 3:01:50 PM4/29/15
to repo-d...@googlegroups.com

I am trying to get my first plugin working in gerrit.  I built it with buck and then put the reviewers-by-blame.jar in the plugins folder.  When gerrit starts, the error_log reports:

[2015-04-29 11:42:20,382] WARN  com.google.gerrit.server.plugins.PluginLoader : Cannot load plugin reviewers-by-blame
java.lang.NoClassDefFoundError: com/google/gerrit/common/EventListener
        at com.googlesource.gerrit.plugins.reviewersbyblame.ReviewersByBlameModule.configure(ReviewersByBlameModule.java:26)

It looks like I am missing a dependency, but it is not clear to me how to add it.  I found the com folder with the EventListener.class in my cloned gerrit folder and copied it to the plugins folder, but that did not work.

Did I need to build the plugin differently to include the dependencies in the jar?
maybe I will just open the jar and add the com folder

The way I built the plugin was
git clone https://gerrit.googlesource.com/gerrit
cd gerrit/plugins
git clone https://gerrit.googlesource.com/plugins/reviewers-by-blame
/buck/bin/buck build plugins/reviewers-by-blame:reviewers-by-blame
jar found in
buck-out/gen/plugins/reviewers-by-blame/reviewers-by-blame.jar

Perhaps it is important to note that I am not using gerrit from this clone, I am using the jar downloaded from the site. v2.10.2.

Jan Kundrát

unread,
Apr 29, 2015, 3:48:21 PM4/29/15
to repo-d...@googlegroups.com
On Wednesday, 29 April 2015 20:59:42 CEST, Vince Thyng wrote:
> It looks like I am missing a dependency, but it is not clear to me how to
> add it. I found the com folder with the EventListener.class in my cloned
> gerrit folder and copied it to the plugins folder, but that did not work.
[...]
> Perhaps it is important to note that I am not using gerrit from this clone,
> I am using the jar downloaded from the site. v2.10.2.

You have to use reviewers-by-blame's stable-2.10 branch, then. There's been
incompatible internal API changes between 2.10 and 2.11, as you found out.

Cheers,
Jan

--
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/
Message has been deleted

David Pursehouse

unread,
May 21, 2015, 8:28:19 PM5/21/15
to Vince Thyng, repo-d...@googlegroups.com
On 04/30/2015 03:59 AM, Vince Thyng wrote:
>
> I am trying to get my first plugin working in gerrit. I built it with
> buck and then put the reviewers-by-blame.jar in the plugins folder.
> When gerrit starts, the error_log reports:
>
> [2015-04-29 11:42:20,382] WARN
> com.google.gerrit.server.plugins.PluginLoader : Cannot load plugin
> reviewers-by-blame
> java.lang.NoClassDefFoundError: com/google/gerrit/common/EventListener
> at
> com.googlesource.gerrit.plugins.reviewersbyblame.ReviewersByBlameModule.configure(ReviewersByBlameModule.java:26)
>

This error is because the plugin is built against a different API
version than the version of Gerrit you're running it on.

> It looks like I am missing a dependency, but it is not clear to me how
> to add it. I found the com folder with the EventListener.class in my
> cloned gerrit folder and copied it to the plugins folder, but that did
> not work.
>

No, this will not work.

> Did I need to build the plugin differently to include the dependencies
> in the jar?
> maybe I will just open the jar and add the com folder
>

And neither will this.

> The way I built the plugin was
> git clone https://gerrit.googlesource.com/gerrit
> cd gerrit/plugins

I don't see any git checkout command, so that means you're using the
master branch of Gerrit.

> git clone https://gerrit.googlesource.com/plugins/reviewers-by-blame
> /buck/bin/buck build plugins/reviewers-by-blame:reviewers-by-blame

and again here there's no git checkout, so you're also building the
master branch of the plugin.

Furthermore, since you're building in-tree it is building the plugin
against the API from Gerrit's master branch regardless of what branch of
the plugin is checked out.

To build the plugin in-tree with buck you need to make sure the correct
branches are checked out both on gerrit and the plugin itself:

cd gerrit
git checkout v2.10 # or any v2.10.x tag, or the head of stable-2.10
cd plugins/reviewers-by-blame
git checkout origin/stable-2.10
cd ../..
buck build plugins/reviewers-by-blame:reviewers-by-blame

Alternatively you can build it in standalone mode with Maven, then you
don't need to clone Gerrit at all:

cd $HOME
git clone https://gerrit.googlesource.com/plugins/reviewers-by-blame
cd reviewers-by-blame
git checkout origin/stable-2.10
mvn clean package

the JAR file is at target/reviewersbyblame-2.10.jar

Note that there is no standalone buck build on the stable-2.10 branch;
that was only added on stable-2.11.
Reply all
Reply to author
Forward
0 new messages