Task 'sonarqube' fails with 'No files nor directories matching' error for gradle

  • Versions: Gradle 6.5.1, sonarqube-gradle-plugin 3.1.1, sonarqube 9.9.1
  • Deployed through: Docker

I am trying to scan a gradle project using AWS codebuild job. And here the settings for sonarqube task:

sonarqube {
    properties {
        property "sonar.junit.reportPaths", "${buildDir}/test-results/test"
        property "sonar.surefire.reportsPath", "${buildDir}/test-results/test"
        properties["sonar.java.test.binaries"] += "$buildDir/classes/java/test"
    }
}

However, the job fails with below error (local-repo is just a directory I am creating and cloning the project to during the pre-build phase in the buildspec.yaml) :

Invalid value for 'sonar.java.test.binaries' property.
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonarqube'.
> No files nor directories matching '/codebuild/output/src1234567/src/local_repo/test-gradle-project/build/classes/java/test'
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org

When I run it locally, I see the directory does exist and also the binaries. Here is the directory structure from my local (I have truncated the list):

./buildspec.yaml
./README.md
./gradle
./gradle/wrapper
./gradle/wrapper/gradle-wrapper.jar
./gradle/wrapper/gradle-wrapper.properties
./gradlew
./.gitignore
./test-gradle-project
./test-gradle-project/build.gradle
./test-gradle-project/gretty.plugin
./test-gradle-project/build
./test-gradle-project/build/generated
./test-gradle-project/build/generated/sources
./test-gradle-project/build/generated/sources/headers
./test-gradle-project/build/generated/sources/headers/java
./test-gradle-project/build/generated/sources/headers/java/test
./test-gradle-project/build/generated/sources/headers/java/main
./test-gradle-project/build/generated/sources/annotationProcessor
./test-gradle-project/build/generated/sources/annotationProcessor/java
./test-gradle-project/build/generated/sources/annotationProcessor/java/test
./test-gradle-project/build/generated/sources/annotationProcessor/java/main
./test-gradle-project/build/classes
./test-gradle-project/build/classes/java
./test-gradle-project/build/classes/java/test
./test-gradle-project/build/classes/java/test/com
./test-gradle-project/build/classes/java/test/com/test
./test-gradle-project/build/classes/java/test/com/test/gateway
./test-gradle-project/build/classes/java/test/com/test/gateway/integration
./test-gradle-project/build/classes/java/test/com/test/gateway/integration/rest
./test-gradle-project/build/classes/java/test/com/test/gateway/integration/rest/resources
./test-gradle-project/build/classes/java/test/com/test/gateway/integration/rest/resources/AbstractJerseyIntegrationTest$SpringAwareGrizzlyWebTestContainer.class
./test-gradle-project/build/classes/java/test/com/test/gateway/integration/rest/resources/GatewayResourceIntegrationTest.class

Could you help me understand why I am still getting No files nor directories matching error?

Hey ther.e

This is really old! The latest version is v4.4.1. Can you use the latest version and see if the issue persists?

And, I’m not sure you need to be configuring this at all. It should get automatically configured.

Hello Colin,

Thank you the suggestions. I will try removing the property from the build.gradle first and see how it goes.

Thanks,
Yogesh

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.