问题描述
命令 mvn sonar:sonar 执行哪些 maven 生命周期阶段?
what are the maven lifecycle phases does the command mvn sonar:sonar execute?
当我看到在屏幕上运行的日志时,在我发现的非常高级的 test, install 上.
while i see the logs that run over the screen, at a very high level test, install that i spotted out.
考虑以下示例,
我有一个像下面这样的 maven 项目
i have a maven project like the following
maven-root maven-child-1 maven-child-2
考虑以下场景,我在根级别按顺序完成了它们
consider the following scenario, i have done them sequentially at root level
- mvn 全新安装
- mvn sonar:sonar -- 查看报告
- 通过添加一些测试用例来修改 child-2 以增加代码覆盖率
- 运行 mvn sonar:sonar
- mvn clean install
- mvn sonar:sonar -- see the report
- modified child-2 by adding some test cases to increase the code coverage
- run mvn sonar:sonar
我对测试用例的更改未反映在报告中.
my changes for the test cases are not reflecting in the report.
- 我已从 sonarqube 中删除报告
- mvn 声纳:声纳
仍然会生成旧报告.
简而言之,我需要执行 mvn clean install 然后 mvn sonar:sonar 吗?
in brief, do i need to perform mvn clean install and then mvn sonar:sonar ?
如果 mvn sonar:sonar 涵盖执行 mvn clean install,为什么报告给我旧数字?
if mvn sonar:sonar covers executing the mvn clean install, why the report gives me old numbers?
推荐答案
mvn sonar:sonar 不会触发 mvn clean install 执行.它仅触发 maven surefire 插件执行.
mvn sonar:sonar does not trigger a mvn clean install execution. it triggers a maven surefire plugin execution only.
这就是为什么您需要在每次分析之前执行 mvn clean install - 否则您编译的类将不是最新的,因此 surefire 执行将不包括最近的修改.
this is why you need to perform a mvn clean install before each analysis - otherwise your compiled classes won't be up-to-date and therefore the surefire execution won't include recent modifications.