我在我的项目中使用IntelliJ和Maven,我必须使用SonarQube分析它,但是当我使用webApp提供的命令扫描我的项目时,它只分析pom.xml文件,而忽略了项目的其余部分。
干净安装声纳: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's 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。
发布于 2018-10-07 18:03:03
所以,问题是IntelliJ是用Java开发工具包11配置的,我降级到Java开发工具包8u181,并配置了POM,这样Maven就可以处理这些更改,我再次执行扫描程序,它就可以工作了。
对pom.xml的更改:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<sonar.sources>src/main/java</sonar.sources>
</properties>
添加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
发布于 2018-10-07 05:08:14
Sonarqube通过分析jacoco输出来工作。我在你的pom里没有看到任何jacoco的配置。https://www.petrikainulainen.net/programming/maven/creating-code-coverage-reports-for-unit-and-integration-tests-with-the-jacoco-maven-plugin/是一个关于如何设置它的很好的教程。
你还必须告诉sonarqube你的jacoco.exec文件在哪里。https://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project
https://stackoverflow.com/questions/52685593
复制相似问题