]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6060 Fix regression with JSON report
authorJulien HENRY <julien.henry@sonarsource.com>
Tue, 20 Jan 2015 14:23:20 +0000 (15:23 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 20 Jan 2015 14:23:40 +0000 (15:23 +0100)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/JSONReport.java
sonar-batch/src/main/java/org/sonar/batch/user/UserRepository.java

index 71580c29ad0b1bd00c8df2fdac873c570a0a300d..9040b071b1abdd49724c9e30fe2624b3325fdd1e 100644 (file)
@@ -176,12 +176,6 @@ import java.util.List;
     global = true, project = false,
     defaultValue = CoreProperties.PREVIEW_EXCLUDE_PLUGINS_DEFAULT_VALUE,
     category = CoreProperties.CATEGORY_GENERAL),
-  @Property(
-    key = "sonar.report.export.path",
-    defaultValue = "sonar-report.json",
-    name = "Report Results Export File",
-    type = PropertyType.STRING,
-    global = false, project = false),
 
   // SERVER-SIDE TECHNICAL PROPERTIES
 
index 42c78ea50ba63805cc42adb2d4ebaf7c51af3f89..333a041f13f3d733cd1507fa184eca873d76b605 100644 (file)
@@ -31,6 +31,7 @@ import org.sonar.batch.maven.MavenProjectBootstrapper;
 import org.sonar.batch.maven.MavenProjectBuilder;
 import org.sonar.batch.maven.MavenProjectConverter;
 import org.sonar.batch.scan.report.ConsoleReport;
+import org.sonar.batch.scan.report.JSONReport;
 import org.sonar.batch.scm.ScmConfiguration;
 import org.sonar.batch.scm.ScmSensor;
 import org.sonar.batch.source.LinesSensor;
@@ -67,6 +68,7 @@ public class BatchComponents {
 
       // Reports
       ConsoleReport.class,
+      JSONReport.class,
 
       // dbcleaner
       DefaultPeriodCleaner.class,
index 786886364825e593c5f09898a01bff19e2ec98be..043507a6db4c168d18087595dd78b838be5b4b20 100644 (file)
@@ -24,6 +24,9 @@ import com.google.common.base.Charsets;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputDir;
 import org.sonar.api.batch.fs.InputFile;
@@ -56,8 +59,16 @@ import java.util.Set;
 
 import static com.google.common.collect.Sets.newHashSet;
 
+@Properties({
+  @Property(
+    key = JSONReport.SONAR_REPORT_EXPORT_PATH,
+    defaultValue = "sonar-report.json",
+    name = "Report Results Export File",
+    type = PropertyType.STRING,
+    global = false, project = false)})
 public class JSONReport implements Reporter {
 
+  static final String SONAR_REPORT_EXPORT_PATH = "sonar.report.export.path";
   private static final Logger LOG = LoggerFactory.getLogger(JSONReport.class);
   private final Settings settings;
   private final FileSystem fileSystem;
@@ -82,7 +93,7 @@ public class JSONReport implements Reporter {
 
   @Override
   public void execute() {
-    String exportPath = settings.getString("sonar.report.export.path");
+    String exportPath = settings.getString(SONAR_REPORT_EXPORT_PATH);
     if (exportPath != null) {
       exportResults(exportPath);
     }
index b82325cf0bfcd4e759f648ad90c0d29f0be462ef..c129bb704df34eb9d30814a8919557929c90ac28 100644 (file)
@@ -25,6 +25,7 @@ import org.sonar.batch.protocol.GsonHelper;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 public class UserRepository {
@@ -45,6 +46,9 @@ public class UserRepository {
   }
 
   public Collection<User> loadFromWs(List<String> userLogins) {
+    if (userLogins.isEmpty()) {
+      return Collections.emptyList();
+    }
     String url = "/api/users/search?format=json&includeDeactivated=true&logins=" + Joiner.on(',').join(userLogins);
     String json = serverClient.request(url);
     Users users = GsonHelper.create().fromJson(json, Users.class);