Gerrit plugins can be built with both Buck and Maven.
NOTE: Developing Gerrit plugins requires installing JDK first.
If plugin contains pom.xml
file, it can be built with Maven.
git clone https://gerrit.googlesource.com/plugins/reviewers
mvn clean package
Maven will automatically download all dependencies and build source code. You will be able to find jar file in $WORKSPACE/target
directory.
BUCK is recommended by Gerrit Community. It’s faster. The build artifcat is also smaller than Maven.
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 bucklets library
git clone https://gerrit.googlesource.com/bucklets
# checkout the correct bucklets version: Make sure bucklets/buckversion is same as the gerrit/.buckversion
git checkout SHA-1
# link bucklets to the plugin directory
cd PLUGIN_DIRECTORY
ln -s ../bucklets .
# link to the .buckversion file
ln -s bucklets/buckversion .buckversion
# build the plugin
buck build plugin
# You will be able to find the plugin in buck-out/gen
NOTE
It’s critical to checkout correct bucklets version. You have to travese commit history of bucklets repository and find out the correct version.
For example, we need to build a plugin for Gerrit version stable-2.11.
Go to gerrit source repository, and we can find .buckversion
which contains the commit SHA-1 79d36de9f5284f6e833cca81867d6088a25685fb
Then we will check bucklets repository and find in commit bdd7f97
, the bucklets/buckversion
has the same commit SHA-1 79d36de9f5284f6e833cca81867d6088a25685fb
.
So we need to checkout bdd7f97
for bucklets repository.