SonarQube不扫描Maven项目中的其他文件夹

时间:2018-08-13 19:31:38

标签: python maven sonarqube pom.xml

我有一个maven项目,其中包含几个文件夹,每个文件夹都有多个python类。像这样:

MyProject
    |
    |-- folder1
    |      |-- a.py
    |      |-- b.py
    |
    |-- folder2
    |      |-- c.py
    |      |-- d.py
    |
    | -- pom.xml

因为这不是传统的程序结构(src/main/..),所以我很难让SonarQube扫描folder1folder2中的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中指定要扫描的其他文件夹?

1 个答案:

答案 0 :(得分:1)

由于您的源文件不在Maven分析希望找到的位置,因此您确实需要明确指定它们的位置。最简单的方法是在分析命令行上使用-Dsonar.sources=...