diff options
-rw-r--r-- | src/main/java/org/sonar/runner/Main.java | 14 | ||||
-rw-r--r-- | src/test/java/org/sonar/runner/MainTest.java | 3 |
2 files changed, 9 insertions, 8 deletions
diff --git a/src/main/java/org/sonar/runner/Main.java b/src/main/java/org/sonar/runner/Main.java index 5321345..698ab3e 100644 --- a/src/main/java/org/sonar/runner/Main.java +++ b/src/main/java/org/sonar/runner/Main.java @@ -69,12 +69,16 @@ public final class Main { private void execute(String[] args) { Stats stats = new Stats().start(); try { - loadProperties(args); - Runner runner = Runner.create(command, globalProperties, projectProperties); + Properties argsProperties = parseArguments(args); Logs.info("Runner version: " + Version.getVersion()); Logs.info("Java version: " + System.getProperty("java.version", "<unknown>") + ", vendor: " + System.getProperty("java.vendor", "<unknown>")); Logs.info("OS name: \"" + System.getProperty("os.name") + "\", version: \"" + System.getProperty("os.version") + "\", arch: \"" + System.getProperty("os.arch") + "\""); + if (displayVersionOnly) { + return; + } + loadProperties(argsProperties); + Runner runner = Runner.create(command, globalProperties, projectProperties); Logs.info("Default locale: \"" + Locale.getDefault() + "\", source code encoding: \"" + runner.getSourceCodeEncoding() + "\"" + (runner.isEncodingPlatformDependant() ? " (analysis is platform dependent)" : "")); if (debugMode) { @@ -87,9 +91,6 @@ public final class Main { } catch (IOException e) { throw new RunnerException(e); } - if (displayVersionOnly) { - return; - } runner.execute(); } finally { stats.stop(); @@ -97,8 +98,7 @@ public final class Main { } @VisibleForTesting - void loadProperties(String[] args) { - Properties argsProperties = parseArguments(args); + void loadProperties(Properties argsProperties) { globalProperties = loadGlobalProperties(argsProperties); projectProperties = loadProjectProperties(argsProperties); } diff --git a/src/test/java/org/sonar/runner/MainTest.java b/src/test/java/org/sonar/runner/MainTest.java index 4c76883..495f212 100644 --- a/src/test/java/org/sonar/runner/MainTest.java +++ b/src/test/java/org/sonar/runner/MainTest.java @@ -89,10 +89,11 @@ public class MainTest { File runnerHome = new File(getClass().getResource("/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/runner").toURI()); File projectHome = new File(getClass().getResource("/org/sonar/runner/MainTest/shouldLoadCompleteConfiguration/project").toURI()); Main main = new Main(); - main.loadProperties(new String[] { + Properties args = main.parseArguments(new String[] { "-D", "runner.home=" + runnerHome.getCanonicalPath(), "-D", "project.home=" + projectHome.getCanonicalPath() }); + main.loadProperties(args); assertThat(main.projectProperties.getProperty("project.prop")).isEqualTo("foo"); assertThat(main.projectProperties.getProperty("overridden.prop")).isEqualTo("project scope"); |