Python 无法扫描maven项目中的其他文件夹
我有一个maven项目,它包含几个文件夹,每个文件夹都有多个python类。大概是这样的:Python 无法扫描maven项目中的其他文件夹,python,maven,sonarqube,pom.xml,Python,Maven,Sonarqube,Pom.xml,我有一个maven项目,它包含几个文件夹,每个文件夹都有多个python类。大概是这样的: MyProject | |-- folder1 | |-- a.py | |-- b.py | |-- folder2 | |-- c.py | |-- d.py | | -- pom.xml <build> <plugins> <plugin&g
MyProject
|
|-- folder1
| |-- a.py
| |-- b.py
|
|-- folder2
| |-- c.py
| |-- d.py
|
| -- pom.xml
<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>
由于这不是传统的程序结构(src/main/)
我很难让SonarQube扫描folder1
和folder2
中的python。它只是忽略了它们
我认为解决方案是将它们添加为pom中的附加src目录,如下所示:
MyProject
|
|-- folder1
| |-- a.py
| |-- b.py
|
|-- folder2
| |-- c.py
| |-- d.py
|
| -- pom.xml
<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>
org.codehaus.mojo
构建助手maven插件
生成源
添加源
折叠1
折叠2
但库贝仍然忽视了它们。如何在pom中指定要扫描的其他文件夹?由于您的源文件不是Maven分析希望找到的位置,因此您需要明确给出它们的位置。在分析命令行上使用
-Dsonar.sources=…
最容易做到这一点,为什么Java项目中有python类?他们提供了什么用途?谢谢,这就是我最终选择的解决方案