mvn checkstyle 插件:google_checks 未达到
mvn checkstyle plugin: google_checks no reached
maven checkstyle 插件告诉我它默认使用 sun_checks.xml
:
INFO] There are 5 errors reported by Checkstyle 8.29 with sun_checks.xml ruleset.
我的意思是,我没有在我的项目中找到任何 sun_checks.xml
来告诉 checkstyle 插件使用这个文件。
所以,我猜,插件默认提供了这个文件。
根据to documentation,插件默认有两个可用的检查规则集:sun_checks.xml
和google_checks.xml
。
我已经尝试更改它:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-plugin.version}</version>
<configuration>
<configLocation>google_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
执行 mvn checkstyle:check
目标后,它告诉我它正在使用 sun_checks.xml
而不是 google_checks.xml
:
$ mvn checkstyle:check
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< net.gencat.clt.arxius:backend >--------------------
[INFO] Building backend 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-checkstyle-plugin:3.1.1:check (default-cli) @ backend ---
[INFO] There are 4 errors reported by Checkstyle 8.29 with sun_checks.xml ruleset.
[ERROR] src/main/java/net/gencat/clt/arxius/backend/BackendApplication.java:[1] (javadoc) JavadocPackage: Missing package-info.java file.
[ERROR] src/main/java/net/gencat/clt/arxius/backend/BackendApplication.java:[6,1] (design) HideUtilityClassConstructor: Utility classes should not have a public or default constructor.
[ERROR] src/main/java/net/gencat/clt/arxius/backend/BackendApplication.java:[9,1] (whitespace) FileTabCharacter: File contains tab characters (this is the first instance).
[ERROR] src/main/java/net/gencat/clt/arxius/backend/BackendApplication.java:[9,9] (javadoc) MissingJavadocMethod: Missing a Javadoc comment.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.265 s
[INFO] Finished at: 2020-10-21T10:45:52+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.1:check (default-cli) on project backend: You have 4 Checkstyle violations. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
有什么想法吗?
您正在使用 <reporting>
标签下的 google_checks.xml。你可以像这样保持它,但 repoting 标签如 maven.apache.org 所说:插件实际上不是报告插件本身。但是它的一个(或多个)目标或 Mojos 可能专门由 maven-site-plugin 调用,通常在站点构建生命周期中。
如果你想使用 mvn checkstyle:check 目标你还需要:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>google_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</build>
maven checkstyle 插件告诉我它默认使用 sun_checks.xml
:
INFO] There are 5 errors reported by Checkstyle 8.29 with sun_checks.xml ruleset.
我的意思是,我没有在我的项目中找到任何 sun_checks.xml
来告诉 checkstyle 插件使用这个文件。
所以,我猜,插件默认提供了这个文件。
根据to documentation,插件默认有两个可用的检查规则集:sun_checks.xml
和google_checks.xml
。
我已经尝试更改它:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-plugin.version}</version>
<configuration>
<configLocation>google_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</reporting>
执行 mvn checkstyle:check
目标后,它告诉我它正在使用 sun_checks.xml
而不是 google_checks.xml
:
$ mvn checkstyle:check
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< net.gencat.clt.arxius:backend >--------------------
[INFO] Building backend 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-checkstyle-plugin:3.1.1:check (default-cli) @ backend ---
[INFO] There are 4 errors reported by Checkstyle 8.29 with sun_checks.xml ruleset.
[ERROR] src/main/java/net/gencat/clt/arxius/backend/BackendApplication.java:[1] (javadoc) JavadocPackage: Missing package-info.java file.
[ERROR] src/main/java/net/gencat/clt/arxius/backend/BackendApplication.java:[6,1] (design) HideUtilityClassConstructor: Utility classes should not have a public or default constructor.
[ERROR] src/main/java/net/gencat/clt/arxius/backend/BackendApplication.java:[9,1] (whitespace) FileTabCharacter: File contains tab characters (this is the first instance).
[ERROR] src/main/java/net/gencat/clt/arxius/backend/BackendApplication.java:[9,9] (javadoc) MissingJavadocMethod: Missing a Javadoc comment.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.265 s
[INFO] Finished at: 2020-10-21T10:45:52+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.1:check (default-cli) on project backend: You have 4 Checkstyle violations. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
有什么想法吗?
您正在使用 <reporting>
标签下的 google_checks.xml。你可以像这样保持它,但 repoting 标签如 maven.apache.org 所说:插件实际上不是报告插件本身。但是它的一个(或多个)目标或 Mojos 可能专门由 maven-site-plugin 调用,通常在站点构建生命周期中。
如果你想使用 mvn checkstyle:check 目标你还需要:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>google_checks.xml</configLocation>
</configuration>
</plugin>
</plugins>
</build>