Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Eclipse Warnings when compiling with maven?

I have a Java project using m2eclipse. In my Eclipse, I get several Warnings.

How can I display those warnings in my maven compilation? I want to use warnings-plugin on jenkins to keep track of the number of warnings.

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

E.g.

"The value of ... is not used" warnings don't show up.

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

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

like image 837
Thomas M. Avatar asked Aug 20 '12 13:08

Thomas M.


1 Answers

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

The warnings are generated by a specific compiler, to prevent the error "no such compiler: eclipse" the dependency to the plexus-compiler is included.

Hope this works for others as well :)

    <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>
like image 146
Thomas M. Avatar answered Oct 04 '22 20:10

Thomas M.