properties.put("sonar.tests", testDirectories);
properties.put("sonar.binaries", nonEmptyOrNull(Iterables.filter(main.getRuntimeClasspath(), IS_DIRECTORY)));
properties.put("sonar.libraries", getLibraries(main));
final Test testTask = (Test) project.getTasks().getByName(JavaPlugin.TEST_TASK_NAME);
if (sourceDirectories != null || testDirectories != null) {
File testResultsDir = testTask.getReports().getJunitXml().getDestination();
// create the test results folder to prevent SonarQube from emitting
// a warning if a project does not contain any tests
testResultsDir.mkdirs();
properties.put("sonar.surefire.reportsPath", testResultsDir);
// added due to https://issues.gradle.org/browse/GRADLE-3005
properties.put("sonar.junit.reportsPath", testResultsDir);
}
project.getPlugins().withType(JacocoPlugin.class, new Action<JacocoPlugin>() {
public void execute(JacocoPlugin jacocoPlugin) {
JacocoTaskExtension jacocoTaskExtension = testTask.getExtensions().getByType(JacocoTaskExtension.class);
File destinationFile = jacocoTaskExtension.getDestinationFile();
if (destinationFile.exists()) {
properties.put("sonar.jacoco.reportPath", destinationFile);
}
}