diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-06-15 14:59:17 +0200 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2015-06-18 17:26:05 +0200 |
commit | e4ba9869d57dc4dd92648b5c8406d26fcd550d46 (patch) | |
tree | 489e0e87f6b7df0a95095de50d0264ff355fa568 /sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java | |
parent | 5b6747b46db7fef9238e3bbaf66d2822e03d0a6e (diff) | |
download | sonar-scanner-cli-e4ba9869d57dc4dd92648b5c8406d26fcd550d46.tar.gz sonar-scanner-cli-e4ba9869d57dc4dd92648b5c8406d26fcd550d46.zip |
SONARUNNER-136 and SONARUNNER-137 - Provide a new API to run several analysis with same process and an interactive mode
Diffstat (limited to 'sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java')
-rw-r--r-- | sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java index b0366c3..9dfad19 100644 --- a/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java +++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java @@ -19,11 +19,14 @@ */ package org.sonar.runner.api; -import org.sonar.runner.impl.BatchLauncher; +import org.sonar.runner.batch.IsolatedLauncher; +import org.sonar.runner.impl.IsolatedLauncherFactory; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.Properties; /** * Implementation of {@link Runner} that is executed in the same JVM. The application can inject @@ -34,19 +37,20 @@ import java.util.List; */ public class EmbeddedRunner extends Runner<EmbeddedRunner> { - private final BatchLauncher batchLauncher; + private final IsolatedLauncherFactory launcherFactory; + private IsolatedLauncher launcher; private final List<Object> extensions = new ArrayList<Object>(); private static final String MASK_RULES_PROP = "sonarRunner.maskRules"; - EmbeddedRunner(BatchLauncher bl) { - this.batchLauncher = bl; + EmbeddedRunner(IsolatedLauncherFactory bl) { + this.launcherFactory = bl; } /** * Create a new instance. */ public static EmbeddedRunner create() { - return new EmbeddedRunner(new BatchLauncher()); + return new EmbeddedRunner(new IsolatedLauncherFactory()); } /** @@ -69,12 +73,12 @@ public class EmbeddedRunner extends Runner<EmbeddedRunner> { } private EmbeddedRunner addMaskRule(String type, String fqcnPrefix) { - String existingRules = property(MASK_RULES_PROP, ""); + String existingRules = globalProperty(MASK_RULES_PROP, ""); if (!"".equals(existingRules)) { existingRules += ","; } existingRules += type + "|" + fqcnPrefix; - return setProperty(MASK_RULES_PROP, existingRules); + return setGlobalProperty(MASK_RULES_PROP, existingRules); } /** @@ -98,7 +102,18 @@ public class EmbeddedRunner extends Runner<EmbeddedRunner> { } @Override - protected void doExecute() { - batchLauncher.execute(properties(), extensions); + protected void doStart() { + launcher = launcherFactory.createLauncher(globalProperties()); + launcher.start(globalProperties(), extensions); + } + + @Override + protected void doStop() { + launcher.stop(); + } + + @Override + protected void doExecute(Properties analysisProperties) { + launcher.execute(analysisProperties); } } |