diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2018-11-14 22:47:35 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-01-16 09:43:01 +0100 |
commit | f594bf7568192dbfc9b9a8cf4f7c243ea4ad046b (patch) | |
tree | b4d6818199beebf97e5d4d6a10dfcebde10e7ba8 /sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper | |
parent | a0acec09a79485117ab9c8e3c67a8446224d5de9 (diff) | |
download | sonarqube-f594bf7568192dbfc9b9a8cf4f7c243ea4ad046b.tar.gz sonarqube-f594bf7568192dbfc9b9a8cf4f7c243ea4ad046b.zip |
SONAR-11465 Deprecate InputModule and introduce InputProject
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java | 57 | ||||
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java | 15 |
2 files changed, 21 insertions, 51 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java index 77195937afd..75c8725b8a8 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/Batch.java @@ -36,10 +36,9 @@ import org.sonar.scanner.bootstrap.GlobalContainer; */ public final class Batch { - private boolean started = false; private LoggingConfiguration loggingConfig; private List<Object> components; - private Map<String, String> globalProperties = new HashMap<>(); + private Map<String, String> scannerProperties = new HashMap<>(); private GlobalContainer bootstrapContainer; private Batch(Builder builder) { @@ -48,11 +47,11 @@ public final class Batch { if (builder.environment != null) { components.add(builder.environment); } - if (builder.globalProperties != null) { - globalProperties.putAll(builder.globalProperties); + if (builder.scannerProperties != null) { + scannerProperties.putAll(builder.scannerProperties); } if (builder.isEnableLoggingConfiguration()) { - loggingConfig = new LoggingConfiguration(builder.environment).setProperties(globalProperties); + loggingConfig = new LoggingConfiguration(builder.environment).setProperties(scannerProperties); if (builder.logOutput != null) { loggingConfig.setLogOutput(builder.logOutput); @@ -68,7 +67,7 @@ public final class Batch { configureLogging(); doStart(); try { - doExecuteTask(globalProperties); + doExecute(); } finally { doStop(); } @@ -81,21 +80,16 @@ public final class Batch { */ @Deprecated public synchronized Batch start() { - if (started) { - throw new IllegalStateException("Scanner Engine is already started"); - } - configureLogging(); - return doStart(); + return this; } private Batch doStart() { try { - bootstrapContainer = GlobalContainer.create(globalProperties, components); + bootstrapContainer = GlobalContainer.create(scannerProperties, components); bootstrapContainer.startComponents(); } catch (RuntimeException e) { throw handleException(e); } - this.started = true; return this; } @@ -106,26 +100,18 @@ public final class Batch { */ @Deprecated public Batch executeTask(Map<String, String> analysisProperties, Object... components) { - checkStarted(); - configureTaskLogging(analysisProperties); - return doExecuteTask(analysisProperties, components); + return execute(); } - private Batch doExecuteTask(Map<String, String> analysisProperties, Object... components) { + private Batch doExecute(Object... components) { try { - bootstrapContainer.executeTask(analysisProperties, components); + bootstrapContainer.executeTask(scannerProperties, components); } catch (RuntimeException e) { throw handleException(e); } return this; } - private void checkStarted() { - if (!started) { - throw new IllegalStateException("Scanner engine is not started. Unable to execute task."); - } - } - private RuntimeException handleException(RuntimeException t) { if (loggingConfig.isVerbose()) { return t; @@ -146,9 +132,6 @@ public final class Batch { */ @Deprecated public synchronized void stop() { - checkStarted(); - configureLogging(); - doStop(); } private void doStop() { @@ -157,19 +140,11 @@ public final class Batch { } catch (RuntimeException e) { throw handleException(e); } - this.started = false; } private void configureLogging() { if (loggingConfig != null) { - loggingConfig.setProperties(globalProperties); - LoggingConfigurator.apply(loggingConfig); - } - } - - private void configureTaskLogging(Map<String, String> taskProperties) { - if (loggingConfig != null) { - loggingConfig.setProperties(taskProperties, globalProperties); + loggingConfig.setProperties(scannerProperties); LoggingConfigurator.apply(loggingConfig); } } @@ -179,7 +154,7 @@ public final class Batch { } public static final class Builder { - private Map<String, String> globalProperties; + private Map<String, String> scannerProperties; private EnvironmentInformation environment; private List<Object> components = new ArrayList<>(); private boolean enableLoggingConfiguration = true; @@ -203,17 +178,17 @@ public final class Batch { return this; } - public Builder setGlobalProperties(Map<String, String> globalProperties) { - this.globalProperties = globalProperties; + public Builder setScannerProperties(Map<String, String> scannerProperties) { + this.scannerProperties = scannerProperties; return this; } /** - * @deprecated since 6.6 use {@link #setGlobalProperties(Map)} + * @deprecated since 6.6 use {@link #setScannerProperties(Map)} */ @Deprecated public Builder setBootstrapProperties(Map<String, String> bootstrapProperties) { - this.globalProperties = bootstrapProperties; + this.scannerProperties = bootstrapProperties; return this; } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java index 08e2236cfec..94c6175298d 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LoggingConfiguration.java @@ -66,12 +66,7 @@ public final class LoggingConfiguration { } public LoggingConfiguration setProperties(Map<String, String> properties) { - setVerbose(properties, null); - return this; - } - - public LoggingConfiguration setProperties(Map<String, String> properties, @Nullable Map<String, String> fallback) { - setVerbose(properties, fallback); + setVerbose(properties); return this; } @@ -88,10 +83,10 @@ public final class LoggingConfiguration { return verbose; } - public LoggingConfiguration setVerbose(Map<String, String> props, @Nullable Map<String, String> fallback) { - String logLevel = getFallback("sonar.log.level", props, fallback); - String deprecatedProfilingLevel = getFallback("sonar.log.profilingLevel", props, fallback); - verbose = "true".equals(getFallback("sonar.verbose", props, fallback)) || + public LoggingConfiguration setVerbose(Map<String, String> props) { + String logLevel = props.get("sonar.log.level"); + String deprecatedProfilingLevel = props.get("sonar.log.profilingLevel"); + verbose = "true".equals(props.get("sonar.verbose")) || "DEBUG".equals(logLevel) || "TRACE".equals(logLevel) || "BASIC".equals(deprecatedProfilingLevel) || "FULL".equals(deprecatedProfilingLevel); |