Search code examples
javabuildgradlelocalsonarqube

Sonar with Gradle Locally


We are trying to use Sonar for Code Analyzes locally

our plan is to host the project on travis in the future and make Sonar run there with gradle

our problem is that Sonar is always trying to connect to a server

what we have now in our build file is:

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'jacoco'
apply plugin: 'sonar'
/* other tasks*/
sonar {

  project {
  name = "Late-Term-Assignment"
  language = "java"
  version = "1.0" // whatever version you want here.
  withProjectProperties { props ->
     props["sonar.jacoco.reportPath"] = "${buildDir}/reports/jacoco/jacoco.exec"}
  }
}

the error that we get is:

* What went wrong:
Executin failed for task ':sonarAnalyze'.
> java.net.ConnectionException: Connection refused: connect

Is there any way to get Sonar to run on code that is stored locally?

best wishes and thank you in advance!


Solution

  • Sonar always analyzes code that is stored locally, but it writes analysis results to the configured JDBC database, and bootstraps itself from the configured Sonar server. I'm not aware of a way to do without this (it's kind of the point of Sonar).