tim*_*ord 8 java maven sonarqube
我有一个由几个模块组成的项目.
我正试图用SonarQube分析这些.
我在每个模块中都包含了Sonar Maven插件作为依赖项:
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>5.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
然后我使用以下方式运行Maven:
mvn clean verify声纳:声纳
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>
Run Code Online (Sandbox Code Playgroud)
由于它是一个多模块项目,因此您应首先从根项目执行安装,然后将该sonar:sonar目标作为专用步骤运行,如下所示:
mvn clean install
mvn sonar:sonar
Run Code Online (Sandbox Code Playgroud)
要配置sonarqube服务器URL,请在您的或如下指定项目属性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>
Run Code Online (Sandbox Code Playgroud)