1

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!

Thor
  • 459
  • 4
  • 15

3 Answers3

1

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).

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • thank you for your answer, we decided to look for another way to do it, we used PMD to inspect the code. – Thor Nov 01 '14 at 22:26
0

We have Sonar server and we use SonarLint plugin configured in our IDE (IntelliJ IDEA). This plugin pointed to our Sonar server and in IDE appears warnings for code which have been checked on the fly according rules from our Sonar server.

Vyacheslav
  • 156
  • 1
  • 1
  • 10
0

In windows try this it will work.

./gradlew sonarqube -D "sonar.projectKey=<code>" -D "sonar.host.url=http://localhost:9000" -D "sonar.login=<code>"
sajeeth
  • 47
  • 2
  • 9