【发布时间】:2019-03-12 03:22:12
【问题描述】:
我在我的项目中使用 IntelliJ 和 Maven,我必须使用 SonarQube 对其进行分析,但是当我使用 webApp 提供的命令扫描我的项目时,它只分析 pom.xml 文件而忽略了项目的其余部分。
clean install sonar:sonar -Dsonar.host.url=http://localhost:9000 -Dsonar.login="这里的对应键"
我的 pom.xml(项目标签里面是什么):
<groupId>cl.itau.simulacionCredito</groupId>
<artifactId>SimulacionCreditoIntelliJ</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.beust/jcommander -->
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.72</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<excludes>
<exclude>**/HomeTest.java</exclude>
<exclude>**/PropuestaTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M1</version>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.5.0.1254</version>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>SimulacionCredito</id>
<name>SimulacionCredito</name>
<url>file:C:\Users\Pc\IdeaProjects</url>
</repository>
</distributionManagement>
我也尝试在配置标签中使用这个:
<sonar.sources>src/main/java</sonar.sources>
这发生了:
我在 Maven 的 conf 中的 settings.xml:
<pluginGroups>
<pluginGroup>org.sonarsource.scanner.maven</pluginGroup>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
</mirrors>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.host.url>
http://localhost:9000
</sonar.host.url>
</properties>
</profile>
</profiles>
我一直在向 POM 添加内容,因为在尝试修复此问题时出现了不同的错误。
我安装了最新版本的 SonarQube。
【问题讨论】:
-
您是否还在本地主机上的 SonarQube 安装中安装了 Java 分析器? (我不记得它是否默认存在,或者您是否必须在安装时安装/启用它,以便在它分析的项目中使用......)
-
@moilejter SonarJava 默认情况下它就在那里(我不得不更新它)
-
能否请您在启用调试 (
-X) 的情况下发布来自 maven 的输出?
标签: java maven intellij-idea sonarqube