aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol/src/main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-08-06 11:28:40 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-08-06 12:52:33 +0200
commit8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505 (patch)
treeaacc9e22f21f755e98a9ac2ad945136ee36f0419 /sonar-scanner-protocol/src/main
parente55369090f3be4f1e4baa791b05c3f5cf1cef6e1 (diff)
downloadsonarqube-8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505.tar.gz
sonarqube-8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505.zip
SONAR-7654 API to propagate props from scanner to CE
Diffstat (limited to 'sonar-scanner-protocol/src/main')
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java3
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java8
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java6
-rw-r--r--sonar-scanner-protocol/src/main/protobuf/scanner_report.proto5
4 files changed, 22 insertions, 0 deletions
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
index c4d3197cb43..5d408aef691 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
@@ -75,4 +75,7 @@ public class FileStructure {
return new File(dir, domain.filePrefix + componentRef + domain.fileSuffix);
}
+ public File contextProperties() {
+ return new File(dir, "context-props.pb");
+ }
}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
index 5cb0d7b8bf2..932373bb3e9 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
@@ -162,6 +162,14 @@ public class ScannerReportReader {
return null;
}
+ public CloseableIterator<ScannerReport.ContextProperty> readContextProperties() {
+ File file = fileStructure.contextProperties();
+ if (!fileExists(file)) {
+ return emptyCloseableIterator();
+ }
+ return Protobuf.readStream(file, ScannerReport.ContextProperty.parser());
+ }
+
private static boolean fileExists(File file) {
return file.exists() && file.isFile();
}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
index b2da5ba4b56..f85f82495e5 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java
@@ -134,6 +134,12 @@ public class ScannerReportWriter {
return file;
}
+ public File writeContextProperties(Iterable<ScannerReport.ContextProperty> properties) {
+ File file = fileStructure.contextProperties();
+ Protobuf.writeStream(properties, file, false);
+ return file;
+ }
+
public File getSourceFile(int componentRef) {
return fileStructure.fileFor(FileStructure.Domain.SOURCE, componentRef);
}
diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
index 1a6efc592f9..f0ab94c1e2a 100644
--- a/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
+++ b/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
@@ -45,6 +45,11 @@ message Metadata {
}
}
+message ContextProperty {
+ string key = 1;
+ string value = 2;
+}
+
message ActiveRule {
string rule_repository = 1;
string rule_key = 2;