use of org.sonar.api.utils.Version in project sonarqube by SonarSource.
the class DatabaseChecker method checkMinDatabaseVersion.
private void checkMinDatabaseVersion() throws SQLException {
Version minDbVersion = MINIMAL_SUPPORTED_DB_VERSIONS.get(db.getDialect().getId());
if (minDbVersion != null) {
try (Connection connection = db.getDataSource().getConnection()) {
int dbMajorVersion = connection.getMetaData().getDatabaseMajorVersion();
int dbMinorVersion = connection.getMetaData().getDatabaseMinorVersion();
Version dbVersion = Version.create(dbMajorVersion, dbMinorVersion, 0);
if (dbVersion.compareTo(minDbVersion) < 0) {
throw MessageException.of(String.format("Unsupported %s version: %s. Minimal supported version is %s.", db.getDialect().getId(), dbVersion, minDbVersion));
}
}
}
}
use of org.sonar.api.utils.Version in project sonarqube by SonarSource.
the class SonarQubeVersionTest method isGte.
@Test
public void isGte() {
Version version = Version.parse("1.2.3");
SonarQubeVersion qubeVersion = new SonarQubeVersion(version);
assertThat(qubeVersion.get()).isEqualTo(version);
assertThat(qubeVersion.isGreaterThanOrEqual(version)).isTrue();
assertThat(qubeVersion.isGreaterThanOrEqual(Version.parse("1.1"))).isTrue();
assertThat(qubeVersion.isGreaterThanOrEqual(Version.parse("1.3"))).isFalse();
}
use of org.sonar.api.utils.Version in project sonarqube by SonarSource.
the class ApiVersionTest method load_version_from_file_in_classpath.
@Test
public void load_version_from_file_in_classpath() {
Version version = ApiVersion.load(System2.INSTANCE);
assertThat(version).isNotNull();
assertThat(version.major()).isGreaterThanOrEqualTo(5);
}
use of org.sonar.api.utils.Version in project sonarlint-core by SonarSource.
the class StorageContainer method doBeforeStart.
@Override
protected void doBeforeStart() {
Version version = ApiVersion.load(System2.INSTANCE);
add(StorageContainerHandler.class, // storage directories and tmp
StoragePaths.class, StorageReader.class, new GlobalTempFolderProvider(), // plugins
PluginRepository.class, PluginCacheLoader.class, PluginVersionChecker.class, PluginLoader.class, PluginClassloaderFactory.class, DefaultPluginJarExploder.class, StoragePluginIndexProvider.class, new PluginCacheProvider(), // storage readers
AllModulesReader.class, IssueStoreReader.class, GlobalUpdateStatusReader.class, ModuleStorageStatusReader.class, StorageRuleDetailsReader.class, IssueStoreFactory.class, // analysis
StorageAnalyzer.class, StorageFileExclusions.class, // needed during analysis (immutable)
UriReader.class, ExtensionInstaller.class, new StorageRulesProvider(), new StorageQProfilesProvider(), new SonarQubeRulesProvider(), new SonarQubeVersion(version), SonarRuntimeImpl.forSonarLint(version), System2.INSTANCE);
}
Aggregations