diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-05-31 15:32:25 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-05-31 15:32:37 +0200 |
commit | 70cd924529a3567f6042e1d8fcbd9a64c0693d1a (patch) | |
tree | df86b828ec55962ad452f1e64ff7a9aab9a5f987 /sonar-batch/src | |
parent | 5c932911b44a302376be42ddda143949e8662fb9 (diff) | |
download | sonarqube-70cd924529a3567f6042e1d8fcbd9a64c0693d1a.tar.gz sonarqube-70cd924529a3567f6042e1d8fcbd9a64c0693d1a.zip |
Fix loading of metric formulas when defined in plugins
Diffstat (limited to 'sonar-batch/src')
3 files changed, 21 insertions, 10 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionInstaller.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionInstaller.java index f176e1a81fc..cee17e434d7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionInstaller.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionInstaller.java @@ -24,6 +24,8 @@ import org.sonar.api.ExtensionProvider; import org.sonar.api.Plugin; import org.sonar.api.batch.CoverageExtension; import org.sonar.api.batch.InstantiationStrategy; +import org.sonar.api.measures.Metric; +import org.sonar.api.measures.Metrics; import org.sonar.batch.bootstrapper.EnvironmentInformation; import java.util.List; @@ -45,6 +47,15 @@ public final class BatchExtensionInstaller implements BatchComponent { } } installExtensionProviders(module); + installMetrics(module); + } + + private void installMetrics(Module module) { + for (Metrics metrics : module.getComponents(Metrics.class)) { + for (Metric metric : metrics.getMetrics()) { + module.addComponent(metric.getKey(), metric); + } + } } void installExtensionProviders(Module module) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java index c69b34c6b82..e78c7251f49 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchModule.java @@ -20,6 +20,9 @@ package org.sonar.batch.bootstrap; import org.sonar.api.Plugins; +import org.sonar.api.measures.CoreMetrics; +import org.sonar.api.measures.Metric; +import org.sonar.api.measures.Metrics; import org.sonar.api.resources.Project; import org.sonar.api.utils.ServerHttpClient; import org.sonar.batch.DefaultResourceCreationLock; @@ -59,6 +62,7 @@ public class BatchModule extends Module { addComponent(PastSnapshotFinderByVersion.class); addComponent(PastMeasuresLoader.class); addComponent(PastSnapshotFinder.class); + addCoreMetrics(); addBatchExtensions(); } @@ -67,6 +71,12 @@ public class BatchModule extends Module { installer.install(this); } + void addCoreMetrics() { + for (Metric metric : CoreMetrics.getMetrics()) { + addComponent(metric.getKey(), metric); + } + } + @Override protected void doStart() { ProjectTree projectTree = getComponent(ProjectTree.class); diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java index 1ea854e61de..ae0c69aec40 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java @@ -104,16 +104,6 @@ public class ProjectModule extends Module { for (Class clazz : Phases.getPhaseClasses()) { addComponent(clazz); } - - // TODO move metrics to BatchComponents - for (Metric metric : CoreMetrics.getMetrics()) { - addComponent(metric.getKey(), metric); - } - for (Metrics metricRepo : getComponents(Metrics.class)) { - for (Metric metric : metricRepo.getMetrics()) { - addComponent(metric.getKey(), metric); - } - } } private void addProjectPluginExtensions() { |