我有一个使用 m2eclipse 的 Java 项目。在我的 Eclipse 中,我收到了几个警告。
如何在我的 Maven 编译中显示这些警告?我想在 jenkins 上使用 warnings-plugin 来跟踪警告的数量。
我找到了 this关于如何在 Maven 中启用警告的帖子,但它只给了我一小部分警告。
例如
"The value of ... is not used" warnings don't show up.
如何获得与 Eclipse 中显示的警告相同的警告? 感谢您的帮助:)
为清楚起见进行编辑:我想显示与 eclipse 中相同的警告,而不是 FindBugs、PMD 或 checkstyle 报告的其他错误
最佳答案
我终于找到了解决我的问题的方法,所以我想分享它:) 我将其添加到我的 pom 文件中,现在在使用 maven 进行编译期间会出现警告,并且我能够使用警告插件将它们包含到 jenkins 中。 我在第一次尝试中错过的重要事情是,插件需要在 pluginManagement 下。
警告由特定的编译器生成,以防止错误“没有这样的编译器:eclipse”,包括对 plexus-compiler 的依赖。
希望这也适用于其他人:)
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>eclipse</compilerId>
<source>1.6</source>
<target>1.6</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>1.8.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
关于java - 使用 Maven 编译时如何获取 Eclipse 警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12038718/