aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-scanner-engine/src/main')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java24
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java12
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java1
4 files changed, 30 insertions, 13 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java
index dfdfa2f9f1d..27f11deacfd 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/config/DefaultConfiguration.java
@@ -47,12 +47,14 @@ public abstract class DefaultConfiguration implements Configuration {
private final Encryption encryption;
private final GlobalAnalysisMode mode;
private final Map<String, String> properties;
+ private final Map<String, String> originalProperties;
public DefaultConfiguration(PropertyDefinitions propertyDefinitions, Encryption encryption, GlobalAnalysisMode mode, Map<String, String> props) {
this.definitions = requireNonNull(propertyDefinitions);
this.encryption = encryption;
this.mode = mode;
this.properties = unmodifiableMapWithTrimmedValues(definitions, props);
+ this.originalProperties = Collections.unmodifiableMap(props);
}
protected static Map<String, String> unmodifiableMapWithTrimmedValues(PropertyDefinitions definitions, Map<String, String> props) {
@@ -80,6 +82,10 @@ public abstract class DefaultConfiguration implements Configuration {
return properties;
}
+ public Map<String, String> getOriginalProperties() {
+ return originalProperties;
+ }
+
@Override
public boolean hasKey(String key) {
return properties.containsKey(key);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java
index b9a1579f027..5fbfff5d25b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java
@@ -28,11 +28,11 @@ import java.util.stream.Collectors;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Configuration;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
+import org.sonar.scanner.config.DefaultConfiguration;
import static java.util.Arrays.asList;
import static org.sonar.api.CoreProperties.CATEGORY_CODE_COVERAGE;
@@ -63,9 +63,9 @@ public class GenericCoverageSensor implements Sensor {
@Deprecated
static final String OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY = "sonar.genericcoverage.overallReportPaths";
- private final Configuration config;
+ private final DefaultConfiguration config;
- public GenericCoverageSensor(Configuration config) {
+ public GenericCoverageSensor(DefaultConfiguration config) {
this.config = config;
}
@@ -77,18 +77,26 @@ public class GenericCoverageSensor implements Sensor {
.description("List of comma-separated paths (absolute or relative) containing coverage report.")
.category(CATEGORY_CODE_COVERAGE)
.onQualifiers(Qualifiers.PROJECT)
+ .multiValues(true)
.deprecatedKey(OLD_COVERAGE_REPORT_PATHS_PROPERTY_KEY)
.build());
}
- private void loadDeprecated(Set<String> reportPaths, String propertyKey) {
- if (config.hasKey(propertyKey)) {
+ private void loadArrayDeprecated(Set<String> reportPaths, String propertyKey) {
+ if (config.getOriginalProperties().containsKey(propertyKey)) {
LOG.warn("Property '{}' is deprecated. Please use '{}' instead.", propertyKey, REPORT_PATHS_PROPERTY_KEY);
reportPaths.addAll(Arrays.asList(config.getStringArray(propertyKey)));
}
}
+ private void loadDeprecated(Set<String> reportPaths, String propertyKey) {
+ if (config.getOriginalProperties().containsKey(propertyKey)) {
+ LOG.warn("Property '{}' is deprecated. Please use '{}' instead.", propertyKey, REPORT_PATHS_PROPERTY_KEY);
+ config.get(propertyKey).ifPresent(reportPaths::add);
+ }
+ }
+
@Override
public void describe(SensorDescriptor descriptor) {
descriptor.name("Generic Coverage Report")
@@ -120,9 +128,9 @@ public class GenericCoverageSensor implements Sensor {
Set<String> reportPaths = new LinkedHashSet<>();
reportPaths.addAll(Arrays.asList(config.getStringArray(REPORT_PATHS_PROPERTY_KEY)));
loadDeprecated(reportPaths, OLD_REPORT_PATH_PROPERTY_KEY);
- loadDeprecated(reportPaths, OLD_COVERAGE_REPORT_PATHS_PROPERTY_KEY);
- loadDeprecated(reportPaths, OLD_IT_COVERAGE_REPORT_PATHS_PROPERTY_KEY);
- loadDeprecated(reportPaths, OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY);
+ loadArrayDeprecated(reportPaths, OLD_COVERAGE_REPORT_PATHS_PROPERTY_KEY);
+ loadArrayDeprecated(reportPaths, OLD_IT_COVERAGE_REPORT_PATHS_PROPERTY_KEY);
+ loadArrayDeprecated(reportPaths, OLD_OVERALL_COVERAGE_REPORT_PATHS_PROPERTY_KEY);
return reportPaths;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java
index b44fdb3591e..3b9fe583ce1 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java
@@ -29,6 +29,7 @@ import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
+import org.sonar.scanner.config.DefaultConfiguration;
import org.sonar.scanner.deprecated.test.TestPlanBuilder;
import static org.sonar.api.CoreProperties.CATEGORY_CODE_COVERAGE;
@@ -45,9 +46,11 @@ public class GenericTestExecutionSensor implements Sensor {
static final String OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY = "sonar.genericcoverage.unitTestReportPaths";
private final TestPlanBuilder testPlanBuilder;
+ private final DefaultConfiguration configuration;
- public GenericTestExecutionSensor(TestPlanBuilder testPlanBuilder) {
+ public GenericTestExecutionSensor(TestPlanBuilder testPlanBuilder, DefaultConfiguration configuration) {
this.testPlanBuilder = testPlanBuilder;
+ this.configuration = configuration;
}
public static ImmutableList<PropertyDefinition> properties() {
@@ -58,9 +61,9 @@ public class GenericTestExecutionSensor implements Sensor {
.description("List of comma-separated paths (absolute or relative) containing unit tests results report.")
.category(CATEGORY_CODE_COVERAGE)
.onQualifiers(Qualifiers.PROJECT)
+ .multiValues(true)
.deprecatedKey(OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY)
.build());
-
}
@Override
@@ -71,10 +74,11 @@ public class GenericTestExecutionSensor implements Sensor {
@Override
public void execute(SensorContext context) {
- if (context.settings().hasKey(OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY)) {
+ if (configuration.getOriginalProperties().containsKey(OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY)) {
LOG.warn("Property '{}' is deprecated. Please use '{}' instead.", OLD_UNIT_TEST_REPORT_PATHS_PROPERTY_KEY, REPORT_PATHS_PROPERTY_KEY);
}
- for (String reportPath : context.settings().getStringArray(REPORT_PATHS_PROPERTY_KEY)) {
+
+ for (String reportPath : configuration.getStringArray(REPORT_PATHS_PROPERTY_KEY)) {
File reportFile = context.fileSystem().resolvePath(reportPath);
LOG.info("Parsing {}", reportFile);
GenericTestExecutionReportParser parser = new GenericTestExecutionReportParser(testPlanBuilder);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
index a44ac36b0ec..af9ea941f51 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
@@ -21,7 +21,6 @@ package org.sonar.scanner.scan;
import com.google.common.annotations.VisibleForTesting;
import javax.annotation.Nullable;
-import org.apache.commons.lang.StringUtils;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.InstantiationStrategy;
import org.sonar.api.batch.fs.internal.DefaultInputModule;