本文整理了Java中org.sonar.api.utils.Version.toString()
方法的一些代码示例,展示了Version.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.toString()
方法的具体详情如下:
包路径:org.sonar.api.utils.Version
类名称:Version
方法名:toString
暂无
代码示例来源:origin: SonarSource/sonarqube
@Override
public String getVersion() {
return runtime.getApiVersion().toString();
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public String getVersion() {
return runtime.getApiVersion().toString();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void test_toString() {
assertThat(parse("1").toString()).isEqualTo("1.0");
assertThat(parse("1.2").toString()).isEqualTo("1.2");
assertThat(parse("1.2.3").toString()).isEqualTo("1.2.3");
assertThat(parse("1.2-b1").toString()).isEqualTo("1.2-b1");
assertThat(parse("1.2.3-b1").toString()).isEqualTo("1.2.3-b1");
assertThat(parse("1.2.3.4567").toString()).isEqualTo("1.2.3.4567");
assertThat(parse("1.2.3.4567-beta1").toString()).isEqualTo("1.2.3.4567-beta1");
// do not display zero numbers when possible
assertThat(parse("1.2.0.0").toString()).isEqualTo("1.2");
assertThat(parse("1.2.0.1").toString()).isEqualTo("1.2.0.1");
assertThat(parse("1.2.1.0").toString()).isEqualTo("1.2.1");
assertThat(parse("1.2.1.0-beta").toString()).isEqualTo("1.2.1-beta");
}
代码示例来源: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
@Test
public void test_getVersion() {
Version version = Version.create(6, 1);
when(runtime.getApiVersion()).thenReturn(version);
assertThat(underTest.getVersion()).isEqualTo(version.toString());
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, FilterChain chain) {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
ServletRequest wsRequest = new ServletRequest(request);
ServletResponse wsResponse = new ServletResponse(response);
wsResponse.setHeader("Sonar-Version", runtime.getApiVersion().toString());
webServiceEngine.execute(wsRequest, wsResponse);
}
代码示例来源:origin: SonarSource/sonarqube
/**
* @return a {@link OkHttpClient} singleton
*/
public OkHttpClient provide(Configuration config, SonarRuntime runtime) {
if (okHttpClient == null) {
OkHttpClientBuilder builder = new OkHttpClientBuilder();
builder.setConnectTimeoutMs(DEFAULT_CONNECT_TIMEOUT_IN_MS);
builder.setReadTimeoutMs(DEFAULT_READ_TIMEOUT_IN_MS);
// no need to define proxy URL as system-wide proxy is used and properly
// configured by bootstrap process.
builder.setProxyLogin(config.get(HTTP_PROXY_USER.getKey()).orElse(null));
builder.setProxyPassword(config.get(HTTP_PROXY_PASSWORD.getKey()).orElse(null));
builder.setUserAgent(format("SonarQube/%s", runtime.getApiVersion().toString()));
okHttpClient = builder.build();
}
return okHttpClient;
}
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void test_create() {
assertVersion(Version.create(1, 2), 1, 2, 0, 0, "");
assertVersion(Version.create(1, 2, 3), 1, 2, 3, 0, "");
assertVersion(Version.create(1, 2, 0, ""), 1, 2, 0, 0, "");
assertVersion(Version.create(1, 2, 3, "build1"), 1, 2, 3, 0, "build1");
assertThat(Version.create(1, 2, 3, "build1").toString()).isEqualTo("1.2.3-build1");
}
代码示例来源:origin: SonarSource/sonarqube
if (!plugin.isCompatibleWith(runtime.getApiVersion().toString())) {
throw MessageException.of(format(
"Plugin %s [%s] requires at least SonarQube %s", plugin.getName(), plugin.getKey(), plugin.getMinimalSqVersion()));
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
@Override
public String getVersion() {
return runtime.getApiVersion().toString();
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-scanner-engine
@Override
public String getVersion() {
return runtime.getApiVersion().toString();
}
代码示例来源:origin: SonarSource/sonarlint-core
@Override
public String getVersion() {
return runtime.getApiVersion().toString();
}
代码示例来源:origin: Riverside-Software/sonar-openedge
private void executeAnalytics(SensorContext context) {
if (!settings.useAnalytics())
return;
StringBuilder data = new StringBuilder(String.format( // NOSONAR Influx requires LF
"proparse,product=%1$s,sid=%2$s files=%3$d,failures=%4$d,parseTime=%5$d,maxParseTime=%6$d,version=\"%7$s\",ncloc=%8$d\n",
context.runtime().getProduct().toString().toLowerCase(), OpenEdgeProjectHelper.getServerId(context), numFiles,
numFailures, parseTime, maxParseTime, context.runtime().getApiVersion().toString(), ncLocs));
for (Entry<String, Long> entry : ruleTime.entrySet()) {
data.append(String.format("rule,product=%1$s,sid=%2$s,rulename=%3$s ruleTime=%4$d\n", // NOSONAR
context.runtime().getProduct().toString().toLowerCase(), OpenEdgeProjectHelper.getServerId(context),
entry.getKey(), entry.getValue()));
}
try {
final URL url = new URL("http://sonar-analytics.rssw.eu/write?db=sonar");
HttpURLConnection connx = (HttpURLConnection) url.openConnection();
connx.setRequestMethod("POST");
connx.setConnectTimeout(2000);
connx.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connx.getOutputStream());
wr.writeBytes(data.toString());
wr.flush();
wr.close();
connx.getResponseCode();
} catch (IOException uncaught) {
LOG.debug("Unable to send analytics: {}", uncaught.getMessage());
}
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
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: org.sonarsource.sonarqube/sonar-server
@Override
public void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, FilterChain chain) {
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
ServletRequest wsRequest = new ServletRequest(request);
ServletResponse wsResponse = new ServletResponse(response);
wsResponse.setHeader("Sonar-Version", runtime.getApiVersion().toString());
webServiceEngine.execute(wsRequest, wsResponse);
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
/**
* @return a {@link OkHttpClient} singleton
*/
public OkHttpClient provide(Configuration config, SonarRuntime runtime) {
if (okHttpClient == null) {
OkHttpClientBuilder builder = new OkHttpClientBuilder();
builder.setConnectTimeoutMs(DEFAULT_CONNECT_TIMEOUT_IN_MS);
builder.setReadTimeoutMs(DEFAULT_READ_TIMEOUT_IN_MS);
// no need to define proxy URL as system-wide proxy is used and properly
// configured by bootstrap process.
builder.setProxyLogin(config.get(HTTP_PROXY_USER.getKey()).orElse(null));
builder.setProxyPassword(config.get(HTTP_PROXY_PASSWORD.getKey()).orElse(null));
builder.setUserAgent(format("SonarQube/%s", runtime.getApiVersion().toString()));
okHttpClient = builder.build();
}
return okHttpClient;
}
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-server
if (!plugin.isCompatibleWith(runtime.getApiVersion().toString())) {
throw MessageException.of(format(
"Plugin %s [%s] requires at least SonarQube %s", plugin.getName(), plugin.getKey(), plugin.getMinimalSqVersion()));
内容来源于网络,如有侵权,请联系作者删除!