Search in sources :

Example 6 with Version

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));
            }
        }
    }
}
Also used : Version(org.sonar.api.utils.Version) Connection(java.sql.Connection)

Example 7 with Version

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();
}
Also used : Version(org.sonar.api.utils.Version) Test(org.junit.Test)

Example 8 with Version

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);
}
Also used : Version(org.sonar.api.utils.Version) Test(org.junit.Test)

Example 9 with Version

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);
}
Also used : SonarQubeVersion(org.sonar.api.SonarQubeVersion) Version(org.sonar.api.utils.Version) SonarQubeVersion(org.sonar.api.SonarQubeVersion) ApiVersion(org.sonar.api.internal.ApiVersion) GlobalTempFolderProvider(org.sonarsource.sonarlint.core.container.global.GlobalTempFolderProvider) PluginCacheProvider(org.sonarsource.sonarlint.core.plugin.cache.PluginCacheProvider)

Aggregations

Version (org.sonar.api.utils.Version)9 SonarQubeVersion (org.sonar.api.SonarQubeVersion)4 ApiVersion (org.sonar.api.internal.ApiVersion)4 Test (org.junit.Test)3 GlobalTempFolderProvider (org.sonarsource.sonarlint.core.container.global.GlobalTempFolderProvider)2 PluginCacheProvider (org.sonarsource.sonarlint.core.plugin.cache.PluginCacheProvider)2 Connection (java.sql.Connection)1 MetricsRepositoryProvider (org.sonar.scanner.repository.MetricsRepositoryProvider)1 LogServerVersion (org.sonar.server.platform.LogServerVersion)1 TempFolderProvider (org.sonar.server.platform.TempFolderProvider)1 OkHttpClientProvider (org.sonar.server.util.OkHttpClientProvider)1