org.sonar.updatecenter.common.Version类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中org.sonar.updatecenter.common.Version类的一些代码示例,展示了Version类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version类的具体详情如下:
包路径:org.sonar.updatecenter.common.Version
类名称:Version

Version介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

private static Version version(String version) {
 return Version.create(version);
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * Find out if this plugin is compatible with a given version of SonarQube.
 * The version of SQ must be greater than or equal to the minimal version
 * needed by the plugin.
 */
public boolean isCompatibleWith(String runtimeVersion) {
 if (null == this.minimalSqVersion) {
  // no constraint defined on the plugin
  return true;
 }
 Version effectiveMin = Version.create(minimalSqVersion.getName()).removeQualifier();
 Version effectiveVersion = Version.create(runtimeVersion).removeQualifier();
 if (runtimeVersion.endsWith("-SNAPSHOT")) {
  // check only the major and minor versions (two first fields)
  effectiveMin = Version.create(effectiveMin.getMajor() + "." + effectiveMin.getMinor());
 }
 return effectiveVersion.compareTo(effectiveMin) >= 0;
}

代码示例来源:origin: SonarSource/sonarqube

def.setSelfFirstStrategy(info.isUseChildFirstClassLoader());
Version minSqVersion = info.getMinimalSqVersion();
boolean compatibilityMode = minSqVersion != null && minSqVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0;
if (compatibilityMode) {
 Loggers.get(getClass()).warn("API compatibility mode is no longer supported. In case of error, plugin {} [{}] should package its dependencies.",

代码示例来源:origin: SonarSource/sonarqube

public static RequiredPlugin parse(String s) {
 if (!PARSER.matcher(s).matches()) {
  throw new IllegalArgumentException("Manifest field does not have correct format: " + s);
 }
 String[] fields = StringUtils.split(s, ':');
 return new RequiredPlugin(fields[0], Version.create(fields[1]).removeQualifier());
}

代码示例来源:origin: SonarSource/sonarqube

@Override
 public String toString() {
  return new StringBuilder().append(key).append(':').append(minimalVersion.getName()).toString();
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public int hashCode() {
 int result = key.hashCode();
 result = 31 * result + (version != null ? version.hashCode() : 0);
 return result;
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public boolean equals(@Nullable Object o) {
 if (this == o) {
  return true;
 }
 if (o == null || getClass() != o.getClass()) {
  return false;
 }
 PluginInfo info = (PluginInfo) o;
 if (!key.equals(info.key)) {
  return false;
 }
 return !(version != null ? !version.equals(info.version) : info.version != null);
}

代码示例来源:origin: SonarSource/sonarqube

public void download(String pluginKey, Version version) {
 Optional<UpdateCenter> updateCenter = updateCenterMatrixFactory.getUpdateCenter(true);
 if (updateCenter.isPresent()) {
  List<Release> installablePlugins = updateCenter.get().findInstallablePlugins(pluginKey, version);
  checkRequest(!installablePlugins.isEmpty(), "Error while downloading plugin '%s' with version '%s'. No compatible plugin found.", pluginKey, version.getName());
  for (Release release : installablePlugins) {
   try {
    downloadRelease(release);
   } catch (Exception e) {
    String message = String.format("Fail to download the plugin (%s, version %s) from %s (error is : %s)",
     release.getArtifact().getKey(), release.getVersion().getName(), release.getDownloadUrl(), e.getMessage());
    LOG.debug(message, e);
    throw new IllegalStateException(message, e);
   }
  }
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-core

public static RequiredPlugin parse(String s) {
 if (!PARSER.matcher(s).matches()) {
  throw new IllegalArgumentException("Manifest field does not have correct format: " + s);
 }
 String[] fields = StringUtils.split(s, ':');
 return new RequiredPlugin(fields[0], Version.create(fields[1]).removeQualifier());
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-core

@Override
public int hashCode() {
 int result = key.hashCode();
 result = 31 * result + (version != null ? version.hashCode() : 0);
 return result;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-core

@Override
public boolean equals(@Nullable Object o) {
 if (this == o) {
  return true;
 }
 if (o == null || getClass() != o.getClass()) {
  return false;
 }
 PluginInfo info = (PluginInfo) o;
 if (!key.equals(info.key)) {
  return false;
 }
 return !(version != null ? !version.equals(info.version) : info.version != null);
}

代码示例来源:origin: SonarSource/sonarqube

protected static Release release(Plugin plugin1, String version) {
 return new Release(plugin1, create(version));
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-core

/**
 * Find out if this plugin is compatible with a given version of SonarQube.
 * The version of SQ must be greater than or equal to the minimal version
 * needed by the plugin.
 */
public boolean isCompatibleWith(String runtimeVersion) {
 if (null == this.minimalSqVersion) {
  // no constraint defined on the plugin
  return true;
 }
 Version effectiveMin = Version.create(minimalSqVersion.getName()).removeQualifier();
 Version effectiveVersion = Version.create(runtimeVersion).removeQualifier();
 if (runtimeVersion.endsWith("-SNAPSHOT")) {
  // check only the major and minor versions (two first fields)
  effectiveMin = Version.create(effectiveMin.getMajor() + "." + effectiveMin.getMinor());
 }
 return effectiveVersion.compareTo(effectiveMin) >= 0;
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test_RequiredPlugin() {
 PluginInfo.RequiredPlugin plugin = PluginInfo.RequiredPlugin.parse("java:1.1");
 assertThat(plugin.getKey()).isEqualTo("java");
 assertThat(plugin.getMinimalVersion().getName()).isEqualTo("1.1");
 assertThat(plugin.toString()).isEqualTo("java:1.1");
 assertThat(plugin.equals(PluginInfo.RequiredPlugin.parse("java:1.2"))).isTrue();
 assertThat(plugin.equals(PluginInfo.RequiredPlugin.parse("php:1.2"))).isFalse();
 try {
  PluginInfo.RequiredPlugin.parse("java");
  fail();
 } catch (IllegalArgumentException expected) {
  // ok
 }
}

代码示例来源:origin: SonarSource/sonarqube

if (installedRequirementVersion != null && requiredPlugin.getMinimalVersion().compareToIgnoreQualifier(installedRequirementVersion) > 0) {

代码示例来源:origin: SonarSource/sonarqube

PluginInfo withMinSqVersion(@Nullable String version) {
  PluginInfo pluginInfo = new PluginInfo("foo");
  if (version != null) {
   pluginInfo.setMinimalSqVersion(Version.create(version));
  }
  return pluginInfo;
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
 public ProtobufSystemInfo.Section toProtobuf() {
  ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
  protobuf.setName("Plugins");
  for (PluginInfo plugin : repository.getPluginInfos()) {
   String label = "[" + plugin.getName() + "]";
   Version version = plugin.getVersion();
   if (version != null) {
    label = version.getName() + " " + label;
   }
   setAttribute(protobuf, plugin.getKey(), label);
  }
  return protobuf.build();
 }
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-core

def.setSelfFirstStrategy(info.isUseChildFirstClassLoader());
Version minSqVersion = info.getMinimalSqVersion();
boolean compatibilityMode = minSqVersion != null && minSqVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0;
if (compatibilityMode) {
 Loggers.get(getClass()).warn("API compatibility mode is no longer supported. In case of error, plugin {} [{}] should package its dependencies.",

代码示例来源:origin: SonarSource/sonarqube

public Optional<UpdateCenter> getUpdateCenter(boolean refreshUpdateCenter) {
  Optional<UpdateCenter> updateCenter = centerClient.getUpdateCenter(refreshUpdateCenter);
  if (updateCenter.isPresent()) {
   org.sonar.api.utils.Version fullVersion = sonarRuntime.getApiVersion();
   org.sonar.api.utils.Version semanticVersion = org.sonar.api.utils.Version.create(fullVersion.major(), fullVersion.minor(), fullVersion.patch());

   return Optional.of(updateCenter.get().setInstalledSonarVersion(Version.create(semanticVersion.toString())).registerInstalledPlugins(
    installedPluginReferentialFactory.getInstalledPluginReferential())
    .setDate(centerClient.getLastRefreshDate()));
  }
  return Optional.absent();
 }
}

代码示例来源:origin: SonarSource/sonarqube

private static void writeMetadata(JsonWriter jsonWriter, Release release) {
 jsonWriter.prop(PROPERTY_VERSION, VersionFormatter.format(release.getVersion().getName()));
 jsonWriter.prop(PROPERTY_DESCRIPTION, release.getDescription());
 jsonWriter.propDate(PROPERTY_RELEASE_DATE, release.getDate());
 jsonWriter.prop(PROPERTY_CHANGE_LOG_URL, release.getChangelogUrl());
 jsonWriter.prop(PROPERTY_DOWNLOAD_URL, release.getDownloadUrl());
}

相关文章