为什么Maven命令MVN声纳:声纳在我的POM.xml中没有任何插件配置工作?

时间:2021-03-25 23:56:43

I have a Maven web project in my repo.

我的回购中有一个Maven Web项目。

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.

我是一个Maven noob,但我仍然明白我们需要配置插件才能运行插件特定命令。

Facts:

事实:

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

我有一个声纳服务器在我的本地机器上运行9000端口。

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

我没有在我的POM.xml中添加任何声纳特定插件

Reference:

参考:

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

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.

但是当我从命令行运行mvn声纳:声纳时,它工作正常。

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?

事实很重要的是我没有在我的POM.xml中配置声纳插件即使那时Maven正在拾取并理解“声纳:声纳”目标/命令?

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

我不想要声纳本身的工作知识。我想知道为什么mvn声纳:声纳无需在我的pom.xml中配置声纳插件

WHY and how?

为什么以及如何?

2 个解决方案

#1


45  

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)

原因是Sonar Maven插件托管在Codehaus Mojo项目中,并受益于groupId“org.codehaus.mojo”。这允许使用快捷方式“sonar:sonar”而不是“org.codehaus.mojo:sonar-maven-plugin :: sonar”(请参阅​​Maven文档的“配置Maven搜索插件”一节)

#2


4  

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.

Sonar有自己的一组插件(例如maven-checkstyle-plugin),它在调用时运行。这些插件根据配置的Sonar服务器中的项目设置自动配置。

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

它为您自动工作的原因是您正在使用声纳服务器安装的默认值(localhost:9000)。

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

这种“零配置”的方法在这里进一步详述:我们有一个梦想:mvn声纳:声纳

#1


45  

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)

原因是Sonar Maven插件托管在Codehaus Mojo项目中,并受益于groupId“org.codehaus.mojo”。这允许使用快捷方式“sonar:sonar”而不是“org.codehaus.mojo:sonar-maven-plugin :: sonar”(请参阅​​Maven文档的“配置Maven搜索插件”一节)

#2


4  

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.

Sonar有自己的一组插件(例如maven-checkstyle-plugin),它在调用时运行。这些插件根据配置的Sonar服务器中的项目设置自动配置。

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

它为您自动工作的原因是您正在使用声纳服务器安装的默认值(localhost:9000)。

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

这种“零配置”的方法在这里进一步详述:我们有一个梦想:mvn声纳:声纳