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

Update "Command-line flags" page with -Xplugin instructions #1115

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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