use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class ServerPluginRepository method appendDependentPluginKeys.
private void appendDependentPluginKeys(String pluginKey, Set<String> appendTo) {
for (PluginInfo otherPlugin : pluginInfosByKeys.values()) {
if (!otherPlugin.getKey().equals(pluginKey)) {
for (PluginInfo.RequiredPlugin requirement : otherPlugin.getRequiredPlugins()) {
if (requirement.getKey().equals(pluginKey)) {
appendTo.add(otherPlugin.getKey());
appendDependentPluginKeys(otherPlugin.getKey(), appendTo);
}
}
}
}
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class ServerPluginRepository method overrideAndRegisterPlugin.
/**
* Move or copy plugin to directory extensions/plugins. If a version of this plugin
* already exists then it's deleted.
*/
private void overrideAndRegisterPlugin(File sourceFile, boolean deleteSource) {
File destDir = fs.getInstalledPluginsDir();
File destFile = new File(destDir, sourceFile.getName());
if (destFile.exists()) {
// plugin with same filename already installed
deleteQuietly(destFile);
}
try {
if (deleteSource) {
moveFile(sourceFile, destFile);
} else {
copyFile(sourceFile, destFile, true);
}
} catch (IOException e) {
throw new IllegalStateException(format("Fail to move or copy plugin: %s to %s", sourceFile.getAbsolutePath(), destFile.getAbsolutePath()), e);
}
PluginInfo info = PluginInfo.create(destFile);
PluginInfo existing = pluginInfosByKeys.put(info.getKey(), info);
if (existing != null) {
if (!existing.getNonNullJarFile().getName().equals(destFile.getName())) {
deleteQuietly(existing.getNonNullJarFile());
}
LOG.info("Plugin {} [{}] updated to version {}", info.getName(), info.getKey(), info.getVersion());
} else {
LOG.info("Plugin {} [{}] installed", info.getName(), info.getKey());
}
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class ServerPluginRepository method getPluginInfo.
@Override
public PluginInfo getPluginInfo(String key) {
checkState(started.get(), NOT_STARTED_YET);
PluginInfo info = pluginInfosByKeys.get(key);
if (info == null) {
throw new IllegalArgumentException(format("Plugin [%s] does not exist", key));
}
return info;
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class PluginWSCommons method writePluginInfoList.
public void writePluginInfoList(JsonWriter json, Iterable<PluginInfo> plugins, Map<String, Plugin> compatiblePluginsByKey, String propertyName) {
json.name(propertyName);
json.beginArray();
for (PluginInfo pluginInfo : copyOf(NAME_KEY_PLUGIN_METADATA_COMPARATOR, plugins)) {
Plugin plugin = compatiblePluginsByKey.get(pluginInfo.getKey());
writePluginInfo(json, pluginInfo, categoryOrNull(plugin));
}
json.endArray();
}
use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.
the class InstalledPluginsAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
JsonWriter json = response.newJsonWriter().beginArray();
for (PluginInfo pluginInfo : pluginRepository.getPluginInfos()) {
Version version = pluginInfo.getVersion();
json.beginObject().prop("key", pluginInfo.getKey()).prop("name", pluginInfo.getName());
if (version != null) {
json.prop("version", version.getName());
}
json.endObject();
}
json.endArray().close();
}
Aggregations