gpt4 book ai didi

java - Maven SonarQube 多模块

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:44:42 33 4
gpt4 key购买 nike

我有一个由多个模块组成的项目。

我正在尝试使用 SonarQube 分析这些。

我已将 Sonar Maven 插件作为依赖项包含在每个模块中:

<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>5.1</version>
</dependency>

然后我使用以下方法运行 Maven:

mvn clean verify sonar:sonar

Maven 成功完成,我可以看到 Sonar 分析正在进行,但是当我打开 Sonar UI 时,模块在项目中不可见。

然而...

如果我从单个模块目录运行 Maven 命令,它在项目中是可见的。

感觉我遗漏了一些非常简单的东西,感谢任何帮助!

最佳答案

不是作为依赖项,而是将 sonar-maven-plugin<build>根的部分 pom.xml ,如下:

<build>
<plugins>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.1</version>
</plugin>
</plugins>
</build>

因为这是一个多模块项目,你应该 first perform an install from the root project and then run the sonar:sonar goal as a dedicated step ,如下:

mvn clean install
mvn sonar:sonar

要配置 sonarqube 服务器 URL,specify a project property of sonar.host.url 在你的settings.xmlpom.xml如下:

<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>http://myserver:9000</sonar.host.url>
</properties>

关于java - Maven SonarQube 多模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36438281/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com