Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

The library sonar-ws-client is intented to help Java developers to use the Sonar SonarQube web services.

Installation

...

Code Block
xml
xml
<dependency>
  <groupId>org.codehaus.sonar</groupId>
  <artifactId>sonar-ws-client</artifactId>

  <!-- It is recommended to use the same version as the requested sonarSonarQube server -->
  <version>2.11</version>
</dependency>
<dependency>
  <groupId>commons-httpclient</groupId>
  <artifactId>commons-httpclient</artifactId>
  <version>3.1</version>
</dependency>

...

But be careful of the critical bug HTTPCLIENT-1140, use version  >4.1.2. It can end up in an infinite loop. 

Using

...

Client

...

Creating Client

Code Block
java
java
import org.sonar.wsclient.Sonar;
Sonar sonar = Sonar.create("http://localhost:9000");

...

Code Block
Sonar sonar = new Sonar(new HttpClient4Connector(new Host("http://localhost:9000")));

Executing

...

Requests

For example to the get the code coverage of the 'Struts' project:

...

The methods find() and findAll() accept queries to get measures, code source, rule violations, configuration, metric definitions and dependencies between resourcescomponents. See Javadoc for more information.

...