Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Reformat bugcheckers Feb 21, 2019
.gitignore Initial commit Oct 23, 2017
LICENSE Initial commit Oct 23, 2017

Guava Beta Checker

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 -->
            <!-- Disable Beta Checker for tests -->
          <!-- 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 add a maven_jar dependency on the Beta Checker, then create a java_plugin target for it, and finally add that target to the plugins attribute of any Java targets it should run on.


You'll need a java_library for the Beta Checker. You can get this using generate-workspace, by running a command like:

bazel run //generate_workspace -- \

After putting the generated generate_workspace.bzl file in your project as described in the documentation, put the following in third_party/BUILD:

load("//:generate_workspace.bzl", "generated_java_libraries")

    name = "guava_beta_checker_plugin",
    deps = [":com_google_guava_guava_beta_checker"],
    visibility = ["//visibility:public"],

Finally, add the plugin to the plugins attribute of any Java target you want to be checked for usages of @Beta APIs:

    name = "foo",
    srcs = glob(["*.java"]),
    deps = [
    plugins = [
You can’t perform that action at this time.