gpt4 book ai didi

maven-checkstyle-plugin - checkstyle 不获取 src/test 文件夹

转载 作者:行者123 更新时间:2023-12-02 20:01:49 26 4
gpt4 key购买 nike

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

最佳答案

<plugin>下方设置配置标签,像这样:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.27</version>
</dependency>
</dependencies>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>

关于maven-checkstyle-plugin - checkstyle 不获取 src/test 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55712919/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com