diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-03-14 15:49:22 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-03-14 15:49:22 +0100 |
commit | 8e7ffed1b130c47fe5ac394b4f5c78dd901bff1b (patch) | |
tree | aee2f7cf51e711f85493df84ddf2d65bed6cd7f3 /sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java | |
parent | 6f752d47dbf6438e73e86acdf8d481102b04ce73 (diff) | |
download | sonarqube-8e7ffed1b130c47fe5ac394b4f5c78dd901bff1b.tar.gz sonarqube-8e7ffed1b130c47fe5ac394b4f5c78dd901bff1b.zip |
SONAR-4069 fix task extension point
Diffstat (limited to 'sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java index 7afac65e0ed..bc50ede3ea2 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java @@ -19,6 +19,8 @@ */ package org.sonar.batch.bootstrap; +import org.sonar.api.CoreProperties; +import org.sonar.api.config.Settings; import org.sonar.api.platform.ComponentContainer; import org.sonar.api.resources.ResourceTypes; import org.sonar.api.task.Task; @@ -27,8 +29,6 @@ import org.sonar.api.task.TaskExtension; import org.sonar.api.utils.SonarException; import org.sonar.batch.tasks.Tasks; -import javax.annotation.Nullable; - public class TaskContainer extends ComponentContainer { public TaskContainer(ComponentContainer parent) { @@ -41,23 +41,24 @@ public class TaskContainer extends ComponentContainer { installComponentsUsingTaskExtensions(); } - public void executeTask(@Nullable String key) { + public void execute() { startComponents(); - TaskDefinition taskDef = get(Tasks.class).getTaskDefinition(key); - if (taskDef != null) { - Task task = get(taskDef.getTask()); - if (task != null) { - task.execute(); - } else { - throw new IllegalStateException("Command " + key + " is badly defined."); - } + // default value is declared in CorePlugin + String taskKey = get(Settings.class).getString(CoreProperties.TASK); + + TaskDefinition def = get(Tasks.class).definition(taskKey); + if (def == null) { + throw new SonarException("Task " + taskKey + " does not exist."); + } + Task task = get(def.taskClass()); + if (task != null) { + task.execute(); } else { - throw new SonarException("Command " + key + " does not exist."); + throw new IllegalStateException("Task " + taskKey + " is badly defined."); } } - private void installTaskExtensions() { get(ExtensionInstaller.class).install(this, new ExtensionInstaller.ComponentFilter() { public boolean accept(Object extension) { |