aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2017-07-20 16:33:37 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-08-07 11:44:06 +0200
commitdd380b60b61eb5de47051a746d0141b8250e5560 (patch)
tree3755bfa1f53d60343f145859f6fbe44d853ee6b0 /sonar-scanner-engine
parent882a48ee26c694880eabdacaa4a0bfc031a9990d (diff)
downloadsonarqube-dd380b60b61eb5de47051a746d0141b8250e5560.tar.gz
sonarqube-dd380b60b61eb5de47051a746d0141b8250e5560.zip
SONAR-9586 Run incremental task when sonar.incremental=true
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java11
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java14
2 files changed, 23 insertions, 2 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java
index 477bd4d2d83..32d3b81b141 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/task/TaskContainer.java
@@ -70,14 +70,21 @@ public class TaskContainer extends ComponentContainer {
@Override
public void doAfterStart() {
- // default value is declared in CorePlugin
String taskKey = StringUtils.defaultIfEmpty(taskProperties.get(CoreProperties.TASK), CoreProperties.SCAN_TASK);
+ boolean incremental = "true".equals(taskProperties.get("sonar.incremental"));
+ if (CoreProperties.SCAN_TASK.equals(taskKey) && incremental) {
+ taskKey = "incremental";
+ }
// Release memory
taskProperties.clear();
TaskDefinition def = getComponentByType(Tasks.class).definition(taskKey);
if (def == null) {
- throw MessageException.of("Task '" + taskKey + "' does not exist. Please use '" + ListTask.KEY + "' task to see all available tasks.");
+ if (incremental) {
+ throw MessageException.of("Incremental mode is not available. Please contact your administrator.");
+ } else {
+ throw MessageException.of("Task '" + taskKey + "' does not exist. Please use '" + ListTask.KEY + "' task to see all available tasks.");
+ }
}
Task task = getComponentByType(def.taskClass());
if (task != null) {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
index 2739b76e23e..ea3ffc3737d 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/tasks/TasksMediumTest.java
@@ -94,6 +94,20 @@ public class TasksMediumTest {
.execute();
}
+ @Test
+ public void incrementalNotFound() throws Exception {
+ tester.start();
+
+ thrown.expect(MessageException.class);
+ thrown.expectMessage(
+ "Incremental mode is not available. Please contact your administrator.");
+
+ tester.newTask()
+ .properties(ImmutableMap.<String, String>builder()
+ .put("sonar.incremental", "true").build())
+ .start();
+ }
+
private static class FakeTaskPlugin extends SonarPlugin {
@Override