maven - Maven 丢失了 checkstyle 配置
问题描述
我尝试将自定义checkstyle.xml
配置而不是标准连接sun_checks.xml
到这个项目。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<configuration>
<configLocation>src/main/resources/checkstyle.xml</configLocation>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
但是mvn -B clean verify checkstyle:checkstyle
得到输出sun_checks.xml
[INFO] There are 206 errors reported by Checkstyle 8.29 with sun_checks.xml ruleset.
为什么<configLocation>
会被忽略,以及如何修复它?
解决方案
您好@Pavel 尝试在您的源代码之外使用 checkstyle.xml,并且还可以选择设置目标。它应该可以解决您的问题。
<properties>
<checkstyle.configLocation>src/checkstyle/checkstyle.xml</checkstyle.configLocation>
<checkstyle.suppressionsLocation>src/checkstyle/suppressions.xml</checkstyle.suppressionsLocation>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
<!-- for java
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.26</version>
</dependency>
</dependencies>
-->
<configuration>
<configLocation>${checkstyle.configLocation}</configLocation>
<suppressionsLocation>${checkstyle.suppressionsLocation}</suppressionsLocation>
<sourceDirectories>
<sourceDirectory>src/main/java</sourceDirectory>
<sourceDirectory>src/test/java</sourceDirectory>
</sourceDirectories>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
推荐阅读
- angular - 如何将搜索结果的计数添加到代码镜像中
- azure - 我无法将 Azure 存储标准迁移到高级版
- c# - 在另一个脚本中无法访问 bool
- python - 无法使用 snowflake-connector-python v1.9 建立连接
- azure - CPU / DTU 在 Azure SQL 数据库上达到极限,但热门查询不到 1%,数据库只有几 MB
- antlr - 能够明确定义“规则元素标签”
- python - 解析 ascii,转义 JSON 字符串 Python 3.6
- python - 如何在 python 中限制下载的文件大小?
- terminal - Mac mojave - sudo uid 重置
- javascript - 在不同的函数调用中使用插值作为字符串