aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java')
-rw-r--r--sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java b/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java
index b7583de..c4013f6 100644
--- a/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java
+++ b/sonar-runner-api/src/main/java/org/sonar/runner/api/Runner.java
@@ -19,10 +19,14 @@
*/
package org.sonar.runner.api;
+import org.apache.commons.io.IOUtils;
import org.sonar.runner.impl.InternalProperties;
import javax.annotation.Nullable;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
import java.util.Properties;
/**
@@ -87,7 +91,26 @@ public abstract class Runner<T extends Runner> {
initDefaultValues();
new SourceEncoding().init(this);
new Dirs().init(this);
- doExecute();
+ String dumpToFile = properties.getProperty(InternalProperties.RUNNER_DUMP_TO_FILE);
+ if (dumpToFile != null) {
+ File dumpFile = new File(dumpToFile);
+ writeProperties(dumpFile);
+ System.out.println("Simulation mode. Configuration written to " + dumpFile.getAbsolutePath());
+ } else {
+ doExecute();
+ }
+ }
+
+ private void writeProperties(File outputFile) {
+ OutputStream output = null;
+ try {
+ output = new FileOutputStream(outputFile);
+ properties().store(output, "Generated by sonar-runner");
+ } catch (Exception e) {
+ throw new IllegalStateException("Fail to export sonar-runner properties", e);
+ } finally {
+ IOUtils.closeQuietly(output);
+ }
}
protected abstract void doExecute();