| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 1 | Gerrit Code Review - Plugin Development |
| 2 | ======================================= |
| 3 | |
| 4 | A plugin in gerrit is tightly coupled code that runs in the same |
| 5 | JVM as gerrit. It has full access to all gerrit internals. Plugins |
| 6 | are coupled to a specific major.minor gerrit version. |
| 7 | |
| Nasser Grainawi | e033b26 | 2012-05-09 17:54:21 -0700 | [diff] [blame^] | 8 | Requirements |
| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 9 | ------------ |
| 10 | |
| Nasser Grainawi | e033b26 | 2012-05-09 17:54:21 -0700 | [diff] [blame^] | 11 | To start development, download the sample maven project, which downloads the |
| 12 | following dependencies: |
| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 13 | |
| Nasser Grainawi | e033b26 | 2012-05-09 17:54:21 -0700 | [diff] [blame^] | 14 | * gerrit-sdk.jar file that matches the war file to develop against |
| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 15 | |
| 16 | |
| 17 | Manifest |
| 18 | -------- |
| 19 | |
| Nasser Grainawi | e033b26 | 2012-05-09 17:54:21 -0700 | [diff] [blame^] | 20 | Plugins need to include the following data in the jar manifest file: |
| 21 | |
| 22 | Gerrit-Module = pkg.class |
| 23 | |
| 24 | Optionally include: |
| 25 | |
| 26 | Gerrit-ReloadMode = 'reload' (default) or 'restart' |
| 27 | |
| 28 | If the plugin holds an exclusive resource that must be released before loading |
| 29 | the plugin again, ReloadMode must be set to 'restart'. Otherwise 'reload' is |
| 30 | sufficient. |
| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 31 | |
| 32 | SSH Commands |
| 33 | ------------ |
| 34 | |
| Nasser Grainawi | e033b26 | 2012-05-09 17:54:21 -0700 | [diff] [blame^] | 35 | Plugins may provide commands that can be accessed through the SSH interface. |
| 36 | These commands register themselves as a part of link:cmd-index.html[SSH Commands]. |
| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 37 | |
| Nasser Grainawi | e033b26 | 2012-05-09 17:54:21 -0700 | [diff] [blame^] | 38 | Each of the plugin commands needs to extend SshCommand. |
| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 39 | |
| Nasser Grainawi | e033b26 | 2012-05-09 17:54:21 -0700 | [diff] [blame^] | 40 | Any plugin which implements at least one ssh command needs to also provide a |
| 41 | class which extends the PluginCommandModule in order to register the ssh |
| 42 | command(s) in its configure method which must be overriden. |
| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 43 | |
| Nasser Grainawi | e033b26 | 2012-05-09 17:54:21 -0700 | [diff] [blame^] | 44 | Registering is done by calling: |
| 45 | |
| 46 | command(String commandName).to(ClassName<? extends SshCommand> klass) |
| 47 | |
| 48 | Documentation |
| 49 | ------------- |
| 50 | |
| 51 | Place files into Documentation/ or static/ and package them into the plugin jar |
| 52 | to access them in a browser via <canonicalWebURL>/plugins/<pluginName>/... |
| 53 | |
| 54 | Deployment |
| 55 | ---------- |
| 56 | |
| 57 | Deploy plugins into <review_site>/plugins/. The file name in that directory will |
| 58 | be the plugin name on the server. |
| Deniz Türkoglu | eb78b60 | 2012-05-07 14:02:36 -0700 | [diff] [blame] | 59 | |
| 60 | GERRIT |
| 61 | ------ |
| 62 | Part of link:index.html[Gerrit Code Review] |