Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use AllErrorsAsWarnings flag in Maven #1226

Closed
cojoco opened this issue Feb 12, 2019 · 3 comments
Closed

Unable to use AllErrorsAsWarnings flag in Maven #1226

cojoco opened this issue Feb 12, 2019 · 3 comments

Comments

@cojoco
Copy link

cojoco commented Feb 12, 2019

Description of the problem / feature request:

I am unable to downgrade all errors to warnings using the '-XepAllErrorsAsWarnings' flag (as seen here)

When I run mvn compile without the flag, I (correctly) get the following error:

[ERROR] /Users/ccook/projects/test-app/src/main/java/com/testgroup/testapp/App.java:[15,8] error: [DeadException] Exception created but not thrown
    (see https://errorprone.info/bugpattern/DeadException)
  Did you mean to remove this line?

When I run with the flag, I get the following error:

[ERROR] javac: invalid flag: -XepAllErrorsAsWarnings
Usage: javac <options> <source files>
use --help for a list of possible options

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Run mvn compile in the same directory as the pom.xml in the unzipped test-app
test-app.zip

What version of Error Prone are you using?

2.3.2

I am also using Maven version 3.5.4 and Java version 1.8.0_181 on OS X (updated to Mojave).

Have you found anything relevant by searching the web?

Unfortunately not. I'm guessing I'm just doing something wrong, since nobody else seems to be having this issue.

@Stephan202
Copy link
Contributor

You're hit by a Java 8-specific issue, described in #1115.

Possible fix:

diff --git a/pom.xml b/pom.xml
index 9e25de2..2a9030b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,8 +35,7 @@
           <target>8</target>
           <compilerArgs>
             <arg>-XDcompilePolicy=simple</arg>
-            <arg>-Xplugin:ErrorProne
-                 -XepAllErrorsAsWarnings</arg>
+            <arg>-Xplugin:ErrorProne -XepAllErrorsAsWarnings</arg>
           </compilerArgs>
           <annotationProcessorPaths>
             <path>

Or if you plan to add many more flags:

diff --git a/pom.xml b/pom.xml
index 9e25de2..77a6785 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,8 +35,8 @@
           <target>8</target>
           <compilerArgs>
             <arg>-XDcompilePolicy=simple</arg>
-            <arg>-Xplugin:ErrorProne
-                 -XepAllErrorsAsWarnings</arg>
+            <arg>-Xplugin:ErrorProne<!--
+            -->  -XepAllErrorsAsWarnings</arg>
           </compilerArgs>
           <annotationProcessorPaths>
             <path>

@cojoco
Copy link
Author

cojoco commented Feb 12, 2019

I tried the first fix. It did get rid of the error, but the compilation did not show the DeadException as a warning. Do I need to add another flag to get the warning to show?

@cojoco
Copy link
Author

cojoco commented Feb 12, 2019

I needed to add <showWarnings>true</showWarnings> to the maven-compiler-plugin configuration to get the warnings to show.

diff --git a/pom.xml b/pom.xml
index b5727d4..71c1aca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,9 +33,10 @@
         <configuration>
           <source>8</source>
           <target>8</target>
+          <showWarnings>true</showWarnings>
           <compilerArgs>
             <arg>-XDcompilePolicy=simple</arg>
-            <arg>-Xplugin:ErrorProne</arg>
+            <arg>-Xplugin:ErrorProne -XepAllErrorsAsWarnings</arg>
           </compilerArgs>
           <annotationProcessorPaths>
             <path>

I think that's all I needed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants