public void uninstall(String pluginKey) {
    if (!pluginRepository.hasPlugin(pluginKey) || pluginRepository.getPlugin(pluginKey).getType() != EXTERNAL) {
      throw new IllegalArgumentException(format("Plugin [%s] is not installed", pluginKey));
    }

    Set<String> uninstallKeys = new HashSet<>();
    uninstallKeys.add(pluginKey);
    appendDependentPluginKeys(pluginKey, uninstallKeys);

    for (String uninstallKey : uninstallKeys) {
      PluginInfo info = pluginRepository.getPluginInfo(uninstallKey);
      // we don't check type because the dependent of an external plugin should never be a bundled plugin!
      uninstall(info.getKey(), info.getName(), info.getNonNullJarFile().getName());
    }
  }
@Test
  public void uninstall() throws Exception {
    File installedJar = copyTestPluginTo("test-base-plugin", fs.getInstalledExternalPluginsDir());
    serverPluginRepository.addPlugin(newPlugin("testbase", EXTERNAL, installedJar.getName()));

    underTest.start();
    assertThat(installedJar).exists();

    underTest.uninstall("testbase");

    assertThat(installedJar).doesNotExist();
    assertThat(uninstallDir.list()).containsOnly(installedJar.getName());
  }