maven - sonar-maven-plugin:如何在包含模式中使用项目相对路径?
问题描述
我有一个相当大的多模块多语言 maven 项目(总共约 100 个模块),我想使用 SonarQube 进行分析,因为扫描仪不会自动发现所有语言的所有文件(即不适用于 Groovy 和 Kotlin) ,我必须告诉它在哪里查找文件。
大多数模块包含 asrc/main/
和 asrc/test/
目录的典型组合,但不一定两者都包含,这使得在顶级 pom 中简单地声明<sonar.sources>pom.xml,src/main/</sonar.sources>
和作为属性是不可能的,因为缺少目录会导致 maven 中止并出现错误。<sonar.tests>src/test/</sonar.tests>
根据https://stackoverflow.com/a/37545474,解决此问题的一种可能方法是设置...
sonar.sources
成为.
sonar.inclusions
成为src/main/**
- => 这将包括 SQ 在 src/main 文件夹中的模块中找到的所有已知文件(如果存在)
并且只使用
<sonar.sources>.</sonar.sources>
<sonar.tests>.</sonar.tests>
<sonar.inclusions>pom.xml,src/main/**</sonar.inclusions>
<sonar.test.inclusions>src/test/**</sonar.test.inclusions>
在顶级 pom 中确实按预期工作(所有应该分析的文件都被发现,并且由于缺少目录而没有报告错误),但它也会导致以下警告,该警告也显示在 SonarQube 中:
[WARNING] Specifying module-relative paths at project level in the property 'sonar.inclusions' is deprecated. To continue matching files like 'frontend/pom.xml', update this property so that patterns refer to project-relative paths.
到目前为止,我尝试的所有路径要么导致总共分析较少的文件,要么导致错误,因为单个文件将被多次索引,因为包含模式产生的非不相交集。因此问题...
如何*.inclusions
在分析所有子模块中的所有文件的同时使用属性来消除警告?
解决方案
绿色,
我在使用 Jenkins 管道时遇到了同样的问题。我解决了包括“projectBaseDir”参数,如下所示:
<properties>
<sonar.projectBaseDir>.</sonar.projectBaseDir>
</properties>
推荐阅读
- python - Pros and cons of using shared Value/Array vs Queue/Pipe in Python multiprocessing
- python - 如何将一个元素列表转换为浮点数
- node.js - DynamoDB 返回未定义但在 console.log() 中记录数据,异步问题?
- html - 文字从卡片中出来并覆盖图像
- r - 循环我在 R 中的数据框列表上创建的函数
- svn - svn update 不替换已删除 --- 但未签入 --- 文件
- json - Json 到数据库而不覆盖数据库 sqlalchemy 中的先前数据
- python - 尽管使用了较早且已经工作的代码,但指针没有向上或向下移动
- python - 子类Python中的父类对象
- javascript - 最后一个元素被排除在外