diff options
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap')
11 files changed, 35 insertions, 79 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java index 94536420f0c..48f4d5a14d5 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/BatchComponents.java @@ -22,7 +22,6 @@ package org.sonar.scanner.bootstrap; import com.google.common.collect.Lists; import java.util.Collection; import java.util.List; -import org.sonar.api.batch.AnalysisMode; import org.sonar.core.component.DefaultResourceTypes; import org.sonar.core.config.CorePropertyDefinitions; import org.sonar.core.issue.tracking.Tracker; @@ -49,7 +48,7 @@ public class BatchComponents { // only static stuff } - public static Collection<Object> all(AnalysisMode analysisMode) { + public static Collection<Object> all(GlobalAnalysisMode analysisMode) { List<Object> components = Lists.newArrayList( DefaultResourceTypes.get(), diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java index 97366e2179d..a25a44f8597 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ExtensionInstaller.java @@ -24,7 +24,6 @@ import javax.annotation.Nullable; import org.sonar.api.ExtensionProvider; import org.sonar.api.Plugin; import org.sonar.api.SonarRuntime; -import org.sonar.api.batch.AnalysisMode; import org.sonar.core.platform.ComponentContainer; import org.sonar.core.platform.PluginInfo; import org.sonar.core.platform.PluginRepository; @@ -33,9 +32,9 @@ public class ExtensionInstaller { private final SonarRuntime sonarRuntime; private final PluginRepository pluginRepository; - private final AnalysisMode analysisMode; + private final GlobalAnalysisMode analysisMode; - public ExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository, AnalysisMode analysisMode) { + public ExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository, GlobalAnalysisMode analysisMode) { this.sonarRuntime = sonarRuntime; this.pluginRepository = pluginRepository; this.analysisMode = analysisMode; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractAnalysisMode.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java index d9ba1203e42..a6dddc7f92e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/AbstractAnalysisMode.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalAnalysisMode.java @@ -20,33 +20,30 @@ package org.sonar.scanner.bootstrap; import java.util.Arrays; +import javax.annotation.concurrent.Immutable; import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.sonar.api.CoreProperties; -import org.sonar.api.batch.AnalysisMode; -public abstract class AbstractAnalysisMode implements AnalysisMode { - - private static final String[] VALID_MODES = {CoreProperties.ANALYSIS_MODE_PREVIEW, CoreProperties.ANALYSIS_MODE_PUBLISH, CoreProperties.ANALYSIS_MODE_ISSUES}; +@Immutable +public class GlobalAnalysisMode { public static final String MEDIUM_TEST_ENABLED = "sonar.mediumTest.enabled"; + private static final Logger LOG = LoggerFactory.getLogger(GlobalAnalysisMode.class); + private static final String[] VALID_MODES = {CoreProperties.ANALYSIS_MODE_PREVIEW, CoreProperties.ANALYSIS_MODE_PUBLISH, CoreProperties.ANALYSIS_MODE_ISSUES}; protected boolean preview; protected boolean issues; protected boolean mediumTestMode; - protected AbstractAnalysisMode() { - } - - @Override public boolean isPreview() { return preview; } - @Override public boolean isIssues() { return issues; } - @Override public boolean isPublish() { return !preview && !issues; } @@ -70,4 +67,20 @@ public abstract class AbstractAnalysisMode implements AnalysisMode { } + public GlobalAnalysisMode(GlobalProperties props) { + String mode = props.property(CoreProperties.ANALYSIS_MODE); + validate(mode); + issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode) || CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode); + mediumTestMode = "true".equals(props.property(MEDIUM_TEST_ENABLED)); + if (preview) { + LOG.debug("Preview mode"); + } else if (issues) { + LOG.debug("Issues mode"); + } else { + LOG.debug("Publish mode"); + } + if (mediumTestMode) { + LOG.info("Medium test mode"); + } + } } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java index 336d0ce73ff..b41cf7d4f0b 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfiguration.java @@ -26,7 +26,6 @@ import javax.annotation.concurrent.Immutable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.CoreProperties; -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.config.Encryption; import org.sonar.api.config.PropertyDefinitions; import org.sonar.scanner.config.DefaultConfiguration; @@ -48,7 +47,7 @@ public class GlobalConfiguration extends DefaultConfiguration { private final Map<String, String> serverSideSettings; - public GlobalConfiguration(PropertyDefinitions propertyDefinitions, Encryption encryption, AnalysisMode mode, + public GlobalConfiguration(PropertyDefinitions propertyDefinitions, Encryption encryption, GlobalAnalysisMode mode, Map<String, String> settings, Map<String, String> serverSideSettings) { super(propertyDefinitions, encryption, mode, settings); this.serverSideSettings = serverSideSettings; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java index 26467a6e5df..46a591b75b1 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalConfigurationProvider.java @@ -29,7 +29,7 @@ public class GlobalConfigurationProvider extends ProviderAdapter { private GlobalConfiguration globalSettings; - public GlobalConfiguration provide(SettingsLoader loader, GlobalProperties globalProps, PropertyDefinitions propertyDefinitions, GlobalMode mode) { + public GlobalConfiguration provide(SettingsLoader loader, GlobalProperties globalProps, PropertyDefinitions propertyDefinitions, GlobalAnalysisMode mode) { if (globalSettings == null) { Map<String, String> serverSideSettings = loader.load(null); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java index 259058a7163..94dbe459a7c 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalContainer.java @@ -65,7 +65,7 @@ public class GlobalContainer extends ComponentContainer { @Override protected void doBeforeStart() { GlobalProperties bootstrapProps = new GlobalProperties(bootstrapProperties); - GlobalMode globalMode = new GlobalMode(bootstrapProps); + GlobalAnalysisMode globalMode = new GlobalAnalysisMode(bootstrapProps); add(bootstrapProps); add(globalMode); addBootstrapComponents(); diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalMode.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalMode.java deleted file mode 100644 index df217760051..00000000000 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/GlobalMode.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.scanner.bootstrap; - -import javax.annotation.concurrent.Immutable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonar.api.CoreProperties; - -@Immutable -public class GlobalMode extends AbstractAnalysisMode { - private static final Logger LOG = LoggerFactory.getLogger(GlobalMode.class); - - public GlobalMode(GlobalProperties props) { - String mode = props.property(CoreProperties.ANALYSIS_MODE); - validate(mode); - issues = CoreProperties.ANALYSIS_MODE_ISSUES.equals(mode) || CoreProperties.ANALYSIS_MODE_PREVIEW.equals(mode); - mediumTestMode = "true".equals(props.property(MEDIUM_TEST_ENABLED)); - if (preview) { - LOG.debug("Preview global mode"); - } else if (issues) { - LOG.debug("Issues global mode"); - } else { - LOG.debug("Publish global mode"); - } - if (mediumTestMode) { - LOG.info("Medium test mode"); - } - } - - @Override - public boolean isIncremental() { - throw new UnsupportedOperationException(); - } - -} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MutableGlobalSettings.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MutableGlobalSettings.java index e31ce436394..b3355a89228 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MutableGlobalSettings.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/MutableGlobalSettings.java @@ -22,7 +22,6 @@ package org.sonar.scanner.bootstrap; import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.sonar.api.batch.AnalysisMode; import org.sonar.api.config.Settings; import org.sonar.api.utils.MessageException; @@ -32,7 +31,7 @@ import org.sonar.api.utils.MessageException; @Deprecated public class MutableGlobalSettings extends Settings { - private final AnalysisMode mode; + private final GlobalAnalysisMode mode; private final Map<String, String> mutableProperties = new HashMap<>(); public MutableGlobalSettings(GlobalConfiguration globalSettings) { diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginPredicate.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginPredicate.java index dc39f5c0ced..a219abe87aa 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginPredicate.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerPluginPredicate.java @@ -47,9 +47,9 @@ public class ScannerPluginPredicate implements Predicate<String> { private final Set<String> whites = new HashSet<>(); private final Set<String> blacks = new HashSet<>(); - private final GlobalMode mode; + private final GlobalAnalysisMode mode; - public ScannerPluginPredicate(Configuration settings, GlobalMode mode) { + public ScannerPluginPredicate(Configuration settings, GlobalAnalysisMode mode) { this.mode = mode; if (mode.isPreview() || mode.isIssues()) { // These default values are not supported by Settings because the class CorePlugin diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClient.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClient.java index 19e0169e182..6ec0eaac6dc 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClient.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClient.java @@ -50,9 +50,9 @@ public class ScannerWsClient { private final WsClient target; private final boolean hasCredentials; - private final GlobalMode globalMode; + private final GlobalAnalysisMode globalMode; - public ScannerWsClient(WsClient target, boolean hasCredentials, GlobalMode globalMode) { + public ScannerWsClient(WsClient target, boolean hasCredentials, GlobalAnalysisMode globalMode) { this.target = target; this.hasCredentials = hasCredentials; this.globalMode = globalMode; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java index 3ffd9275d39..51d0b4c50e5 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/ScannerWsClientProvider.java @@ -39,7 +39,7 @@ public class ScannerWsClientProvider extends ProviderAdapter { private ScannerWsClient wsClient; - public synchronized ScannerWsClient provide(final GlobalProperties settings, final EnvironmentInformation env, GlobalMode globalMode) { + public synchronized ScannerWsClient provide(final GlobalProperties settings, final EnvironmentInformation env, GlobalAnalysisMode globalMode) { if (wsClient == null) { String url = defaultIfBlank(settings.property("sonar.host.url"), CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE); HttpConnector.Builder connectorBuilder = HttpConnector.newBuilder(); |