Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

Table of Contents

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

Installation

Add the following maven dependencies to your pom:

Be careful, Commons HTTPClient depends on commons-logging. If you use SLF4J, you should replace commons-logging by jcl-over-slf4j:

Using HttpClient 4

It's possible to use the version 4 of Commons HTTPClient instead of version 3.1:

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

Using the Client

Create the client

If the security is enabled, you have to define the credentials:

When using the lib Commons HttpClient 4.0, the constructor is slightly different:

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 resources. See Javadoc for more information.

Project Sample

A sample project is available on github that can be browsed or downloaded: ws/manual-measure-ws

  • No labels