smp*_*p7d 5 checkstyle maven-plugin maven-3
我似乎无法弄清楚当我运行检查目标时如何让maven-checkstyle-plugin向控制台输出警告.
如果我配置为:
<module name="Checker">
<module name="TreeWalker">
<module name="NPathComplexity">
<property name="max" value="5" />
<property name="severity" value="warning" />
</module>
</module>
</module>
Run Code Online (Sandbox Code Playgroud)
...我在控制台看不到任何东西,检查不会失败.如果我将严重性更改为错误,则检查失败.
有任何想法吗?我错过了什么吗?
插件配置如下
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<logViolationsToConsole>true</logViolationsToConsole>
<configLocation>
rules.xml</configLocation>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我遇到了类似的问题.这个配置对我有用.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<consoleOutput>true</consoleOutput>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<goals>
<goal>checkstyle</goal>
</goals>
<phase>prepare-package</phase>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我假设您必须显式添加检查目标以将信息打印到控制台,如文档中所述。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execute>
<id>check</id>
<goals><goal>check</goal></goals>
<phase>prepare-package</phase>
<execute>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
根据您调用 mvn 的方式,您需要更改执行检查的阶段。maven-checkstyle-plugin 的默认绑定是 verfiy 阶段。要么在执行块中给出显式阶段,要么只执行 mvn clean verify 并且可以省略阶段条目。
| 归档时间: |
|
| 查看次数: |
3448 次 |
| 最近记录: |