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

后端 未结 4 812
广开言路
广开言路 2020-12-24 01:55

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 p

相关标签:
4条回答
  • 2020-12-24 02:17

    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

    0 讨论(0)
  • 2020-12-24 02:27

    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)

    0 讨论(0)
  • 2020-12-24 02:37

    I could be wrong but my assumption is that this capability typically comes from your settings.xml instead of our pom.xml file with Maven. I would assume that the <id>sonar</id> section specifies the name of the profile invoked when running mvn.

    This is merely a guess as opposed to a definitive answer at this time as other answers seemed to be missing the mark and I don't have the time to dig into the real answers myself at the moment.

    0 讨论(0)
  • 2020-12-24 02:39

    I could be wrong but my assumption is that this capability typically comes from your settings.xml instead of our pom.xml file with Maven. I would assume that the <id>sonar</id> section specifies the name of the profile invoked when running mvn.

    This is merely a guess as opposed to a definitive answer at this time as other answers seemed to be missing the mark and I don't have the time to dig into the real answers myself at the moment.

    References:

    • https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-maven/
    0 讨论(0)
提交回复
热议问题