SonarQube 不扫描 Maven 项目中的其他文件夹
SonarQube not scanning additional folders in maven project
我有一个包含多个文件夹的 Maven 项目,每个文件夹有多个 python 类。像这样:
MyProject
|
|-- folder1
| |-- a.py
| |-- b.py
|
|-- folder2
| |-- c.py
| |-- d.py
|
| -- pom.xml
因为这不是传统的程序结构 (src/main/..)
我很难让 SonarQube 扫描 folder1
和 folder2
内的 python。它只是忽略它们。
我认为解决方案是将它们添加为 pom 中的附加 src 目录,如下所示:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>folder1</source>
<source>folder2</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
但 SonarQube 仍然忽略它们。如何在 pom 中指定要扫描的其他文件夹?
由于您的源文件不在 Maven 分析期望找到它们的位置,因此您需要明确提供它们的位置。使用 -Dsonar.sources=...
在分析命令行上执行此操作最简单
我有一个包含多个文件夹的 Maven 项目,每个文件夹有多个 python 类。像这样:
MyProject
|
|-- folder1
| |-- a.py
| |-- b.py
|
|-- folder2
| |-- c.py
| |-- d.py
|
| -- pom.xml
因为这不是传统的程序结构 (src/main/..)
我很难让 SonarQube 扫描 folder1
和 folder2
内的 python。它只是忽略它们。
我认为解决方案是将它们添加为 pom 中的附加 src 目录,如下所示:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>folder1</source>
<source>folder2</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
但 SonarQube 仍然忽略它们。如何在 pom 中指定要扫描的其他文件夹?
由于您的源文件不在 Maven 分析期望找到它们的位置,因此您需要明确提供它们的位置。使用 -Dsonar.sources=...