我希望通过Eclipse IDE中的maven构建(使用外部maven)生成检查样式违规,例如当您使用checkstyle检查代码时,如何使用checkstyle违规发布java文件。
我可以使用eclipse checkstyle插件显式运行我的文件,但我的项目要求是使用maven build运行。
有没有办法实现这个目标?我找不到关于这个问题的任何链接。
答案 0 :(得分:0)
就个人而言,我通过运行checkstyle的Sonar来做到这一点。我在本地安装了Sonar并将以下配置文件添加到我的maven项目中(您也可以将它添加到您的个人〜/ .m2 / settings.xml):
<profile>
<id>sonar</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>jdbc:postgresql://localhost:5432/sonar</sonar.jdbc.url>
<sonar.jdbc.driver>org.postgresql.Driver</sonar.jdbc.driver>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://localhost:7080/sonar</sonar.host.url>
</properties>
</profile>
现在,您可以使用以下命令在项目上运行Sonar:
mvn sonar:sonar -Psonar
In Eclipse, you need to install the Sonar plugin。它允许您直接在Eclipse中运行本地分析或检索远程结果。在这两种情况下,违规和问题都会添加到Eclipse警告/消息对话框中,以便您可以轻松跟进。