diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-08-06 11:28:40 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-08-06 12:52:33 +0200 |
commit | 8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505 (patch) | |
tree | aacc9e22f21f755e98a9ac2ad945136ee36f0419 /sonar-scanner-protocol/src/main | |
parent | e55369090f3be4f1e4baa791b05c3f5cf1cef6e1 (diff) | |
download | sonarqube-8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505.tar.gz sonarqube-8e6415a4c7444f7c6e03b10e8fa8eb535cc7e505.zip |
SONAR-7654 API to propagate props from scanner to CE
Diffstat (limited to 'sonar-scanner-protocol/src/main')
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; |