Search code examples
pythonmavensonarqubepom.xml

SonarQube not scanning additional folders in maven project


I have a maven project that contains several folders, each with multiple python classes. Something like this:

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

Since this is not a traditional program structure (src/main/..) I'm having difficulty getting SonarQube to scan the python within folder1 and folder2. It just ignores them.

I thought the solution would be to add them as additional src directories within the pom, like this:

<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>

But still SonarQube still ignores them. How do I specify in the pom additional folders I want to be scanned?


Solution

  • Since your source files aren't where a Maven analysis expects to find them, you do need to give their locations explicitly. It will be easiest to do that on the analysis command line with -Dsonar.sources=...