I am trying:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Werror</compilerArgument>
<fork>true</fork>
</configuration>
</plugin>
but with no joy. Any ideas now to get medieval on such errors as suggested at this blog post?
By using the workaround in this comment in the open jira issue for maven compiler plugin, the build can be failed for compiler warning.
This works for me:
EDIT: This answer is outdated however I can't delete it as it was an accepted answer at the time.
Tis a bug with Maven see: http://jira.codehaus.org/browse/MCOMPILER-120 it's been fixed in 2.4 of the Maven-compiler-plugin but I don't believe that's been released yet. tag won't work either unfortunately.
New in
maven-compiler-plugin
3.6.0: thefailOnWarning
flag. This worked for me:Note that I had to exclude the
processing
lint or otherwise auto-matter's annotations would break the build with cryptic "symbol not found" errors.Update for the year 2015, using Maven 3.3 and Java 8.
Here's a minimal compiler configuration that enables all warnings and makes the build fail whenever warnings occur.
Bits of note:
<showWarnings>true</showWarnings>
is required. For reasons unknown, Maven by default actively suppresses warnings with the-nowarn
flag, so the-Xlint
and-Werror
flags would be ignored.showDeprecation
doesn't need to be enabled because-Xlint:all
already emits deprecation warnings.fork
doesn't need to be enabled, even though the documentation says otherwise.There is an alternate form perhaps give it a try? Note the s on the end of
<compilerArguments>