Maven SonarQube multi module(Maven SonarQube 多模块)
问题描述
我有一个由几个模块组成的项目.
I have a project made up of several modules.
我正在尝试使用 SonarQube 分析这些.
I'm trying to analyse these with SonarQube.
我已将 Sonar Maven 插件作为依赖项包含在每个模块中:
I've included the Sonar Maven plugin as a dependency in each module:
<dependency>
  <groupId>org.codehaus.sonar</groupId>
  <artifactId>sonar-maven-plugin</artifactId>
  <version>5.1</version>
</dependency>
然后我正在使用以下方式运行 Maven:
Then I'm running Maven using:
mvn clean 验证声纳:声纳
mvn clean verify sonar:sonar
Maven 成功完成,我可以看到 Sonar 分析正在进行,但是当我打开 Sonar UI 时,模块在项目中不可见.
Maven completes successfully and I can see the Sonar analysis happening however when I open the Sonar UI, the modules aren't visible in projects.
不过……
如果我从单个模块目录运行 Maven 命令,它在项目中是可见的.
If I run the Maven command from an individual module directory, it is visible in projects.
感觉我遗漏了一些非常简单的东西,感谢任何帮助!
Feel I'm missing something very simple, appreciate any help!
推荐答案
把sonar-maven-plugin放到中,而不是作为依赖根pom.xml部分,如下:
Instead of as a dependency, put the sonar-maven-plugin in the <build> section of the root pom.xml, as follows:
<build>
    <plugins>
        <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.0.1</version>
        </plugin>
    </plugins>
</build>
由于它是一个多模块项目,您应该 首先从根项目执行安装,然后作为专用步骤运行 sonar:sonar 目标,如下所示:
And since it's a multi-module project, you should first perform an install from the root project and then run the sonar:sonar goal as a dedicated step, as follows:
mvn clean install
mvn sonar:sonar
要配置 sonarqube 服务器 URL,在 settings.xml 或 pom.xml 中指定 sonar.host.url 的项目属性,如下所示:
To configure the sonarqube server URL, specify a project property of sonar.host.url in your settings.xml or pom.xml as follows:
<properties>
    <!-- Optional URL to server. Default value is http://localhost:9000 -->
    <sonar.host.url>http://myserver:9000</sonar.host.url>
</properties>
                        这篇关于Maven SonarQube 多模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Maven SonarQube 多模块
				
        
 
            
        - value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
 - Jersey REST 客户端:发布多部分数据 2022-01-01
 - 将log4j 1.2配置转换为log4j 2配置 2022-01-01
 - Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
 - C++ 和 Java 进程之间的共享内存 2022-01-01
 - 从 finally 块返回时 Java 的奇怪行为 2022-01-01
 - Eclipse 插件更新错误日志在哪里? 2022-01-01
 - Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
 - Java包名称中单词分隔符的约定是什么? 2022-01-01
 - 如何使用WebFilter实现授权头检查 2022-01-01
 
						
						
						
						
						