aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-06-16 17:38:52 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-06-19 17:08:54 +0200
commitf2e74b6d6935082e4d75a5ddfaf66e8ba1079f1f (patch)
treeddecebafb089a6a2518aa96a3fcbd03b852ec13c /sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java
parente4ba9869d57dc4dd92648b5c8406d26fcd550d46 (diff)
downloadsonar-scanner-cli-f2e74b6d6935082e4d75a5ddfaf66e8ba1079f1f.tar.gz
sonar-scanner-cli-f2e74b6d6935082e4d75a5ddfaf66e8ba1079f1f.zip
SONARUNNER-138 Allow to redirect logs to a custom stream
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.java28
1 files changed, 23 insertions, 5 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 9dfad19..e1c04b7 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,13 +19,15 @@
*/
package org.sonar.runner.api;
+import org.sonar.home.log.LogListener;
+
+import org.sonar.runner.impl.Logs;
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;
/**
@@ -36,9 +38,9 @@ import java.util.Properties;
* @since 2.2
*/
public class EmbeddedRunner extends Runner<EmbeddedRunner> {
-
private final IsolatedLauncherFactory launcherFactory;
private IsolatedLauncher launcher;
+ private String sqVersion;
private final List<Object> extensions = new ArrayList<Object>();
private static final String MASK_RULES_PROP = "sonarRunner.maskRules";
@@ -53,6 +55,11 @@ public class EmbeddedRunner extends Runner<EmbeddedRunner> {
return new EmbeddedRunner(new IsolatedLauncherFactory());
}
+ public static EmbeddedRunner create(LogListener logListener) {
+ Logs.setListener(logListener);
+ return new EmbeddedRunner(new IsolatedLauncherFactory());
+ }
+
/**
* Sonar is executed in an almost fully isolated classloader (mask everything by default). This method allows to unmask some classes based on
* a prefix of their fully qualified name. It is related to the extensions provided by {@link #addExtensions(Object...)}.
@@ -104,16 +111,27 @@ public class EmbeddedRunner extends Runner<EmbeddedRunner> {
@Override
protected void doStart() {
launcher = launcherFactory.createLauncher(globalProperties());
- launcher.start(globalProperties(), extensions);
+ if (Utils.isAtLeast52(launcher.getVersion())) {
+ launcher.start(globalProperties(), extensions, Logs.getListener());
+ }
}
@Override
protected void doStop() {
- launcher.stop();
+ if (Utils.isAtLeast52(launcher.getVersion())) {
+ launcher.stop();
+ }
}
@Override
protected void doExecute(Properties analysisProperties) {
- launcher.execute(analysisProperties);
+ if (Utils.isAtLeast52(launcher.getVersion())) {
+ launcher.execute(analysisProperties);
+ } else {
+ Properties prop = new Properties();
+ prop.putAll(globalProperties());
+ prop.putAll(analysisProperties);
+ launcher.executeOldVersion(prop, extensions);
+ }
}
}