更多:作者   提 Bug   

An Error Prone plugin that checks for usages of Guava APIs that are annotated with the @Beta annotation. Such APIs should never be used in library code that other projects may depend on; using the Beta Checker can help library projects ensure that they don't use them.

Example error:

src/main/java/foo/ error: [BetaApi] @Beta APIs should not be used in library code as they are subject to change.
    Files.copy(a, b);


Using the Beta Checker requires configuring your project to build with the Error Prone Java compiler. By default, this enables a lot of useful checks for a variety of common bugs. However, if you just want to use the Beta Checker, the other checks can be disabled.

The usage examples below will show how to use the Beta Checker only, with notes for what to remove if you want all checks.


In pom.xml:

        <!-- Remove these compilerArgs to keep all checks enabled -->
          <!-- override plexus-compiler-javac-errorprone's dependency with the
               latest Error Prone version -->


Your build.gradle file(s) should have the following things. Add them to what's already in your files as appropriate.

// Add the gradle plugins that are needed for Error Prone plugin support
buildscript {
  repositories {
    maven {
      url ""
  dependencies {
    classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
    classpath "net.ltgt.gradle:gradle-apt-plugin:0.12"

repositories {

apply plugin: 'java'

// Enable Error Prone and APT plugins
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'net.ltgt.apt'

dependencies {
  // Add an APT dependency on the beta checker
  apt '$betaCheckerVersion'

configurations.errorprone {
  resolutionStrategy.force ''

compileJava {
  // Remove these compilerArgs to keep all checks enabled
  options.compilerArgs += ["-XepDisableAllChecks", "-Xep:BetaApi:ERROR"]


Bazel Java targets use the Error Prone compiler by default. To use the Beta Checker with Bazel, you'll need to create a java_plugin target for the Beta Checker and then add that target to the plugins attribute of any Java targets it should run on.

TODO: Add an example of how to do this.

Android 开发经验分享
Android 开发经验分享