diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index b05095dd3c..1ac1afba09 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt @@ -2556,10 +2556,21 @@ Polygerrit) can be deployed without the overhead of JAR packaging. For more information refer to link:cmd-plugin-install.html[plugin install] command. -Plugins can also be copied directly into the server's -directory at `$site_path/plugins/$name.(jar|js|html)`. The name of -the file, minus the `.jar`, `.js` or `.html` extension, will be used -as the plugin name. Unless disabled, servers periodically scan this +Plugins can also be copied directly into the server's directory at +`$site_path/plugins/$name.(jar|js|html)`. For Web UI plugins, the name +of the file, minus the `.js` or `.html` extension, will be used as the +plugin name. For JAR plugins, the value of the `Gerrit-PluginName` +manifest attribute will be used, if provided, otherwise the name of +the file, minus the `.jar` extension, will be used. + +For Web UI plugins, the plugin version is derived from the filename. +If the filename contains one or more hyphens, the version is taken +from the portion following the last hyphen. For example if the plugin +filename is `my-plugin-1.0.js` the version will be `1.0`. For JAR +plugins, the version is taken from the `Version` attribute in the +manifest. + +Unless disabled, servers periodically scan the `$site_path/plugins` directory for updated plugins. The time can be adjusted by link:config-gerrit.html#plugins.checkFrequency[plugins.checkFrequency]. diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/plugin/PluginIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/plugin/PluginIT.java index 9d4ba2505d..3e1b2cb6c7 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/plugin/PluginIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/plugin/PluginIT.java @@ -46,7 +46,8 @@ public class PluginIT extends AbstractDaemonTest { RawInputUtil.create(HTML_PLUGIN.getBytes(UTF_8)); private static final List PLUGINS = - ImmutableList.of("plugin-a.js", "plugin-b.html", "plugin-c.js", "plugin-d.html"); + ImmutableList.of( + "plugin-a.js", "plugin-b.html", "plugin-c.js", "plugin-d.html", "plugin_e.js"); @Test @GerritConfig(name = "plugins.allowRemoteAdmin", value = "true") @@ -65,6 +66,7 @@ public class PluginIT extends AbstractDaemonTest { PluginInfo info = api.get(); String name = pluginName(plugin); assertThat(info.id).isEqualTo(name); + assertThat(info.version).isEqualTo(pluginVersion(plugin)); assertThat(info.indexUrl).isEqualTo(String.format("plugins/%s/", name)); assertThat(info.disabled).isNull(); } @@ -78,12 +80,12 @@ public class PluginIT extends AbstractDaemonTest { assertPlugins(list().prefix("PLUGIN-").get(), ImmutableList.of()); // With substring - assertPlugins(list().substring("lugin-").get(), PLUGINS); + assertPlugins(list().substring("lugin-").get(), PLUGINS.subList(0, PLUGINS.size() - 1)); assertPlugins(list().substring("lugin-").start(1).limit(2).get(), PLUGINS.subList(1, 3)); // With regex assertPlugins(list().regex(".*in-b").get(), ImmutableList.of("plugin-b.html")); - assertPlugins(list().regex("plugin-.*").get(), PLUGINS); + assertPlugins(list().regex("plugin-.*").get(), PLUGINS.subList(0, PLUGINS.size() - 1)); assertPlugins(list().regex("plugin-.*").start(1).limit(2).get(), PLUGINS.subList(1, 3)); // Invalid match combinations @@ -135,6 +137,12 @@ public class PluginIT extends AbstractDaemonTest { return plugin.substring(0, dot); } + private String pluginVersion(String plugin) { + String name = pluginName(plugin); + int dash = name.lastIndexOf("-"); + return dash > 0 ? name.substring(dash + 1) : ""; + } + private void assertBadRequest(ListRequest req) throws Exception { try { req.get();