]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4047 Maven command line properties were not passed to Sonar Runner
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 20 Jun 2013 15:21:30 +0000 (17:21 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 20 Jun 2013 15:23:56 +0000 (17:23 +0200)
sonar-maven-plugin/src/main/java/org/sonar/maven/SonarMojo.java

index 0a184927385e723918bbb8bf6cb14ad321b8b392..f5b18848593e7c49cf6487520059ecc42e36bc43 100644 (file)
@@ -38,8 +38,6 @@ import org.sonar.runner.api.ScanProperties;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Map.Entry;
-import java.util.Set;
 
 /**
  * @goal sonar
@@ -130,11 +128,11 @@ public final class SonarMojo extends AbstractMojo {
   public void execute() throws MojoExecutionException, MojoFailureException {
 
     EmbeddedRunner runner = EmbeddedRunner.create()
-        .setApp("Maven", getMavenVersion());
-    Set<Entry<Object, Object>> properties = project.getModel().getProperties().entrySet();
-    for (Entry<Object, Object> entry : properties) {
-      runner.setProperty(toString(entry.getKey()), toString(entry.getValue()));
-    }
+        .setApp("Maven", getMavenVersion())
+        .addProperties(session.getExecutionProperties())
+        .addProperties(project.getModel().getProperties())
+        // Add user properties (ie command line arguments -Dsonar.xxx=yyyy) in last position to override all other
+        .addProperties(session.getUserProperties());
     String encoding = getSourceEncoding(project);
     if (encoding != null) {
       runner.setProperty(ScanProperties.PROJECT_SOURCE_ENCODING, encoding);