use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class CePluginJarExploderTest method explode_jar_to_temp_directory.
@Test
public void explode_jar_to_temp_directory() throws Exception {
PluginInfo info = PluginInfo.create(plugin1Jar());
ExplodedPlugin exploded = underTest.explode(info);
// all the files loaded by classloaders (JAR + META-INF/libs/*.jar) are copied to a dedicated temp directory
File copiedJar = exploded.getMain();
assertThat(exploded.getKey()).isEqualTo("test");
assertThat(copiedJar).isFile().exists();
assertThat(copiedJar.getParentFile()).isDirectory().hasName("test");
assertThat(copiedJar.getParentFile().getParentFile()).isDirectory().hasName("ce-exploded-plugins");
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class CePluginJarExploderTest method explode_is_reentrant.
@Test
public void explode_is_reentrant() throws Exception {
PluginInfo info = PluginInfo.create(plugin1Jar());
ExplodedPlugin exploded1 = underTest.explode(info);
long dirSize1 = sizeOfDirectory(exploded1.getMain().getParentFile());
ExplodedPlugin exploded2 = underTest.explode(info);
long dirSize2 = sizeOfDirectory(exploded2.getMain().getParentFile());
assertThat(exploded2.getMain().getCanonicalPath()).isEqualTo(exploded1.getMain().getCanonicalPath());
assertThat(dirSize1).isEqualTo(dirSize2);
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class CePluginRepository method start.
@Override
public void start() {
Loggers.get(getClass()).info("Load plugins");
for (File file : listJarFiles(fs.getInstalledPluginsDir())) {
PluginInfo info = PluginInfo.create(file);
pluginInfosByKeys.put(info.getKey(), info);
}
pluginInstancesByKeys.putAll(loader.load(pluginInfosByKeys));
started.set(true);
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class PluginsMonitor method attributes.
@Override
public Map<String, Object> attributes() {
Map<String, Object> attributes = new LinkedHashMap<>();
for (PluginInfo plugin : repository.getPluginInfos()) {
LinkedHashMap<String, Object> pluginAttributes = new LinkedHashMap<>();
pluginAttributes.put("Name", plugin.getName());
Version version = plugin.getVersion();
if (version != null) {
pluginAttributes.put("Version", version.getName());
}
attributes.put(plugin.getKey(), pluginAttributes);
}
return attributes;
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class ServerExtensionInstaller method installExtensions.
public void installExtensions(ComponentContainer container) {
ListMultimap<PluginInfo, Object> installedExtensionsByPlugin = ArrayListMultimap.create();
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
try {
String pluginKey = pluginInfo.getKey();
Plugin plugin = pluginRepository.getPluginInstance(pluginKey);
container.addExtension(pluginInfo, plugin);
Plugin.Context context = new Plugin.Context(sonarRuntime);
plugin.define(context);
for (Object extension : context.getExtensions()) {
if (installExtension(container, pluginInfo, extension, true) != null) {
installedExtensionsByPlugin.put(pluginInfo, extension);
} else {
container.declareExtension(pluginInfo, extension);
}
}
} catch (Throwable e) {
// catch Throwable because we want to catch Error too (IncompatibleClassChangeError, ...)
throw new IllegalStateException(String.format("Fail to load plugin %s [%s]", pluginInfo.getName(), pluginInfo.getKey()), e);
}
}
for (Map.Entry<PluginInfo, Object> entry : installedExtensionsByPlugin.entries()) {
PluginInfo pluginInfo = entry.getKey();
try {
Object extension = entry.getValue();
if (isExtensionProvider(extension)) {
ExtensionProvider provider = (ExtensionProvider) container.getComponentByKey(extension);
installProvider(container, pluginInfo, provider);
}
} catch (Throwable e) {
// catch Throwable because we want to catch Error too (IncompatibleClassChangeError, ...)
throw new IllegalStateException(String.format("Fail to load plugin %s [%s]", pluginInfo.getName(), pluginInfo.getKey()), e);
}
}
}
Aggregations