我在 Maven 构建中添加了 checkstyle 但由于某种原因它只检查 src/main 文件夹并忽略 src/test 文件夹,这是我的项目结构:
Proj
- Module A
- src
- main
- java
- resources
- test
- java
- resources
- Module B
- src
- main
- java
- resources
- test
- java
- resources
pom.xml
checkstyle.xml
和我的 pom.xml
<properties>
<checkstyle.version>3.0.0</checkstyle.version>
<checkstyle.config.location>checkstyle.xml</checkstyle.config.location>
<checkstyle.consoleOutput>true</checkstyle.consoleOutput>
<checkstyle.failOnViolation>true</checkstyle.failOnViolation>
<encoding>UTF-8</encoding>
</properties>
<build>
<pluginManagement>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.18</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<testSourceDirectories>src/test/java</testSourceDirectories>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>