aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-07-18 09:51:04 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-07-18 15:43:39 +0200
commit274e9cefeb16fab1d5e35088289338f12993b208 (patch)
tree33e9e5a364815bd748973a568caf60a9a66019b9 /sonar-plugin-api
parent9d7b13c044e50067989658700ca307b7ce4804cd (diff)
downloadsonarqube-274e9cefeb16fab1d5e35088289338f12993b208.tar.gz
sonarqube-274e9cefeb16fab1d5e35088289338f12993b208.zip
SONAR-5417 Load metrics using project referential
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/MetricFinder.java40
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java2
3 files changed, 54 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
index 7b5a059b680..a5fa7ab0d93 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
@@ -165,6 +165,18 @@ public class ProjectDefinition {
return properties.getProperty(CoreProperties.PROJECT_KEY_PROPERTY);
}
+ /**
+ * @since 4.5
+ */
+ public String getKeyWithBranch() {
+ String branch = properties.getProperty(CoreProperties.PROJECT_BRANCH_PROPERTY);
+ String projectKey = getKey();
+ if (StringUtils.isNotBlank(branch)) {
+ projectKey = String.format("%s:%s", projectKey, branch);
+ }
+ return projectKey;
+ }
+
public String getVersion() {
return properties.getProperty(CoreProperties.PROJECT_VERSION_PROPERTY);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/MetricFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/MetricFinder.java
new file mode 100644
index 00000000000..4f91ea5aae4
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/measure/MetricFinder.java
@@ -0,0 +1,40 @@
+/*
+ * 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.api.batch.measure;
+
+import org.sonar.api.BatchComponent;
+
+import javax.annotation.CheckForNull;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @since 4.5
+ */
+public interface MetricFinder extends BatchComponent {
+
+ @CheckForNull
+ Metric findByKey(String key);
+
+ Collection<Metric> findAll(List<String> metricKeys);
+
+ Collection<Metric> findAll();
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
index c6f68aaedce..5d9aefd6013 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MetricFinder.java
@@ -29,7 +29,9 @@ import java.util.List;
/**
* @since 2.5
+ * @deprecated since 4.5 use {@link org.sonar.api.batch.measure.MetricFinder} on batch side
*/
+@Deprecated
public interface MetricFinder extends TaskComponent, ServerComponent {
@CheckForNull