]> source.dussan.org Git - sonar-scanner-cli.git/commitdiff
SONARPLUGINS-1220 command-line properties must override global and project settings
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 27 Jun 2011 10:36:46 +0000 (10:36 +0000)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 27 Jun 2011 10:36:46 +0000 (10:36 +0000)
src/main/java/org/sonar/runner/Main.java

index 1eb8b77f11d6872d7372fb3b911384745cd9036e..832009040ac8121d3cc39fb60da4672e637fdf10 100644 (file)
@@ -51,11 +51,15 @@ public final class Main {
   }
 
   static Properties loadProperties(String[] args) {
-    Properties props = parseArguments(args);
-    props.putAll(System.getProperties());
-    props.putAll(loadRunnerProperties(props));
-    props.putAll(loadProjectProperties(props));
-    return props;
+    Properties commandLineProps = new Properties();
+    commandLineProps.putAll(System.getProperties());
+    commandLineProps.putAll(parseArguments(args));
+
+    Properties result = new Properties();
+    result.putAll(loadRunnerProperties(commandLineProps));
+    result.putAll(loadProjectProperties(commandLineProps));
+    result.putAll(commandLineProps);
+    return result;
   }
 
   static Properties loadRunnerProperties(Properties props) {
@@ -69,7 +73,7 @@ public final class Main {
 
   static Properties loadProjectProperties(Properties props) {
     File settingsFile = locatePropertiesFile(props, "project.home", "sonar-project.properties", "project.settings");
-    if (settingsFile.isFile() && settingsFile.exists()) {
+    if (settingsFile!=null && settingsFile.isFile() && settingsFile.exists()) {
       log("Project settings: " + settingsFile.getAbsolutePath());
       return toProperties(settingsFile);
     }