Guava Beta Checker

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

Лицензия

Лицензия

Категории

Категории

Guava Универсальные библиотеки Utility
Группа

Группа

com.google.guava
Идентификатор

Идентификатор

guava-beta-checker
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Guava Beta Checker
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Система контроля версий

Система контроля версий

https://github.com/google/guava-beta-checker

Скачать guava-beta-checker

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.google.guava/guava-beta-checker/ -->
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava-beta-checker</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.google.guava/guava-beta-checker/
implementation 'com.google.guava:guava-beta-checker:1.0'
// https://jarcasting.com/artifacts/com.google.guava/guava-beta-checker/
implementation ("com.google.guava:guava-beta-checker:1.0")
'com.google.guava:guava-beta-checker:jar:1.0'
<dependency org="com.google.guava" name="guava-beta-checker" rev="1.0">
  <artifact name="guava-beta-checker" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.google.guava', module='guava-beta-checker', version='1.0')
)
libraryDependencies += "com.google.guava" % "guava-beta-checker" % "1.0"
[com.google.guava/guava-beta-checker "1.0"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
com.google.auto.service : auto-service Необязательный jar 1.0-rc3
com.google.guava : guava Необязательный jar 23.2-jre

provided (1)

Идентификатор библиотеки Тип Версия
com.google.errorprone : error_prone_core jar 2.1.2

test (2)

Идентификатор библиотеки Тип Версия
com.google.testing.compile : compile-testing jar 0.12
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

Build Status Maven Central

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/MyClass.java:14: error: [BetaApi] @Beta APIs should not be used in library code as they are subject to change.
    Files.copy(a, b);
    ^
    (see https://github.com/google/guava/wiki/PhilosophyExplained#beta-apis)

Usage

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.

Maven

In pom.xml:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.8.0</version>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <annotationProcessorPaths>
          <path>
            <groupId>com.google.errorprone</groupId>
            <artifactId>error_prone_core</artifactId>
            <version>2.3.3</version>
          </path>
          <path>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-beta-checker</artifactId>
            <version>${betachecker.version}</version>
          </path>
        </annotationProcessorPaths>
      </configuration>
      <executions>
        <execution>
          <id>default-compile</id>
          <phase>compile</phase>
          <goals>
            <goal>compile</goal>
          </goals>
          <configuration>
            <compilerArgs>
              <arg>-XDcompilePolicy=simple</arg>
              <!-- Remove -XepDisableAllChecks to keep all checks enabled -->
              <arg>-Xplugin:ErrorProne -XepDisableAllChecks -Xep:BetaApi:ERROR</arg>
            </compilerArgs>
          </configuration>
        </execution>
        <execution>
          <id>default-testCompile</id>
          <phase>test-compile</phase>
          <goals>
            <goal>testCompile</goal>
          </goals>
          <configuration>
            <!-- Disable Beta Checker for tests
                 NOTE: in this specific case, we could just NOT enable Error Prone at all -->
            <compilerArgs>
              <arg>-XDcompilePolicy=simple</arg>
              <!-- Remove -XepDisableAllChecks to keep all checks enabled -->
              <arg>-Xplugin:ErrorProne -XepDisableAllChecks -Xep:BetaApi:OFF</arg>
            </compilerArgs>
          </configuration>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Gradle

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

Using the Groovy DSL
plugins {
  id("java")
  id("net.ltgt.errorprone") version "0.8"
}

repositories {
  mavenCentral()
}

dependencies {
  errorprone "com.google.errorprone:error_prone_core:2.3.3"
  errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"

  // Add dependency on the beta checker
  // NOTE: added here to `annotationProcessor` so it's only enabled for the main classes
  annotationProcessor "com.google.guava:guava-beta-checker:$betaCheckerVersion"
}

// Remove this block to keep all checks enabled (default behavior)
tasks.named("compileJava").configure {
  options.errorprone.disableAllChecks = true
  options.errorprone.error("BetaApi")
}
Using the Kotlin DSL
import net.ltgt.gradle.errorprone.errorprone

plugins {
  id("java")
  id("net.ltgt.errorprone") version "0.8"
}

repositories {
  mavenCentral()
}

dependencies {
  errorprone("com.google.errorprone:error_prone_core:2.3.3")
  errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")

  // Add dependency on the beta checker
  // NOTE: added here to `annotationProcessor` so it's only enabled for the main classes
  annotationProcessor("com.google.guava:guava-beta-checker:$betaCheckerVersion")
}

// Remove this block to keep all checks enabled (default behavior)
tasks.compileJava {
  options.errorprone.disableAllChecks.set(true)
  options.errorprone.error("BetaApi")
}

Bazel

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.

Example

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 -- \
    -a com.google.guava:guava:$GUAVA_VERSION \
    -a com.google.guava:guava-beta-checker:$BETA_CHECKER_VERSION \
    -r https://repo.maven.apache.org/maven2/

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")
generated_java_libraries()

java_plugin(
    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:

java_library(
    name = "foo",
    srcs = glob(["*.java"]),
    deps = [
        "//third_party:com_google_guava_guava",
    ],
    plugins = [
        "//third_party:guava_beta_checker_plugin",
    ],
)
com.google.guava

Google

Google ❤️ Open Source

Версии библиотеки

Версия
1.0