{"id":5171,"date":"2018-08-19T20:09:20","date_gmt":"2018-08-19T20:09:20","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=5171"},"modified":"2020-01-09T06:47:48","modified_gmt":"2020-01-09T06:47:48","slug":"how-to-compile-and-build-gerrit-plugins","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-compile-and-build-gerrit-plugins\/","title":{"rendered":"How to compile and build Gerrit Plugins?"},"content":{"rendered":"<p><strong>To build Gerrit Plugins from source, you need:<\/strong><\/p>\n<p>A Linux or macOS system (Windows is not supported at this time)<\/p>\n<p><strong>zip, unzip, wget<\/strong><\/p>\n<pre>$yum install zip -y\n$ yum install unzip -y\n$ yum install wget -y\n$ yum install git -y<\/pre>\n<p><strong>Python 2 or 3<\/strong><br \/>\nThis is installed in each RHEL 7 and Ubunutu server by defaul.<\/p>\n<p><strong>Node.js<\/strong><\/p>\n<pre>curl --silent --location https:\/\/rpm.nodesource.com\/setup_8.x | sudo bash -\nOR\ncurl --silent --location https:\/\/rpm.nodesource.com\/setup_10.x | sudo bash -\nsudo yum -y install nodejs<\/pre>\n<p><strong>Bazel<\/strong><\/p>\n<pre>## RHEL\/CentOS 7 64-Bit ##\n$ wget https:\/\/copr.fedorainfracloud.org\/coprs\/vbatts\/bazel\/repo\/epel-7\/vbatts-bazel-epel-7.repo\n$ cp vbatts-bazel-epel-7.repo \/etc\/yum.repos.d\/\n$ yum install -y bazel<\/pre>\n<p><strong>How to Installing Bazel on Ubuntu?<\/strong><br \/>\nhttps:\/\/docs.bazel.build\/versions\/master\/install-ubuntu.html<\/p>\n<p><strong>Maven<\/strong><\/p>\n<pre>$ cd \/opt\n$ wget http:\/\/www-us.apache.org\/dist\/maven\/maven-3\/3.5.4\/binaries\/apache-maven-3.5.4-bin.zip\n$ unzip apache-maven-3.5.4-bin.zip\n$ mv apache-maven-3.5.4 maven\n$ export PATH=$PATH:\/op\/maven\/bin<\/pre>\n<p><strong>gcc<\/strong><\/p>\n<p>[code language=&#8221;text&#8221;]$ sudo yum install gcc-c++ make[\/code]<\/p>\n<p><strong>Now, Bazel in tree driven means it can only be built from within Gerrit tree. Clone or link the plugin into gerrit\/plugins directory:<\/strong><\/p>\n<p><strong># First become a non-root user<\/strong><\/p>\n<p><strong>A JDK for Java 8<\/strong><\/p>\n<pre>$ cd\n$ wget -c --header \"Cookie: oraclelicense=accept-securebackup-cookie\" http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u181-b13\/96a7b8442fe848ef90c96a2fad6ed6d1\/jdk-8u181-linux-x64.tar.gz\n$ tar -xvf jdk-8u181-linux-x64.tar.gz\n$ export JAVA_HOME=\/home\/ec2-user\/jdk1.8.0_181\n$ java -version\n<\/pre>\n<p><strong>Follow for Gerrit.war<\/strong><\/p>\n<pre>$ git clone --recursive https:\/\/gerrit.googlesource.com\/gerrit\n$ cd gerrit \n$ bazel build release\n<\/pre>\n<p><strong>Follow for plugins such as&nbsp;its-jira<\/strong><\/p>\n<pre>$ cd plugins\n$ git clone https:\/\/gerrit.googlesource.com\/plugins\/its-jira\n$ git clone https:\/\/gerrit.googlesource.com\/plugins\/its-base\n$ bazel build plugins\/its-jira\n<\/pre>\n<p><strong>The output can be normally found in the following directory:<\/strong><\/p>\n<pre>bazel-genfiles\/plugins\/its-jira\/its-jira.jar<\/pre>\n<p># Some plugins describe their build process in src\/main\/resources\/Documentation\/build.md file. It may worth checking.<\/p>\n<p># Some plugins cane be build using maven as well<\/p>\n<p><strong>Reference<\/strong><\/p>\n<ul>\n<li>https:\/\/gerrit-review.googlesource.com\/Documentation\/dev-bazel.html<\/li>\n<li>https:\/\/gerrit.googlesource.com\/gerrit\/<\/li>\n<li>https:\/\/gerrit-review.googlesource.com\/Documentation\/cmd-plugin-install.html<\/li>\n<li>https:\/\/gerrit-review.googlesource.com\/Documentation\/dev-build-plugins.html<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>To build Gerrit Plugins from source, you need: A Linux or macOS system (Windows is not supported at this time) zip, unzip, wget $yum install zip -y $ yum install&#8230; <\/p>\n","protected":false},"author":1,"featured_media":8506,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4994],"tags":[5007,91,3420,945,1076],"class_list":["post-5171","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gerrit","tag-bazel","tag-build","tag-compile","tag-gerrit","tag-plugins"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=5171"}],"version-history":[{"count":14,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5171\/revisions"}],"predecessor-version":[{"id":8507,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5171\/revisions\/8507"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/8506"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=5171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=5171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=5171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}