Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

note
Info
iconfalse
titleTable of Contents

Table of Contents

maxLevel

To use Sonar in Eclipse on a project, it is required that the project has been first analyzed in a standard way by Sonar.

Setting Sonar Servers

1

To take full advantage of SonarQube in Eclipse, it is recommended that your project be analyzed on a regular basis by SonarQube. Regular analysis allows the Eclipse plugin to distinguish between existing issues and any new ones you introduced.

If your project is not already under analysis, you'll need to declare it through the SonarQube web interface. 

Once your project exists in SonarQube, you're ready to get started with SonarQube in Eclipse.

Setting SonarQube Servers

Go to Window > Preferences > SonarQube > Servers.

SonarQube in Eclipse is pre-configured to access a local Sonar SonarQube server listening on http://localhost:9000/. To use another address, you first need to define this server by using the Eclipse global Preferences window:

Image Removed

Linking Projects to Sonar Servers

Once the Sonar server(s) is(are) You can edit this server, delete it or add new ones.

The user you set to access the server has to be granted the Execute Preview Analysis permission.
Image Added

Linking a Project to One Analyzed on a SonarQube Server

Linking for the first time

Once the SonarQube server is defined, the next step is to link your Eclipse projects project with projects a project defined and analyzed on Sonar server(s). This linkage operation can be done by right-clicking on the the project in the "Package explorer", and then by choosing "Configure -> Associate with Sonar...":

Image Removed
Image Removed

Note

In some cases the Eclipse project may not be automatically associated to a Sonar project. If that happens, you need to manually enter the groupId and the artifactId of the Sonar project.
For instance for the following Sonar project http://nemo.sonarsource.org/dashboard/index/org.codehaus.sonar-plugins:sonar-flex-plugin, the groupId is "org.codehaus.sonar-plugins" and the artifactId is "sonar-flex-plugin".

Unlinking a Project from Sonar Server

This operation can be done by right-clicking on the the project in the "Package explorer", and then by choosing "Configure -> Remove Sonar Nature":

Image Removed

Configuring Mylin to deal with Reviews

A Sonar Mylyn connector allows to track reviews.

Creating a Sonar Task Repository

 To start using this feature, a new Sonar task repository has to be created (see the Mylyn documentation page for more information):

Image Removed

Note
titleValidate Settings limitation

Validate Settings returns Authentication credentials are valid even if you have not entered correct credentials (Username/Password).

So, make sure to correctly deal with your credentials otherwise you will not be able to retrieve any review.

 

You new repository should now appear in the Task Repositories view:

Image Removed

Creating a Query

To browse the reviews, you can create as many queries as you wish:

Image Removed

Here's an example of a query that retrieves all the reviews assigned to you on every project:

Image Removed

The reviews should now appear in the Task List view:

Image Removed

 

on this SonarQube server.

To do so, right-click on the project in the Project Explorer, and then Configure > Associate with SonarQube...:

Image Added

In the SonarQube project text field, start typing the name of the project and select it in the list box:

Image Added

Click on Finish. Your project is now associated to one analyzed on your SonarQube server.

Info
titleAutomatic association for Maven projects
Note that for Maven projects, the association is performed automatically.

Changing linkage

At any time, it is possible to change the project association.

To do so, right-click on the project in the Project Explorer, and then SonarQube > Change Project Association...:

Image Added

Unlinking a Project

To do so, right-click on the project in the Project Explorer, and then SonarQube > Remove SonarQube Nature:

Image Added

Advanced Configuration

Additional settings (such as markers for new issues) are available through Window > Preferences > SonarQube:

Image Added

You are now all set with configuration and you can start using Sonar SonarQube in Eclipse.