@@ -0,0 +1,64 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.protocol.input; | |||
import com.google.gson.Gson; | |||
import java.io.Reader; | |||
import java.util.ArrayList; | |||
import java.util.Collection; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* Container for all global data going from server to batch. | |||
* This is not an API since server and batch always share the same version. | |||
*/ | |||
public class GlobalReferentials { | |||
private long timestamp; | |||
private Collection<Metric> metrics = new ArrayList<Metric>(); | |||
private Map<String, String> globalSettings = new HashMap<String, String>(); | |||
public Map<String, String> globalSettings() { | |||
return globalSettings; | |||
} | |||
public Collection<Metric> metrics() { | |||
return metrics; | |||
} | |||
public long timestamp() { | |||
return timestamp; | |||
} | |||
public void setTimestamp(long timestamp) { | |||
this.timestamp = timestamp; | |||
} | |||
public String toJson() { | |||
return new Gson().toJson(this); | |||
} | |||
public static GlobalReferentials fromJson(Reader input) { | |||
return new Gson().fromJson(input, GlobalReferentials.class); | |||
} | |||
} |
@@ -28,13 +28,12 @@ import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* Container for all data going from server to batch. | |||
* Container for all project data going from server to batch. | |||
* This is not an API since server and batch always share the same version. | |||
*/ | |||
public class ProjectReferentials { | |||
private long timestamp; | |||
private Collection<Metric> metrics = new ArrayList<Metric>(); | |||
private Map<String, QProfile> qprofilesByLanguage = new HashMap<String, QProfile>(); | |||
private Collection<ActiveRule> activeRules = new ArrayList<ActiveRule>(); | |||
private Map<String, Map<String, String>> settingsByModule = new HashMap<String, Map<String, String>>(); | |||
@@ -48,10 +47,6 @@ public class ProjectReferentials { | |||
return this; | |||
} | |||
public Collection<Metric> metrics() { | |||
return metrics; | |||
} | |||
public Collection<QProfile> qProfiles() { | |||
return qprofilesByLanguage.values(); | |||
} |
@@ -0,0 +1,65 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.protocol.input; | |||
import org.fest.assertions.MapAssert; | |||
import org.json.JSONException; | |||
import org.junit.Test; | |||
import org.skyscreamer.jsonassert.JSONAssert; | |||
import java.io.StringReader; | |||
import static org.fest.assertions.Assertions.assertThat; | |||
public class GlobalReferentialsTest { | |||
@Test | |||
public void testToJson() throws Exception { | |||
GlobalReferentials ref = new GlobalReferentials(); | |||
ref.metrics().add(new Metric(1, "ncloc", "INT", "Description", -1, "NCLOC", true, false, 2.0, 1.0, true)); | |||
ref.globalSettings().put("prop", "value"); | |||
ref.setTimestamp(10); | |||
System.out.println(ref.toJson()); | |||
JSONAssert | |||
.assertEquals( | |||
"{timestamp:10," | |||
+ "metrics:[{id:1,key:ncloc,valueType:INT,description:Description,direction:-1,name:NCLOC,qualitative:true,userManaged:false,worstValue:2.0,bestValue:1.0,optimizedBestValue:true}]," | |||
+ "globalSettings:{prop:value}}", | |||
ref.toJson(), true); | |||
} | |||
@Test | |||
public void testFromJson() throws JSONException { | |||
GlobalReferentials ref = GlobalReferentials | |||
.fromJson(new StringReader( | |||
"{timestamp:1," | |||
+ "metrics:[{id:1,key:ncloc,valueType:DATA,description:Description,direction:-1,name:NCLOC,qualitative:true,userManaged:false,worstValue:2.0,bestValue:1.0,optimizedBestValue:true}]," | |||
+ "globalSettings:{prop:value}}")); | |||
assertThat(ref.timestamp()).isEqualTo(1); | |||
Metric metric = ref.metrics().iterator().next(); | |||
assertThat(metric.id()).isEqualTo(1); | |||
assertThat(metric.key()).isEqualTo("ncloc"); | |||
assertThat(metric.valueType()).isEqualTo("DATA"); | |||
assertThat(ref.globalSettings()).includes(MapAssert.entry("prop", "value")); | |||
} | |||
} |
@@ -19,6 +19,7 @@ | |||
*/ | |||
package org.sonar.batch.protocol.input; | |||
import org.fest.assertions.MapAssert; | |||
import org.json.JSONException; | |||
import org.junit.Test; | |||
import org.skyscreamer.jsonassert.JSONAssert; | |||
@@ -34,7 +35,6 @@ public class ProjectReferentialsTest { | |||
@Test | |||
public void testToJson() throws Exception { | |||
ProjectReferentials ref = new ProjectReferentials(); | |||
ref.metrics().add(new Metric(1, "ncloc", "INT", "Description", -1, "NCLOC", true, false, 2.0, 1.0, true)); | |||
ref.addQProfile(new QProfile("squid-java", "Java", "java", new SimpleDateFormat("dd/MM/yyyy").parse("14/03/1984"))); | |||
ref.addSettings("foo", new HashMap<String, String>()); | |||
ref.settings("foo").put("prop", "value"); | |||
@@ -44,7 +44,7 @@ public class ProjectReferentialsTest { | |||
System.out.println(ref.toJson()); | |||
JSONAssert | |||
.assertEquals( | |||
"{timestamp:10,metrics:[{id:1,key:ncloc,valueType:INT,description:Description,direction:-1,name:NCLOC,qualitative:true,userManaged:false,worstValue:2.0,bestValue:1.0,optimizedBestValue:true}]," | |||
"{timestamp:10," | |||
+ "qprofilesByLanguage:{java:{key:\"squid-java\",name:Java,language:java,rulesUpdatedAt:\"Mar 14, 1984 12:00:00 AM\"}}," | |||
+ "activeRules:[{repositoryKey:repo,ruleKey:rule,severity:MAJOR,internalKey:rule,language:java,params:{}}]," | |||
+ "settingsByModule:{foo:{prop:value}}}", | |||
@@ -53,18 +53,15 @@ public class ProjectReferentialsTest { | |||
@Test | |||
public void testFromJson() throws JSONException { | |||
ProjectReferentials ref = ProjectReferentials.fromJson(new StringReader("{timestamp:1,metrics:[{id:1,key:ncloc,valueType:DATA}]," | |||
ProjectReferentials ref = ProjectReferentials.fromJson(new StringReader("{timestamp:1," | |||
+ "qprofilesByLanguage:{java:{key:\"squid-java\",name:Java,language:java,rulesUpdatedAt:\"Mar 14, 1984 12:00:00 AM\"}}," | |||
+ "activeRules:[{repositoryKey:repo,ruleKey:rule,severity:MAJOR,internalKey:rule,language:java,params:{}}]," | |||
+ "settingsByModule:{foo:{prop:value}}}")); | |||
assertThat(ref.timestamp()).isEqualTo(1); | |||
Metric metric = ref.metrics().iterator().next(); | |||
assertThat(metric.id()).isEqualTo(1); | |||
assertThat(metric.key()).isEqualTo("ncloc"); | |||
assertThat(metric.valueType()).isEqualTo("DATA"); | |||
assertThat(ref.activeRules().iterator().next().ruleKey()).isEqualTo("rule"); | |||
assertThat(ref.qProfiles().iterator().next().name()).isEqualTo("Java"); | |||
assertThat(ref.settings("foo")).includes(MapAssert.entry("prop", "value")); | |||
} | |||
} |
@@ -36,7 +36,10 @@ import org.sonar.batch.components.PastSnapshotFinderByDays; | |||
import org.sonar.batch.components.PastSnapshotFinderByPreviousAnalysis; | |||
import org.sonar.batch.components.PastSnapshotFinderByPreviousVersion; | |||
import org.sonar.batch.components.PastSnapshotFinderByVersion; | |||
import org.sonar.batch.referential.DefaultGlobalReferentialsLoader; | |||
import org.sonar.batch.referential.DefaultProjectReferentialsLoader; | |||
import org.sonar.batch.referential.GlobalReferentialsLoader; | |||
import org.sonar.batch.referential.GlobalReferentialsProvider; | |||
import org.sonar.batch.referential.ProjectReferentialsLoader; | |||
import org.sonar.batch.settings.DefaultSettingsReferential; | |||
import org.sonar.batch.settings.SettingsReferential; | |||
@@ -103,13 +106,17 @@ public class BootstrapContainer extends ComponentContainer { | |||
HttpDownloader.class, | |||
UriReader.class, | |||
new FileCacheProvider(), | |||
System2.INSTANCE); | |||
System2.INSTANCE, | |||
new GlobalReferentialsProvider()); | |||
if (getComponentByType(SettingsReferential.class) == null) { | |||
add(DefaultSettingsReferential.class); | |||
} | |||
if (getComponentByType(PluginsReferential.class) == null) { | |||
add(DefaultPluginsReferential.class); | |||
} | |||
if (getComponentByType(GlobalReferentialsLoader.class) == null) { | |||
add(DefaultGlobalReferentialsLoader.class); | |||
} | |||
if (getComponentByType(ProjectReferentialsLoader.class) == null) { | |||
add(DefaultProjectReferentialsLoader.class); | |||
} |
@@ -31,6 +31,8 @@ import org.sonar.batch.bootstrapper.EnvironmentInformation; | |||
import org.sonar.batch.scan.DeprecatedProjectReactorBuilder; | |||
import org.sonar.batch.scan.ProjectReactorBuilder; | |||
import org.sonar.batch.scan.ScanTask; | |||
import org.sonar.batch.scan.measure.DefaultMetricFinder; | |||
import org.sonar.batch.scan.measure.DeprecatedMetricFinder; | |||
import org.sonar.batch.tasks.ListTask; | |||
import org.sonar.batch.tasks.Tasks; | |||
import org.sonar.core.permission.PermissionFacade; | |||
@@ -54,11 +56,21 @@ public class TaskContainer extends ComponentContainer { | |||
installCoreTasks(); | |||
installTaskExtensions(); | |||
installComponentsUsingTaskExtensions(); | |||
addCoreComponents(); | |||
for (Object component : components) { | |||
add(component); | |||
} | |||
} | |||
private void addCoreComponents() { | |||
// Metrics | |||
if (!getParent().getComponentByType(AnalysisMode.class).isSensorMode()) { | |||
add(DeprecatedMetricFinder.class); | |||
} | |||
add(DefaultMetricFinder.class); | |||
} | |||
void installCoreTasks() { | |||
add(new TaskProperties(taskProperties, getParent().getComponentByType(BootstrapProperties.class).property(CoreProperties.ENCRYPTION_SECRET_KEY_PATH))); | |||
add( |
@@ -35,7 +35,9 @@ import org.sonar.batch.bootstrap.PluginsReferential; | |||
import org.sonar.batch.bootstrapper.Batch; | |||
import org.sonar.batch.bootstrapper.EnvironmentInformation; | |||
import org.sonar.batch.protocol.input.ActiveRule; | |||
import org.sonar.batch.protocol.input.GlobalReferentials; | |||
import org.sonar.batch.protocol.input.ProjectReferentials; | |||
import org.sonar.batch.referential.GlobalReferentialsLoader; | |||
import org.sonar.batch.referential.ProjectReferentialsLoader; | |||
import org.sonar.batch.scan.filesystem.InputFileCache; | |||
import org.sonar.batch.scan2.AnalyzerIssueCache; | |||
@@ -65,7 +67,8 @@ public class BatchMediumTester { | |||
} | |||
public static class BatchMediumTesterBuilder { | |||
private final FakeProjectReferentialsLoader refProvider = new FakeProjectReferentialsLoader(); | |||
private final FakeGlobalReferentialsLoader globalRefProvider = new FakeGlobalReferentialsLoader(); | |||
private final FakeProjectReferentialsLoader projectRefProvider = new FakeProjectReferentialsLoader(); | |||
private final FakeSettingsReferential settingsReferential = new FakeSettingsReferential(); | |||
private final FackPluginsReferential pluginsReferential = new FackPluginsReferential(); | |||
private final Map<String, String> bootstrapProperties = new HashMap<String, String>(); | |||
@@ -92,12 +95,12 @@ public class BatchMediumTester { | |||
} | |||
public BatchMediumTesterBuilder registerMetric(Metric<?> metric) { | |||
refProvider.add(metric); | |||
globalRefProvider.add(metric); | |||
return this; | |||
} | |||
public BatchMediumTesterBuilder addQProfile(String language, String name) { | |||
refProvider.addQProfile(language, name); | |||
projectRefProvider.addQProfile(language, name); | |||
return this; | |||
} | |||
@@ -113,7 +116,7 @@ public class BatchMediumTester { | |||
} | |||
public BatchMediumTesterBuilder activateRule(ActiveRule activeRule) { | |||
refProvider.addActiveRule(activeRule); | |||
projectRefProvider.addActiveRule(activeRule); | |||
return this; | |||
} | |||
@@ -134,7 +137,8 @@ public class BatchMediumTester { | |||
new EnvironmentInformation("mediumTest", "1.0"), | |||
builder.settingsReferential, | |||
builder.pluginsReferential, | |||
builder.refProvider, | |||
builder.globalRefProvider, | |||
builder.projectRefProvider, | |||
new DefaultDebtModel()) | |||
.setBootstrapProperties(builder.bootstrapProperties) | |||
.build(); | |||
@@ -228,23 +232,18 @@ public class BatchMediumTester { | |||
} | |||
private static class FakeProjectReferentialsLoader implements ProjectReferentialsLoader { | |||
private static class FakeGlobalReferentialsLoader implements GlobalReferentialsLoader { | |||
private int metricId = 1; | |||
private ProjectReferentials ref = new ProjectReferentials(); | |||
private GlobalReferentials ref = new GlobalReferentials(); | |||
@Override | |||
public ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages) { | |||
public GlobalReferentials load() { | |||
return ref; | |||
} | |||
public FakeProjectReferentialsLoader addQProfile(String language, String name) { | |||
ref.addQProfile(new org.sonar.batch.protocol.input.QProfile(name, name, language, new Date())); | |||
return this; | |||
} | |||
public FakeProjectReferentialsLoader add(Metric metric) { | |||
public FakeGlobalReferentialsLoader add(Metric metric) { | |||
ref.metrics().add(new org.sonar.batch.protocol.input.Metric(metricId, | |||
metric.key(), | |||
metric.getType().name(), | |||
@@ -259,6 +258,21 @@ public class BatchMediumTester { | |||
metricId++; | |||
return this; | |||
} | |||
} | |||
private static class FakeProjectReferentialsLoader implements ProjectReferentialsLoader { | |||
private ProjectReferentials ref = new ProjectReferentials(); | |||
@Override | |||
public ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages) { | |||
return ref; | |||
} | |||
public FakeProjectReferentialsLoader addQProfile(String language, String name) { | |||
ref.addQProfile(new org.sonar.batch.protocol.input.QProfile(name, name, language, new Date())); | |||
return this; | |||
} | |||
public FakeProjectReferentialsLoader addActiveRule(ActiveRule activeRule) { | |||
ref.addActiveRule(activeRule); |
@@ -0,0 +1,67 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.referential; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.batch.protocol.input.GlobalReferentials; | |||
import org.sonar.jpa.session.DatabaseSessionFactory; | |||
import java.util.Collection; | |||
/** | |||
* TODO This is currently implemented by accessing DB but should be replaced by WS call | |||
*/ | |||
public class DefaultGlobalReferentialsLoader implements GlobalReferentialsLoader { | |||
private static final String ENABLED = "enabled"; | |||
private final DatabaseSessionFactory sessionFactory; | |||
public DefaultGlobalReferentialsLoader(DatabaseSessionFactory sessionFactory) { | |||
this.sessionFactory = sessionFactory; | |||
} | |||
@Override | |||
public GlobalReferentials load() { | |||
GlobalReferentials ref = new GlobalReferentials(); | |||
for (Metric m : sessionFactory.getSession().getResults(Metric.class, ENABLED, true)) { | |||
Boolean optimizedBestValue = m.isOptimizedBestValue(); | |||
Boolean qualitative = m.getQualitative(); | |||
Boolean userManaged = m.getUserManaged(); | |||
ref.metrics().add( | |||
new org.sonar.batch.protocol.input.Metric(m.getId(), m.getKey(), | |||
m.getType().name(), | |||
m.getDescription(), | |||
m.getDirection(), | |||
m.getName(), | |||
qualitative != null ? m.getQualitative() : false, | |||
userManaged != null ? m.getUserManaged() : false, | |||
m.getWorstValue(), | |||
m.getBestValue(), | |||
optimizedBestValue != null ? optimizedBestValue : false)); | |||
} | |||
return ref; | |||
} | |||
private Collection<Metric> doFindAll() { | |||
return sessionFactory.getSession().getResults(Metric.class, ENABLED, true); | |||
} | |||
} |
@@ -24,7 +24,6 @@ import com.google.common.collect.ListMultimap; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.batch.bootstrap.ProjectReactor; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.api.resources.Language; | |||
import org.sonar.api.resources.Languages; | |||
import org.sonar.api.rules.Rule; | |||
@@ -41,12 +40,9 @@ import org.sonar.core.qualityprofile.db.ActiveRuleDto; | |||
import org.sonar.core.qualityprofile.db.ActiveRuleParamDto; | |||
import org.sonar.core.qualityprofile.db.QualityProfileDao; | |||
import org.sonar.core.qualityprofile.db.QualityProfileDto; | |||
import org.sonar.jpa.session.DatabaseSessionFactory; | |||
import javax.annotation.CheckForNull; | |||
import java.util.Collection; | |||
/** | |||
* TODO This is currently implemented by accessing DB but should be replaced by WS call | |||
*/ | |||
@@ -54,14 +50,12 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad | |||
private static final String ENABLED = "enabled"; | |||
private final DatabaseSessionFactory sessionFactory; | |||
private final QualityProfileDao qualityProfileDao; | |||
private final ActiveRuleDao activeRuleDao; | |||
private final RuleFinder ruleFinder; | |||
public DefaultProjectReferentialsLoader(DatabaseSessionFactory sessionFactory, QualityProfileDao qualityProfileDao, | |||
public DefaultProjectReferentialsLoader(QualityProfileDao qualityProfileDao, | |||
ActiveRuleDao activeRuleDao, RuleFinder ruleFinder) { | |||
this.sessionFactory = sessionFactory; | |||
this.qualityProfileDao = qualityProfileDao; | |||
this.activeRuleDao = activeRuleDao; | |||
this.ruleFinder = ruleFinder; | |||
@@ -70,22 +64,6 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad | |||
@Override | |||
public ProjectReferentials load(ProjectReactor reactor, Settings settings, Languages languages) { | |||
ProjectReferentials ref = new ProjectReferentials(); | |||
for (Metric m : sessionFactory.getSession().getResults(Metric.class, ENABLED, true)) { | |||
Boolean optimizedBestValue = m.isOptimizedBestValue(); | |||
Boolean qualitative = m.getQualitative(); | |||
Boolean userManaged = m.getUserManaged(); | |||
ref.metrics().add( | |||
new org.sonar.batch.protocol.input.Metric(m.getId(), m.getKey(), | |||
m.getType().name(), | |||
m.getDescription(), | |||
m.getDirection(), | |||
m.getName(), | |||
qualitative != null ? m.getQualitative() : false, | |||
userManaged != null ? m.getUserManaged() : false, | |||
m.getWorstValue(), | |||
m.getBestValue(), | |||
optimizedBestValue != null ? optimizedBestValue : false)); | |||
} | |||
String defaultName = settings.getString(ModuleQProfiles.SONAR_PROFILE_PROP); | |||
@@ -158,10 +136,6 @@ public class DefaultProjectReferentialsLoader implements ProjectReferentialsLoad | |||
return get(language, profileName); | |||
} | |||
protected Collection<Metric> doFindAll() { | |||
return sessionFactory.getSession().getResults(Metric.class, ENABLED, true); | |||
} | |||
public QProfile get(String language, String name) { | |||
QualityProfileDto dto = qualityProfileDao.getByNameAndLanguage(name, language); | |||
if (dto == null) { |
@@ -0,0 +1,28 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.referential; | |||
import org.sonar.batch.protocol.input.GlobalReferentials; | |||
public interface GlobalReferentialsLoader { | |||
GlobalReferentials load(); | |||
} |
@@ -0,0 +1,30 @@ | |||
/* | |||
* SonarQube, open source software quality management tool. | |||
* Copyright (C) 2008-2014 SonarSource | |||
* mailto:contact AT sonarsource DOT com | |||
* | |||
* SonarQube is free software; you can redistribute it and/or | |||
* modify it under the terms of the GNU Lesser General Public | |||
* License as published by the Free Software Foundation; either | |||
* version 3 of the License, or (at your option) any later version. | |||
* | |||
* SonarQube is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
* Lesser General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Lesser General Public License | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.batch.referential; | |||
import org.picocontainer.injectors.ProviderAdapter; | |||
import org.sonar.batch.protocol.input.GlobalReferentials; | |||
public class GlobalReferentialsProvider extends ProviderAdapter { | |||
public GlobalReferentials provide(GlobalReferentialsLoader loader) { | |||
return loader.load(); | |||
} | |||
} |
@@ -70,8 +70,6 @@ import org.sonar.batch.rule.RulesProvider; | |||
import org.sonar.batch.scan.filesystem.InputFileCache; | |||
import org.sonar.batch.scan.maven.FakeMavenPluginExecutor; | |||
import org.sonar.batch.scan.maven.MavenPluginExecutor; | |||
import org.sonar.batch.scan.measure.DefaultMetricFinder; | |||
import org.sonar.batch.scan.measure.DeprecatedMetricFinder; | |||
import org.sonar.batch.scan.measure.MeasureCache; | |||
import org.sonar.batch.source.HighlightableBuilder; | |||
import org.sonar.batch.source.SymbolizableBuilder; | |||
@@ -192,8 +190,6 @@ public class ProjectScanContainer extends ComponentContainer { | |||
// Measures | |||
MeasureCache.class, | |||
DeprecatedMetricFinder.class, | |||
DefaultMetricFinder.class, | |||
PastMeasuresLoader.class, | |||
// Rules |
@@ -24,7 +24,7 @@ import com.google.common.collect.Maps; | |||
import org.sonar.api.batch.measure.Metric; | |||
import org.sonar.api.batch.measure.MetricFinder; | |||
import org.sonar.api.measures.Metric.ValueType; | |||
import org.sonar.batch.protocol.input.ProjectReferentials; | |||
import org.sonar.batch.protocol.input.GlobalReferentials; | |||
import java.util.Collection; | |||
import java.util.List; | |||
@@ -34,8 +34,8 @@ public class DefaultMetricFinder implements MetricFinder { | |||
private Map<String, Metric> metricsByKey = Maps.newLinkedHashMap(); | |||
public DefaultMetricFinder(ProjectReferentials projectReferentials) { | |||
for (org.sonar.batch.protocol.input.Metric metric : projectReferentials.metrics()) { | |||
public DefaultMetricFinder(GlobalReferentials globalReferentials) { | |||
for (org.sonar.batch.protocol.input.Metric metric : globalReferentials.metrics()) { | |||
metricsByKey.put(metric.key(), new org.sonar.api.measures.Metric.Builder(metric.key(), metric.key(), ValueType.valueOf(metric.valueType())).create()); | |||
} | |||
} |
@@ -24,7 +24,7 @@ import com.google.common.collect.Maps; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.api.measures.Metric.ValueType; | |||
import org.sonar.api.measures.MetricFinder; | |||
import org.sonar.batch.protocol.input.ProjectReferentials; | |||
import org.sonar.batch.protocol.input.GlobalReferentials; | |||
import java.util.Collection; | |||
import java.util.List; | |||
@@ -35,8 +35,8 @@ public final class DeprecatedMetricFinder implements MetricFinder { | |||
private Map<String, Metric> metricsByKey = Maps.newLinkedHashMap(); | |||
private Map<Integer, Metric> metricsById = Maps.newLinkedHashMap(); | |||
public DeprecatedMetricFinder(ProjectReferentials projectReferentials) { | |||
for (org.sonar.batch.protocol.input.Metric metric : projectReferentials.metrics()) { | |||
public DeprecatedMetricFinder(GlobalReferentials globalReferentials) { | |||
for (org.sonar.batch.protocol.input.Metric metric : globalReferentials.metrics()) { | |||
Metric hibernateMetric = new org.sonar.api.measures.Metric.Builder(metric.key(), metric.key(), ValueType.valueOf(metric.valueType())) | |||
.create() | |||
.setDirection(metric.direction()) |
@@ -44,7 +44,6 @@ import org.sonar.batch.scan.ProjectSettings; | |||
import org.sonar.batch.scan.filesystem.InputFileCache; | |||
import org.sonar.batch.scan.maven.FakeMavenPluginExecutor; | |||
import org.sonar.batch.scan.maven.MavenPluginExecutor; | |||
import org.sonar.batch.scan.measure.DefaultMetricFinder; | |||
public class ProjectScanContainer extends ComponentContainer { | |||
public ProjectScanContainer(ComponentContainer taskContainer) { | |||
@@ -96,7 +95,6 @@ public class ProjectScanContainer extends ComponentContainer { | |||
DefaultLanguagesReferential.class, | |||
// Measures | |||
DefaultMetricFinder.class, | |||
AnalyzerMeasureCache.class, | |||
// file system |