Gameshark
Gameshark

Reputation: 63

Sonar Gradle error on Invalid value of sonar.libraries

I was trying to configure Sonarqube against a Gradle project. The project has many subprojects under it. The relevant config in build.gradle of root project is as follows:

sonarqube {
    properties {
        property 'sonar.jdbc.url', ''
        property 'sonar.host.url', 'http://localhost'
        property 'sonar.jdbc.driver', 'oracle.jdbc.driver.OracleDriver'
        property 'sonar.jdbc.username', 'sonar'
        property 'sonar.jdbc.password', 'sonar'
        property 'sonar.projectName', 'ABC'
        property "sonar.exclusions", "src/test/**"
        property 'sonar.skippedModules', '1024m'
        }
    }

  sonarqube {
    properties {
        property "sonar.sources", "src"
        property "sonar.tests", "src/test"
        }
    }

In root project's build.gradle I have:

dependencies {
    classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2"
}

  allprojects  {
  apply plugin: 'java'
  if( rootProject == project ) {
    //Add sonar plugin to only root projects not subprojects.
   apply plugin: 'org.sonarqube'
  }
  }

When built, Gradle gives an error:

Invalid value of sonar.libraries for : Component1
09-Nov-2016 13:00:56    :sonarqube FAILED
09-Nov-2016 13:00:56    
09-Nov-2016 13:00:56    FAILURE: Build failed with an exception.
09-Nov-2016 13:00:56    
09-Nov-2016 13:00:56    * What went wrong:
09-Nov-2016 13:00:56    Execution failed for task ':sonarqube'.
09-Nov-2016 13:00:56    > No files nor directories matching '[/opt/gradle_repo/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar' in directory /opt/gradle_repo/caches

Went through http://sonarqube-archive.15.x6.nabble.com/Sonar-Eclipse-Plugin-Local-Analysis-Error-td5009991.html but couldn't get it working.

Upvotes: 4

Views: 6291

Answers (1)

Pedro Costa
Pedro Costa

Reputation: 56

I experienced the same issue and only got it working by downgrading to Sonarqube Gradle plugin version 2.1.

There is indeed a bug in the 2.2 plugin version that incorrectly sets the property 'sonar.libraries' as a single value, leaving the '[' and ']' chars behind, leading to the problem resolving the lib directories as you see in the stack-trace.

you can follow the issue here: https://github.com/SonarSource/sonar-scanner-gradle/pull/20

Update: version 2.2.1 was released and fixes this problem.

Upvotes: 4

Related Questions