Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the Maven command "mvn sonar:sonar" work without any plugin configuration in my "pom.xml"?

I have a Maven web project in my repo.

I am a Maven noob but still I understand the fact that there are plugins which we need to configure only then we could run plugin specific commands.

Facts:

I have a sonar server running on my local machine at port 9000.

I have not added any sonar specific plugin in my POM.xml

Reference:

http://www.sonarsource.org/we-had-a-dream-mvn-sonarsonar/

Observation:

But still when I run mvn sonar:sonar in my project from command line it works fine.

Matter of the fact is I have NOT configured sonar plugin in my POM.xml Even then from where the hell Maven is picking up and understanding "sonar:sonar" goal/command?

Question / curiosity:

I don't want the working knowledge of sonar itself. I want to know why mvn sonar:sonar works without configuring a sonar plugin in my pom.xml

WHY and how?

like image 605
Rakesh Waghela Avatar asked Feb 20 '13 12:02

Rakesh Waghela


People also ask

What does Mvn sonar sonar do?

The SonarScanner for Maven is a Maven plugin that allows you to execute SonarCloud code analysis via a regular Maven goal. As a Maven goal, the scanner is available anywhere Maven is available (locally, in CI services, etc.), without the need to manually download, set up, and maintain a separate installation.

How does Maven integrate with SonarQube?

Step1. Download the latest stable release of SonarQube and unzip it to your favorite directory. By default, the SonarQube runs on 9000 port. Now that, SonarQube Server is up and running we are good to integrate our project(Maven)into it and do the continuous inspection of code quality.


2 Answers

The reason is that the Sonar Maven Plugin is hosted at the Codehaus Mojo project and benefits from the groupId "org.codehaus.mojo". This allows to use the shortcut "sonar:sonar" instead of "org.codehaus.mojo:sonar-maven-plugin::sonar" (see the section "Configuring Maven to Search for Plugins" of the Maven documentation)

like image 134
Simon Brandhof - SonarSource Avatar answered Oct 21 '22 08:10

Simon Brandhof - SonarSource


Sonar has its own set of plugins (e.g. maven-checkstyle-plugin) which it is running when being invoked. These plugins are automatically configured according to your project settings in your configured Sonar server.

The reasoning behind this to have a controlled configuration in your sonar instance.

The reason it is working automatically for you is that you are using the default values for your sonar server installation (localhost:9000).

This 'zero-configuration' approach is further detailed here: We had a dream : mvn sonar:sonar

like image 39
Torsten Avatar answered Oct 21 '22 10:10

Torsten