Skip to content

Commit

Permalink
Update "Command-line flags" page with -Xplugin instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan202 authored and cushon committed May 16, 2020
1 parent 4c29d5a commit c8f2c17
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
23 changes: 18 additions & 5 deletions docs/flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ public class MyChecker extends BugChecker implements SomeTreeMatcher {
## Maven

To pass Error Prone flags to Maven, use the `compilerArgs` parameter in the
plugin's configuration. To enable warnings, the `showWarnings` parameter must
also be set:
plugin's configuration. The flags must be appended to the `arg` entry
containing `-Xplugin:ErrorProne`. To enable warnings, the `showWarnings`
parameter must also be set:

```xml
<project>
Expand All @@ -117,15 +118,27 @@ also be set:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerId>javac-with-errorprone</compilerId>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xep:DeadException:WARN</arg>
<arg>-Xep:GuardedBy:OFF</arg>
<arg>-XDcompilePolicy=simple</arg>
<arg>-Xplugin:ErrorProne -Xep:DeadException:WARN -Xep:GuardedBy:OFF</arg>
</compilerArgs>
</configuration>
</build>
</plugins>
</plugin>
</project>
```

Be aware that when running on JDK 8 the flags cannot be wrapped across multiple
lines. JDK 9 and above do allow the flags to be separated by newlines. That is,
the second `<arg>` element above can also be formatted as follows on JDK 9+,
but *not* on JDK 8:

```xml
<arg>
-Xplugin:ErrorProne
-Xep:DeadException:WARN
-Xep:GuardedBy:OFF
</arg>
```
3 changes: 3 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ directory for a working example:
[INFO] ------------------------------------------------------------------------
```

See the [flags documentation](http://errorprone.info/docs/flags#maven) for details on
how to customize the plugin's behavior.

## Gradle

The gradle plugin is an external contribution. The documentation and code is at
Expand Down

0 comments on commit c8f2c17

Please sign in to comment.