in sonar-plugin-agent/src/main/java/jetbrains/buildserver/sonarplugin/SQRBuildService.java [119:196]
private List<String> composeSQRArgs(@NotNull final Map<String, String> runnerParameters,
@NotNull final Map<String, String> sharedConfigParameters,
@NotNull final String sonarScannerRoot,
@NotNull final File buildTempDir,
@NotNull final Map<String, String> environmentVariables) {
final SQRParametersAccessor accessor = new SQRParametersAccessor(SQRParametersUtil.mergeParameters(sharedConfigParameters, runnerParameters));
final List<String> res = mySQArgsComposer.composeArgs(accessor, new JavaSonarQubeKeysProvider(), environmentVariables);
addSQRArg(res, "-Dscanner.home", sonarScannerRoot, myOsType);
final Set<String> collectedReports = mySonarProcessListener.getCollectedReports();
if (!collectedReports.isEmpty() && (accessor.getAdditionalParameters() == null || !accessor.getAdditionalParameters().contains("-Dsonar.junit.reportsPath"))) {
addSQRArg(res, "-Dsonar.dynamicAnalysis", "reuseReports", myOsType);
addSQRArg(res, "-Dsonar.junit.reportsPath", collectReportsPath(collectedReports, accessor.getProjectModules()), myOsType);
}
boolean xmlFound = false;
boolean jacocoEnabled = false;
String jacocoXmlReportPaths = null;
final String jacocoExecFilePath = sharedConfigParameters.get("teamcity.jacoco.coverage.datafile");
if (jacocoExecFilePath != null) {
final File file = new File(jacocoExecFilePath);
if (file.exists() && file.isFile() && file.canRead()) {
// check jacoco.xml report first
String reportPath = sharedConfigParameters.get("teamcity.coverage.tempdir.path");
if (reportPath != null) {
final File xmlReport = new File(reportPath, "report" + File.separator + "jacocoReport.xml");
if (xmlReport.exists() && xmlReport.isFile()) {
jacocoXmlReportPaths = xmlReport.getAbsolutePath();
}
}
if (jacocoXmlReportPaths == null) {
final File[] files = buildTempDir.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().startsWith("JACOCO") && file.getName().endsWith("coverage") && new File(file, "report" + File.separator + "jacocoReport.xml").exists();
}
});
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
files[i] = new File(files[i], "report" + File.separator + "jacocoReport.xml");
}
jacocoXmlReportPaths = StringUtil.join(files, new Function<File, String>() {
@Override
public String fun(File file) {
return file.getAbsolutePath();
}
}, ",");
}
}
jacocoEnabled = true;
addSQRArg(res, "-Dsonar.java.coveragePlugin", "jacoco", myOsType);
if (jacocoXmlReportPaths != null) {
xmlFound = true;
addSQRArg(res, "-Dsonar.coverage.jacoco.xmlReportPaths", jacocoXmlReportPaths, myOsType);
}
addSQRArg(res, "-Dsonar.jacoco.reportPath", jacocoExecFilePath, myOsType);
}
}
if (!xmlFound) {
final String jacocoXmlReportPath = sharedConfigParameters.get("teamcity.jacoco.coverage.xmlReport");
if (jacocoXmlReportPath != null) {
if (!jacocoEnabled) {
addSQRArg(res, "-Dsonar.java.coveragePlugin", "jacoco", myOsType);
}
addSQRArg(res, "-Dsonar.coverage.jacoco.xmlReportPaths", jacocoXmlReportPath, myOsType);
}
}
return res;
}