throw new UnsupportedOperationException();
}
- @Override
- public File getBundledPluginsDir() {
- throw new UnsupportedOperationException();
- }
-
@Override
public File getPluginIndex() {
throw new UnsupportedOperationException();
*/
File getInstalledPluginsDir();
- /**
- * Directory of the plugins packaged by default with application. These
- * plugins are installed during the first fresh startup.
- * @return a directory which may or not exist
- */
- File getBundledPluginsDir();
-
/**
* The file listing all the installed plugins. Used by scanner only.
* @return an existing file
return new File(getHomeDir(), "extensions/plugins");
}
- @Override
- public File getBundledPluginsDir() {
- return new File(getHomeDir(), "lib/bundled-plugins");
- }
-
@Override
public File getPluginIndex() {
return new File(deployDir, "plugins/index.txt");
/**
* Entry point to install and load plugins on server startup. It manages
* <ul>
- * <li>installation of bundled plugins on first server startup</li>
* <li>installation of new plugins (effective after server startup)</li>
* <li>un-installation of plugins (effective after server startup)</li>
* <li>cancel pending installations/un-installations</li>
@Override
public void start() {
loadPreInstalledPlugins();
- copyBundledPlugins();
moveDownloadedPlugins();
moveDownloadedEditionPlugins();
unloadIncompatiblePlugins();
}
}
- /**
- * Copies the plugins bundled with SonarQube distribution to directory extensions/plugins.
- * Does nothing if not a fresh installation.
- */
- private void copyBundledPlugins() {
- if (upgradeStatus.isFreshInstall()) {
- for (File sourceFile : listJarFiles(fs.getBundledPluginsDir())) {
- PluginInfo info = PluginInfo.create(sourceFile);
- // lib/bundled-plugins should be copied only if the plugin is not already
- // available in extensions/plugins
- if (!pluginInfosByKeys.containsKey(info.getKey())) {
- overrideAndRegisterPlugin(sourceFile, false);
- }
- }
- }
- }
-
private void registerPluginInfo(PluginInfo info) {
String pluginKey = info.getKey();
if (blacklistedPluginKeys.contains(pluginKey)) {
@Before
public void setUp() throws IOException {
- when(fs.getBundledPluginsDir()).thenReturn(temp.newFolder());
when(fs.getDeployedPluginsDir()).thenReturn(temp.newFolder());
when(fs.getDownloadedPluginsDir()).thenReturn(temp.newFolder());
when(fs.getHomeDir()).thenReturn(temp.newFolder());
underTest.stop();
}
- /**
- * The first server startup (fresh db) installs bundled plugins and instantiates bundled plugins.
- */
- @Test
- public void first_startup_installs_bundled_plugins() throws Exception {
- copyTestPluginTo("test-base-plugin", fs.getBundledPluginsDir());
- when(upgradeStatus.isFreshInstall()).thenReturn(true);
-
- underTest.start();
-
- // both plugins are installed
- assertThat(underTest.getPluginInfosByKeys()).containsOnlyKeys("testbase");
- }
-
- @Test
- public void bundled_plugins_are_not_installed_if_not_fresh_server() throws Exception {
- copyTestPluginTo("test-base-plugin", fs.getBundledPluginsDir());
- when(upgradeStatus.isFreshInstall()).thenReturn(false);
-
- underTest.start();
-
- assertThat(underTest.getPluginInfos()).isEmpty();
- }
-
@Test
public void standard_startup_loads_installed_plugins() throws Exception {
copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
testCompile 'junit:junit'
testCompile 'org.assertj:assertj-core'
testCompile 'org.mockito:mockito-core'
-
}
jar {
into("${archiveDir}/lib/") {
from jar
}
- into("${archiveDir}/lib/bundled-plugins/") {
+ into("${archiveDir}/extensions/plugins/") {
from configurations.bundledPlugin
}
into("${archiveDir}/lib/jsw/") {