use of org.sonar.updatecenter.common.Version 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.updatecenter.common.Version in project sonarqube by SonarSource.
the class ServerPluginRepository method isCompatible.
@VisibleForTesting
static boolean isCompatible(PluginInfo plugin, SonarRuntime runtime, Map<String, PluginInfo> allPluginsByKeys) {
if (Strings.isNullOrEmpty(plugin.getMainClass()) && Strings.isNullOrEmpty(plugin.getBasePlugin())) {
LOG.warn("Plugin {} [{}] is ignored because entry point class is not defined", plugin.getName(), plugin.getKey());
return false;
}
if (!plugin.isCompatibleWith(runtime.getApiVersion().toString())) {
throw MessageException.of(format("Plugin %s [%s] requires at least SonarQube %s", plugin.getName(), plugin.getKey(), plugin.getMinimalSqVersion()));
}
if (!Strings.isNullOrEmpty(plugin.getBasePlugin()) && !allPluginsByKeys.containsKey(plugin.getBasePlugin())) {
// it extends a plugin that is not installed
LOG.warn("Plugin {} [{}] is ignored because its base plugin [{}] is not installed", plugin.getName(), plugin.getKey(), plugin.getBasePlugin());
return false;
}
for (PluginInfo.RequiredPlugin requiredPlugin : plugin.getRequiredPlugins()) {
PluginInfo installedRequirement = allPluginsByKeys.get(requiredPlugin.getKey());
if (installedRequirement == null) {
// it requires a plugin that is not installed
LOG.warn("Plugin {} [{}] is ignored because the required plugin [{}] is not installed", plugin.getName(), plugin.getKey(), requiredPlugin.getKey());
return false;
}
Version installedRequirementVersion = installedRequirement.getVersion();
if (installedRequirementVersion != null && requiredPlugin.getMinimalVersion().compareToIgnoreQualifier(installedRequirementVersion) > 0) {
// it requires a more recent version
LOG.warn("Plugin {} [{}] is ignored because the version {} of required plugin [{}] is not supported", plugin.getName(), plugin.getKey(), requiredPlugin.getKey(), requiredPlugin.getMinimalVersion());
return false;
}
}
return true;
}
use of org.sonar.updatecenter.common.Version in project sonarqube by SonarSource.
the class PluginWSCommons method writePluginInfo.
void writePluginInfo(JsonWriter json, PluginInfo pluginInfo, @Nullable String category) {
json.beginObject();
json.prop(PROPERTY_KEY, pluginInfo.getKey());
json.prop(PROPERTY_NAME, pluginInfo.getName());
json.prop(PROPERTY_DESCRIPTION, pluginInfo.getDescription());
Version version = pluginInfo.getVersion();
if (version != null) {
String functionalVersion = isNotBlank(pluginInfo.getDisplayVersion()) ? pluginInfo.getDisplayVersion() : version.getName();
json.prop(PROPERTY_VERSION, functionalVersion);
}
json.prop(PROPERTY_CATEGORY, category);
json.prop(PROPERTY_LICENSE, pluginInfo.getLicense());
json.prop(PROPERTY_ORGANIZATION_NAME, pluginInfo.getOrganizationName());
json.prop(PROPERTY_ORGANIZATION_URL, pluginInfo.getOrganizationUrl());
json.prop(PROPERTY_HOMEPAGE_URL, pluginInfo.getHomepageUrl());
json.prop(PROPERTY_ISSUE_TRACKER_URL, pluginInfo.getIssueTrackerUrl());
json.prop(PROPERTY_IMPLEMENTATION_BUILD, pluginInfo.getImplementationBuild());
json.endObject();
}
use of org.sonar.updatecenter.common.Version in project sonarqube by SonarSource.
the class PluginReferentialMetadataConverter method toPluginManifest.
private static PluginManifest toPluginManifest(PluginInfo metadata) {
PluginManifest pluginManifest = new PluginManifest();
pluginManifest.setKey(metadata.getKey());
pluginManifest.setName(metadata.getName());
Version version = metadata.getVersion();
if (version != null) {
pluginManifest.setVersion(version.getName());
}
pluginManifest.setDescription(metadata.getDescription());
pluginManifest.setMainClass(metadata.getMainClass());
pluginManifest.setOrganization(metadata.getOrganizationName());
pluginManifest.setOrganizationUrl(metadata.getOrganizationUrl());
pluginManifest.setLicense(metadata.getLicense());
pluginManifest.setHomepage(metadata.getHomepageUrl());
pluginManifest.setIssueTrackerUrl(metadata.getIssueTrackerUrl());
pluginManifest.setBasePlugin(metadata.getBasePlugin());
pluginManifest.setRequirePlugins(Collections2.transform(metadata.getRequiredPlugins(), RequiredPluginToString.INSTANCE).toArray(new String[metadata.getRequiredPlugins().size()]));
return pluginManifest;
}
use of org.sonar.updatecenter.common.Version 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