2

I am trying use SonarQube v5.2(with Jacoco) with Gradle 3.1 . (org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2)

Earlier I had to switch to Sonar-runner due to the same exception (and could generate Sonar reports) but to get Jacoco working, I had to switch back to SonarQube. It has bitten me again , with the jar error. The build output logs are as follows:

78472 tests completed, 337 failed, 11 skipped
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Invalid value of sonar.libraries for :component
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sonarqube'.
> No files nor directories matching '[/opt/application-data/bamboo-agent/gradle_repo/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar' in directory /opt/application-data/bamboo-agent/application-data-local/bamboo-agent/agent4/xml-data/build-dir/CV-SVPT-JOB1/component

Tried quite a number of times changing config But couldnt get it working.

Some relevant code from build.xml of this component:

def jacocoExecutionData = "build/jacoco/testDebugUnitTest.exec"
def classesDirectory = "build";


task jacocoTestReport(type: JacocoReport, dependsOn: "testDebugUnitTest")      
{
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
    xml.enabled = true
    html.enabled = true
}
//fileTree(dir: "${project.buildDir}/classes/main", excludes: []

classDirectories = fileTree(dir: "${project.buildDir}/classes/main", excludes: [])

def coverageSourceDirs = ["${rootDir}/app/src/main/java"]
//additionalSourceDirs = files(coverageSourceDirs)

//classDirectories = fileTree(dir: classesDirectory)
additionalSourceDirs = files(coverageSourceDirs)
sourceDirectories = files(coverageSourceDirs)
executionData = files(jacocoExecutionData)
}

sonarqube {
    properties {
        property "sonar.jacoco.reportPath", jacocoExecutionData
        }
    }

Not sure if it is caused by jars conflict each other as I tried deleting the jar from gradle-repo (though Gradle download the hamcrest-core-1.3.jar again) Requesting help on this. Thanks a lot in advance.

Godin
  • 9,801
  • 2
  • 39
  • 76
Gameshark
  • 63
  • 1
  • 5
  • This seems to be similar to http://stackoverflow.com/questions/40173764/illegalstateexception-no-files-nor-directories-matching-for-non-existing-jar And I doubt that this has any relation to JaCoCo. – Godin Nov 14 '16 at 22:45
  • Found a way to fix it. SonarSqube requires non-empty "main" and "test" folders in "src" . Just place a placeholder code file and SonarQube will work. – Gameshark Nov 18 '16 at 00:51

0 Answers0