aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-runner-api/src/main/java/org/sonar/runner/api/EmbeddedRunner.java
diff options
context:
space:
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.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);
+ }
}
}