How to get Eclipse warnings when compiling with maven?

I have a Java project using m2eclipse. In my Eclipse I get a few warnings.

How can I display these warnings in my maven assembly? I want to use warnings-plugin for jenkins to track the number of warnings.

I found this article on how to enable warnings in maven, but that only gives me a small subset of warnings.

eg.

"Value ... not used" warnings are not displayed.

How can I get the same warnings as in Eclipse? Thanks for the help:)

Edit for clarity: I would like to display the same warnings as in eclipse, and not other errors reported by FindBugs, PMD or checkstyle

+6
source share
2 answers

I finally found a solution for my problem, so I want to share it :) I added this to my pom file, and now the warnings appear during compilation with maven, and I was able to include them in jenkins using the warning plugin. The important thing I missed in my first attempts was that plugins should be under the Management plugin.

Warnings are generated by a specific compiler in order to prevent the error "there is no such compiler: eclipse" that the plexor-compiler dependency is included.

Hope this works for others too :)

<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> 
+5
source

Better than eclipse warnings, you can use a static analysis tool like PMD and the right rules. Check out the Maven PMD plugin

Examples of rules you could use:

+2
source

Source: https://habr.com/ru/post/923286/


All Articles