aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2022-03-14 11:28:22 -0500
committersonartech <sonartech@sonarsource.com>2022-03-18 20:02:57 +0000
commitecf844b39473fe21acaa1f832d244a4cc4c9f811 (patch)
treea03e87cb743b877be05c92774e6f009bad3932f5 /sonar-scanner-protocol
parent1269984e8e09338c057d068d715ade7df5a0c354 (diff)
downloadsonarqube-ecf844b39473fe21acaa1f832d244a4cc4c9f811.tar.gz
sonarqube-ecf844b39473fe21acaa1f832d244a4cc4c9f811.zip
SONAR-16097 Add plugin cache to the Sensor API
Diffstat (limited to 'sonar-scanner-protocol')
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java2
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java6
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportWriter.java4
-rw-r--r--sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto2
-rw-r--r--sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java7
5 files changed, 11 insertions, 10 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 041bf6cbeff..d5bcf2a3a4d 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
@@ -66,7 +66,7 @@ public class FileStructure {
return new File(dir, "metadata.pb");
}
- public File pluginCache() {
+ public File analysisCache() {
return new File(dir, "plugin-cache.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 aaa0190a802..5e1376a3f1c 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
@@ -81,12 +81,12 @@ public class ScannerReportReader {
@CheckForNull
public InputStream getPluginCache() {
- File file = fileStructure.pluginCache();
+ File file = fileStructure.analysisCache();
if (fileExists(file)) {
try {
- return new BufferedInputStream(new FileInputStream(fileStructure.pluginCache()));
+ return new BufferedInputStream(new FileInputStream(fileStructure.analysisCache()));
} catch (FileNotFoundException e) {
- throw new IllegalStateException("Unable to open file " + fileStructure.pluginCache(), e);
+ throw new IllegalStateException("Unable to open file " + fileStructure.analysisCache(), e);
}
}
return null;
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 88f16d14d19..1b67cd41ea6 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
@@ -95,8 +95,8 @@ public class ScannerReportWriter {
return file;
}
- public File writePluginCache(ScannerInternal.PluginCacheMsg cacheMsg) {
- File file = fileStructure.pluginCache();
+ public File writeAnalysisCache(ScannerInternal.AnalysisCacheMsg cacheMsg) {
+ File file = fileStructure.analysisCache();
Protobuf.writeGzip(cacheMsg, file);
return file;
}
diff --git a/sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto b/sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto
index b0d38058c4c..4a9f0c53a58 100644
--- a/sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto
+++ b/sonar-scanner-protocol/src/main/protobuf/scanner_internal.proto
@@ -3,6 +3,6 @@ syntax = "proto3";
option java_package = "org.sonar.scanner.protocol.internal";
option optimize_for = SPEED;
-message PluginCacheMsg {
+message AnalysisCacheMsg {
map<string, bytes> map = 1;
}
diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java
index 58333d108cf..1269c63c540 100644
--- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java
+++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java
@@ -35,7 +35,8 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.core.util.CloseableIterator;
import org.sonar.core.util.Protobuf;
-import org.sonar.scanner.protocol.internal.ScannerInternal.PluginCacheMsg;
+import org.sonar.scanner.protocol.internal.ScannerInternal;
+import org.sonar.scanner.protocol.internal.ScannerInternal.AnalysisCacheMsg;
import org.sonar.scanner.protocol.output.ScannerReport.Measure.StringValue;
import org.sonar.scanner.protocol.output.ScannerReport.SyntaxHighlightingRule.HighlightingType;
@@ -214,13 +215,13 @@ public class ScannerReportReaderTest {
@Test
public void read_plugin_cache() throws IOException {
ScannerReportWriter writer = new ScannerReportWriter(dir);
- writer.writePluginCache(PluginCacheMsg.newBuilder()
+ writer.writeAnalysisCache(ScannerInternal.AnalysisCacheMsg.newBuilder()
.putMap("key", ByteString.copyFrom("data", UTF_8))
.build());
ScannerReportReader reader = new ScannerReportReader(dir);
- PluginCacheMsg cache = Protobuf.read(new GZIPInputStream(reader.getPluginCache()), PluginCacheMsg.parser());
+ AnalysisCacheMsg cache = Protobuf.read(new GZIPInputStream(reader.getPluginCache()), ScannerInternal.AnalysisCacheMsg.parser());
assertThat(cache.getMapMap()).containsOnly(new AbstractMap.SimpleEntry<>("key", ByteString.copyFrom("data", UTF_8)));
}