summaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/main
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-10-01 10:50:17 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-10-01 10:57:00 +0200
commit33cbe7daa7722a29e115ad9343a448c561d875a9 (patch)
tree5de951abf7745e40d8de512f71bed90884dd0a81 /sonar-batch/src/main
parent9cd17b26616cd146c8954e1e38ee7c9589280842 (diff)
downloadsonarqube-33cbe7daa7722a29e115ad9343a448c561d875a9.tar.gz
sonarqube-33cbe7daa7722a29e115ad9343a448c561d875a9.zip
Use sonar.profile when project is not provisioned
Diffstat (limited to 'sonar-batch/src/main')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizer.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java5
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileLoader.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java5
5 files changed, 11 insertions, 5 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizer.java b/sonar-batch/src/main/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizer.java
index 5242184a30f..2df946dc0ae 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/NonAssociatedCacheSynchronizer.java
@@ -79,7 +79,7 @@ public class NonAssociatedCacheSynchronizer {
Profiler profiler = Profiler.create(Loggers.get(ProjectCacheSynchronizer.class));
profiler.startInfo("Load default quality profiles");
- Collection<QualityProfile> qProfiles = qualityProfileLoader.loadDefault(null);
+ Collection<QualityProfile> qProfiles = qualityProfileLoader.loadDefault(null, null);
profiler.stopInfo();
profiler.startInfo("Load default active rules");
diff --git a/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java b/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java
index 4ba15ab16a6..fbba13fbbc8 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/cache/ProjectCacheSynchronizer.java
@@ -105,7 +105,7 @@ public class ProjectCacheSynchronizer {
if (projectRepo.exists()) {
qProfiles = qualityProfileLoader.load(projectKey, null, null);
} else {
- qProfiles = qualityProfileLoader.loadDefault(null);
+ qProfiles = qualityProfileLoader.loadDefault(null, null);
}
profiler.stopInfo();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java
index 3eace767103..c8cc3f391cf 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/DefaultQualityProfileLoader.java
@@ -45,8 +45,11 @@ public class DefaultQualityProfileLoader implements QualityProfileLoader {
}
@Override
- public List<QualityProfile> loadDefault(@Nullable MutableBoolean fromCache) {
+ public List<QualityProfile> loadDefault(@Nullable String profileName, @Nullable MutableBoolean fromCache) {
String url = WS_URL + "?defaults=true";
+ if(profileName != null) {
+ url += "&profileName=" + BatchUtils.encodeForUrl(profileName);
+ }
return loadResource(url, fromCache);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileLoader.java b/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileLoader.java
index 1ab61a9e438..266d24a3d7a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileLoader.java
@@ -29,5 +29,5 @@ import java.util.List;
public interface QualityProfileLoader {
List<QualityProfile> load(String projectKey, @Nullable String profileName, @Nullable MutableBoolean fromCache);
- List<QualityProfile> loadDefault(@Nullable MutableBoolean fromCache);
+ List<QualityProfile> loadDefault(@Nullable String profileName, @Nullable MutableBoolean fromCache);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java b/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java
index d35ab28fb6b..b53635e7bd5 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java
@@ -19,6 +19,8 @@
*/
package org.sonar.batch.repository;
+import javax.annotation.CheckForNull;
+
import org.sonar.api.utils.log.Profiler;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
@@ -45,7 +47,7 @@ public class QualityProfileProvider extends ProviderAdapter {
Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
if (mode.isNotAssociated() || !projectRepositories.exists()) {
- profileList = loader.loadDefault(fromCache);
+ profileList = loader.loadDefault(getSonarProfile(props, mode), fromCache);
} else {
profileList = loader.load(projectKey.get(), getSonarProfile(props, mode), fromCache);
}
@@ -56,6 +58,7 @@ public class QualityProfileProvider extends ProviderAdapter {
return profiles;
}
+ @CheckForNull
private static String getSonarProfile(AnalysisProperties props, DefaultAnalysisMode mode) {
String profile = null;
if (!mode.isIssues()) {