GithubHelp home page GithubHelp logo

tbroyer / gradle-errorprone-plugin Goto Github PK

View Code? Open in Web Editor NEW
360.0 9.0 31.0 707 KB

Gradle plugin to use the error-prone compiler for Java

License: Apache License 2.0

Kotlin 94.09% Java 5.91%
gradle-plugin java errorprone error-prone

gradle-errorprone-plugin's Introduction

gradle-errorprone-plugin

This plugin configures JavaCompile tasks to use the Error Prone compiler.

Requirements

This plugin requires using at least Gradle 6.8.

While JDK 8 is supported, it is recommended to use at least a JDK 9 compiler. See note below about JDK 8 support.

There's no specific support for the Android Gradle Plugin. Read on to better understand what you need to do to use both plugins together. Specifically, note that source sets below are only about standard Gradle source sets for JVM projects, not Android source sets, so anything done by the plugin based on source sets won't be done at all for Android projects.

Usage

plugins {
    id("net.ltgt.errorprone") version "<plugin version>"
}

This plugin creates a configuration named errorprone, and configures the <sourceSet>AnnotationProcessor configuration for each source set to extend it. This allows configuring Error Prone dependencies from a single place.

Error Prone needs to be added as a dependency in this configuration:

repositories {
    mavenCentral()
}
dependencies {
    errorprone("com.google.errorprone:error_prone_core:$errorproneVersion")
}

CAUTION: Using a dynamic or changing version for Error Prone, such as latest.release or 2.+, means that your build could fail at any time, if a new version of Error Prone adds or enables new checks that your code would trigger.

Error Prone can then be configured on the JavaCompile tasks:

import net.ltgt.gradle.errorprone.errorprone

tasks.withType<JavaCompile>().configureEach {
    options.errorprone.disableWarningsInGeneratedCode.set(true)
}
with Groovy DSL
tasks.withType(JavaCompile).configureEach {
    options.errorprone.disableWarningsInGeneratedCode = true
}

and can also be disabled altogether:

tasks {
    compileTestJava {
        options.errorprone.isEnabled.set(false)
    }
}
with Groovy DSL
tasks {
    compileTestJava {
        options.errorprone.enabled = false
    }
}

Note that this plugin only enables Error Prone on tasks for source sets (i.e. compileJava for the main source set, compileTestJava for the test source set, and compileIntegTestJava for a custom integTest source set).

If you're creating custom compile tasks, then you'll have to configure them manually to enable Error Prone
val annotationProcessorCustom = configurations.resolvable("annotationProcessorCustom") {
    extendsFrom(configurations.errorprone.get())
}
tasks.register<JavaCompile>("compileCustom") {
    source("src/custom/")
    include("**/*.java")
    classpath = configurations["custom"]
    sourceCompatibility = "8"
    targetCompatibility = "8"
    destinationDir = file("$buildDir/classes/custom")

    // Error Prone must be available in the annotation processor path
    options.annotationProcessorPath = annotationProcessorCustom.get()
    // Enable Error Prone
    options.errorprone.isEnabled = true
    // It can then be configured for the task
    options.errorprone.disableWarningsInGeneratedCode = true
}
with Groovy DSL
def annotationProcessorCustom = configurations.resolvable("annotationProcessorCustom") {
    extendsFrom(configurations.errorprone)
}
tasks.register("compileCustom", JavaCompile) {
    source "src/custom/"
    include "**/*.java"
    classpath = configurations.custom
    sourceCompatibility = "8"
    targetCompatibility = "8"
    destinationDir = file("$buildDir/classes/custom")

    // Error Prone must be available in the annotation processor path
    options.annotationProcessorPath = annotationProcessorCustom
    // Enable Error Prone
    options.errorprone.enabled = true
    // It can then be configured for the task
    options.errorprone.disableWarningsInGeneratedCode = true
}

JDK 8 support

Error Prone requires at least a JDK 9 compiler. When using a JDK 8 compiler, the plugin will configure the JavaCompile tasks to use a forking compiler and will override the compiler by prepending the Error Prone javac to the bootstrap classpath (using a -Xbootclasspath/p: JVM argument).

You can configure JavaCompile tasks to use a specific JDK compiler, independently of the JDK used to run Gradle itself. The plugin will use the toolchain version, if any is specified, to configure the task. This allows you to enforce compilation with JDK 11 while running Gradle with JDK 8. (In case you would want to enforce compilation with JDK 8 instead, the plugin would detect it and properly configure the bootstrap classpath as described above)

Note that the plugin will ignore any task that forks and defines either a javaHome or an executable, and thus won't configure the bootstrap classpath if you're e.g. running Gradle with a more recent JDK and forking the compilation tasks to use JDK 8.

JDK 16+ support

Starting with JDK 16, due to JEP 396: Strongly Encapsulate JDK Internals by Default, --add-opens and --add-exports arguments need to be passed to the compiler's JVM.

The plugin will automatically use a forking compiler and pass the necessary JVM arguments whenever it detects such a JDK is being used and ErrorProne is enabled (unless the Gradle daemon's JVM already was given the appropriate options through org.gradle.jvmargs).

That detection will only take into account the toolchain used by the JavaCompile task, or the JDK used to run Gradle in case no toolchain is being used. The plugin will ignore any task that forks and defines either a javaHome or an executable, and thus won't configure the JVM arguments if you're e.g. running Gradle with an older JDK and forking the compilation tasks to use JDK 17.

Note that the plugin also configures the JVM arguments for any JDK above version 9 to silence related warnings, but they will then only be used if the task is explicitly configured for forking (or if the configured toolchain is incompatible with the JDK used to run Gradle, which will then implicitly fork a compiler daemon).

Android Gradle Plugin support

As noted above, this plugin won't have much effect when used in conjunction with the AGP rather than, say, Gradle's built-in Java plugins.

It will then:

  • create the errorprone configuration, but won't wire it to any other configuration, and by extension to any compilation task
  • enhance JavaCompile tasks with the errorprone extension, but keep ErrorProne disabled by default (it would fail otherwise, as ErrorProne won't be on the processor path)

You'll thus have to somehow:

  • put ErrorProne on the processor path of the JavaCompile tasks
  • enable ErrorProne on the JavaCompile tasks
  • configure isCompilingTestOnlyCode for compilation tasks for test variants (this changes the behavior of some checks)

This could (and should) be done by a plugin, so if you have deep knowledge of the AGP APIs and how to idiomatically integrate Error Prone within Android builds, please make such a plugin and I'll link to it here for others to use.

Custom Error Prone checks

Custom Error Prone checks can be added to the errorprone configuration too:

dependencies {
    errorprone("com.uber.nullaway:nullaway:$nullawayVersion")
}

or alternatively to the <sourceSet>AnnotationProcessor configuration, if they only need to be enabled for a given source set:

dependencies {
    annotationProcessor("com.google.guava:guava-beta-checker:$betaCheckerVersion")
}

and can then be configured on the tasks; for example:

tasks.withType<JavaCompile>().configureEach {
    options.errorprone {
        option("NullAway:AnnotatedPackages", "net.ltgt")
    }
}
tasks.compileJava {
    // The check defaults to a warning, bump it up to an error for the main sources
    options.errorprone.error("NullAway")
}
with Groovy DSL
tasks.withType(JavaCompile).configureEach {
    options.errorprone {
        option("NullAway:AnnotatedPackages", "net.ltgt")
    }
}
tasks.compileJava {
    // The check defaults to a warning, bump it up to an error for the main sources
    options.errorprone.error("NullAway")
}

Configuration

As noted above, this plugin adds an errorprone extension to the JavaCompile.options. It can be configured either as a property (options.errorprone.xxx) or script block (options.errorprone { โ€ฆ }).

In a *.gradle.kts script, the Kotlin extensions need to be imported:

import net.ltgt.gradle.errorprone.errorprone

Properties

Please note that all properties are lazy.

Property Description
isEnabled (enabled with Groovy DSL) Allows disabling Error Prone altogether for the task. Error Prone will still be in the annotation processor path, but -Xplugin:ErrorProne won't be passed as a compiler argument. Defaults to true for source set tasks, false otherwise.
disableAllChecks Disable all Error Prone checks; maps to -XepDisableAllChecks. This will be the first argument, so checks can then be re-enabled on a case-by-case basis. Defaults to false.
disableAllWarnings Maps to -XepDisableAllWarnings (since ErrorProne 2.4.0). Defaults to false.
allErrorsAsWarnings Maps to -XepAllErrorsAsWarnings. Defaults to false.
allDisabledChecksAsWarnings Enables all Error Prone checks, checks that are disabled by default are enabled as warnings; maps to -XepDisabledChecksAsWarnings. Defaults to false.
disableWarningsInGeneratedCode Disables warnings in classes annotated with javax.annotation.processing.Generated or @javax.annotation.Generated; maps to -XepDisableWarningsInGeneratedCode. Defaults to false.
ignoreUnknownCheckNames Maps to -XepIgnoreUnknownCheckNames. Defaults to false.
ignoreSuppressionAnnotations Maps to -XepIgnoreSuppressionAnnotations (since Error Prone 2.3.3). Defaults to false.
isCompilingTestOnlyCode (compilingTestOnlyCode with Groovy DSL) Maps to -XepCompilingTestOnlyCode. Defaults to false. (defaults to true for a source set inferred as a test source set)
excludedPaths A regular expression pattern (as a string) of file paths to exclude from Error Prone checking; maps to -XepExcludedPaths. Defaults to null.
checks A map of check name to CheckSeverity, to configure which checks are enabled or disabled, and their severity; maps each entry to -Xep:<key>:<value>, or -Xep:<key> if the value is CheckSeverity.DEFAULT. Defaults to an empty map.
checkOptions A map of check options to their value; maps each entry to -XepOpt:<key>=<value>. Use an explicit "true" value for a boolean option. Defaults to an empty map.
errorproneArgs Additional arguments passed to Error Prone. Defaults to an empty list.
errorproneArgumentProviders A list of CommandLineArgumentProvider for additional arguments passed to Error Prone. Defaults to an empty list.

Methods

Method Description
enable(checkNames...) Adds checks with their default severity. Useful in combination with disableAllChecks to selectively re-enable checks. Equivalent to check(checkName, CheckSeverity.DEFAULT) for each check name.
disable(checkNames...) Disable checks. Equivalent to check(checkName, CheckSeverity.OFF) for each check name.
warn(checkNames...) Adds checks with warning severity. Equivalent to check(checkName, CheckSeverity.WARNING) for each check name.
error(checkNames...) Adds checks with error severity. Equivalent to check(checkName, CheckSeverity.ERROR) for each check name.
check(checkName to severity...) (Kotlin DSL only) Adds pairs of check name to severity. Equivalent to checks.put(first, second) for each pair.
check(checkName, severity) Adds a check with a given severity. The severity can be passed as a provider for lazy configuration. Equivalent to checks.put(checkName, severity).
option(optionName) Enables a boolean check option. Equivalent to option(checkName, true).
option(optionName, value) Adds a check option with a given value. Value can be a boolean or a string, or a provider of string. Equivalent to checkOptions.put(name, value).

A check severity can take values: DEFAULT, OFF, WARN, or ERROR.
Note that the net.ltgt.gradle.errorprone.CheckSeverity needs to be imported into your build scripts (see examples above).

gradle-errorprone-plugin's People

Contributors

aalmiray avatar nakulj avatar tbroyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gradle-errorprone-plugin's Issues

New release to support Gradle 6.7 toolchains?

Hello, sorry to bug but Gradle 6.7 is out and is awesome. I believe my build logs this when Gradle is run with Java 8 and build uses Java 11 because the toolchains support hasn't been released yet. Would be wonderful if that could be released!

No dependency was configured in configuration errorproneJavac, compilation with Error Prone will likely fail as a result.
Add a dependency to com.google.errorprone:javac with the appropriate version corresponding to the version of Error Prone you're using:

    dependencies {
        errorproneJavac("com.google.errorprone:javac:$errorproneJavacVersion")
    }

Dependency conflicts reported by ResolutionStrategy#failOnVersionConflict

We are using failOnVersionConflict in our build.

Unfortunately just using the 'net.ltgt.errorprone' plugins leads to errors.

Could you maybe fix/pin the versions on your side?

plugins {
    id 'java-library'
    id 'net.ltgt.errorprone' version '0.6'
}

repositories.jcenter()

configurations.all {
  resolutionStrategy.failOnVersionConflict()
}

dependencies {
  errorprone 'com.google.errorprone:error_prone_core:2.3.2'
  errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
}
$ ./gradlew build
> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':annotationProcessor'.
> A conflict was found between the following modules:
    - com.google.code.findbugs:jsr305:3.0.0
    - com.google.code.findbugs:jsr305:1.3.9
  A conflict was found between the following modules:
    - com.google.errorprone:error_prone_annotations:2.3.2
    - com.google.errorprone:error_prone_annotations:2.0.18
  A conflict was found between the following modules:
    - org.checkerframework:checker-qual:2.0.0
    - org.checkerframework:checker-qual:2.5.3
  Run with:
      --scan or
      :dependencyInsight --configuration annotationProcessor --dependency com.google.code.findbugs:jsr305
  to get more insight on how to solve the conflict.
$ ./gradlew :dependencyInsight --configuration annotationProcessor --dependency com.google.code.findbugs:jsr305
Parallel execution with configuration on demand is an incubating feature.

> Task :dependencyInsight
Dependency resolution failed because of conflicts between the following modules:
   - com.google.code.findbugs:jsr305:3.0.0
   - com.google.code.findbugs:jsr305:1.3.9

com.google.code.findbugs:jsr305:3.0.0
   variant "runtime" [
      org.gradle.status = release (not requested)
   ]
   Selection reasons:
      - Was requested
      - By conflict resolution : between versions 3.0.0 and 1.3.9

com.google.code.findbugs:jsr305:3.0.0
+--- com.google.errorprone:error_prone_check_api:2.3.2
|    \--- com.google.errorprone:error_prone_core:2.3.2
|         \--- annotationProcessor
\--- com.google.errorprone:error_prone_core:2.3.2 (*)

com.google.code.findbugs:jsr305:1.3.9 -> 3.0.0
\--- com.google.guava:guava:23.5-jre
     +--- com.google.errorprone:error_prone_core:2.3.2
     |    \--- annotationProcessor
     +--- com.google.errorprone:error_prone_annotation:2.3.2
     |    +--- com.google.errorprone:error_prone_core:2.3.2 (*)
     |    \--- com.google.errorprone:error_prone_check_api:2.3.2
     |         \--- com.google.errorprone:error_prone_core:2.3.2 (*)
     \--- com.google.auto:auto-common:0.10
          \--- com.google.errorprone:error_prone_core:2.3.2 (*)

(*) - dependencies omitted (listed previously)

Custom Javac plugin does not launch together with ErrorProne

I'm trying to run a custom plugin together with the ErrorProne plugin.

When the ErrorProne Gradle plugin is not applied, my Javac plugin is launched. However, when it is applied, my plugin is skipped (it is still discovered by the ServiceLoader, but the init method is never called).

I was able to work around this issue, by satisfying this condition:

compileJava {
    options.compilerArgs += '-Xplugin:MyPlugin'
    options.fork = true
    if (options.forkOptions.javaHome == null) {
        options.forkOptions.javaHome = System.getenv('JAVA_HOME') as File
    }
}

but the compiler now fails at some random spot, which, I believe, is why there is a custom ErrorProne Javac in the first place.

How do I enable custom Javac plugins with the ErrorProne Java compiler?

I'm using Java 8, ErrorProne 2.3.3, ErrorProne Javac 9+181-r4173-1, and the Gradle plugin 0.8.

migration from 0.0.x with plain old java

so your readme says this won't work anymore... but... how do I write the new thing in Java? I extend your plugin with my own in Java, and there's no errorProne() method on the class (unsurprisingly)

     options.getCompilerArgs().addAll( Arrays.asList(
                "-XepExcludedPaths:.*/build/generated/.*",
                "-Xep:MissingOverride:ERROR",
                "-Xep:Var:ERROR"
        ) );

Support configuration cache

When using version 2.0.1 of the plugin with Gradle 7 (RC2) with --configuration-cache, the configuration cache can be created, but the project does not build when it is used. Key error message:
> Extension with name 'errorprone' does not exist. Currently registered extension names: [ext]

Reproducer: https://github.com/C-Otto/playground/tree/errorprone-configuration-cache

Creating configuration cache (successful):

$ ./gradlew clean build --no-build-cache --configuration-cache
Configuration cache is an incubating feature.
Calculating task graph as no configuration cache is available for tasks: clean build

BUILD SUCCESSFUL in 4s
12 actionable tasks: 12 executed
Configuration cache entry stored.

Second build, reusing configuration cache (fails):

$ ./gradlew clean build --no-build-cache --configuration-cache
Configuration cache is an incubating feature.
Reusing configuration cache.
> Task :subproject-one:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':subproject-one:compileJava'.
> Extension with name 'errorprone' does not exist. Currently registered extension names: [ext]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 679ms
4 actionable tasks: 4 executed
Configuration cache entry reused.

Warning for errorproneJavac even on Java 10, when using com.github.ben-manes.versions plugin

I'm on Java 10 and when I run gradle dependecyUpdates (from gradle-versions-plugin) I get:

No dependency was configured in configuration errorproneJavac, compilation with Error Prone will likely fail as a result.
Add a dependency to com.google.errorprone:javac with the appropriate version corresponding to the version of Error Prone you're using:

    dependencies {
        errorproneJavac("com.google.errorprone:javac:$errorproneJavacVersion")
    }

I looked at your code and I'm not sure why this could happen. I printed:

dependencyUpdates.doLast {
	println System.getProperty("java.version")
	println org.gradle.api.JavaVersion.current()
}

And this gives:

10.0.2
1.10

Compilation and other tasks work fine. Any ideas?

Not working with APT

When I enable 'net.ltgt.apt' plugin the build starts to fail. Maybe this has something to do with APT overriding default compile targets and ErrorProne has to be additionally configured? I've seen this in README.md, but could you provide a way to do that for already existing 'compileJava' and 'compilteTestJava' targets? Unfortunately, I have not that much Gradle experience to do that myself.

> Task :compileJava FAILED
error: plug-in not found: ErrorProne
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

I also attach a sample project to reproduce the issue:
demo.zip

Add to readme where to find versions of javac

Hi @tbroyer , thx very much for updating the errorprone plugin to agp 3.3.0 and gradle 5.

While migrating from version 0.0.11 to 0.7, I was wondering where to get an appropriate javac version for error prone. I ended up looking into the code and realized you were using a dependency of error prone itself. Maybe you should add this to the doc:

You can find an appropriate version of javac for errorprone on maven central.

Add support for refaster

This is a follow-up of tbroyer/gradle-errorprone-plugin-v0.0.x#65.

Refaster is now a plugin of error prone. Thus, I thought that the gradle plugin would support it, too.

For a first version I would expect that

  • src/refaster/ contains *.refaster
  • A gradle task refaster applies each refaster file to each java file in the compile source set. Also for the test source set.

In later versions, one can configure the source set and the files to apply. (IMHO not needed).

Annotation processors not run in compileTestJava

I'm not sure why, but setting up this plugin on a Java 10 project (w/o ErrorProne prior) fails in compileTestJava. It does not generate the AutoValue code, but does so in compileJava. An afterEvaluate shows that the compiler arg -s, <test dir> is set, but nothing is generated. The only changes to the build was adding this plugin, so not sure how to diagnose it further.

apply plugin: 'net.ltgt.errorprone-javacplugin'

tasks.withType(JavaCompile) {
  options.errorprone {
    disableWarningsInGeneratedCode = true
    excludedPaths = "${buildDir}/generated-sources/.*"
  }
}

java.lang.NoClassDefFoundError: edu/umd/cs/findbugs/formatStringChecker/MissingFormatArgumentException

I'm not sure if this is a bug in my code / this plugin / error-prone itself, but after configuring the plugin I am seeing the following stacktrace:

* What went wrong:
Failed to match Java compiler error output: 'An exception has occurred in the compiler ((version info not available)). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NoClassDefFoundError: edu/umd/cs/findbugs/formatStringChecker/MissingFormatArgumentException
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
        at java.lang.Class.getConstructors(Class.java:1651)
        at com.google.errorprone.scanner.ScannerSupplierImpl.instantiateChecker(ScannerSupplierImpl.java:69)
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
        at com.google.errorprone.scanner.ScannerSupplierImpl.get(ScannerSupplierImpl.java:94)
        at com.google.errorprone.scanner.ScannerSupplierImpl.get(ScannerSupplierImpl.java:40)
        at com.google.errorprone.ErrorProneAnalyzer.lambda$scansPlugins$0(ErrorProneAnalyzer.java:78)
        at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:164)
        at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
        at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
        at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1404)
        at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1353)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
        at com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:100)
        at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
        at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:89)
        at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:50)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:36)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:88)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:76)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:42)
        at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:46)
        at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:30)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:101)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: edu.umd.cs.findbugs.formatStringChecker.MissingFormatArgumentException
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 53 more'

Running the gradle dependencies task for my module shows error-prone but nothing about jFormatString which is what I think is missing, based on the ant requirements here: https://errorprone.info/docs/installation.

Is there a way to add this dependency?

Compiler error when migrating from Error Prone 2.3.4 to 2.4.0

If an enum declares a method with a Javadoc that has a {@link } reference, error: enum types may not be instantiated compiler error is emitted.

This was discovered when changing the version from 2.3.4 to 2.4.0. This cannot be reproduced using the 2.3.4 version.

The version of this plugin doesn't seem to matter, this happens on versions 1.1.1 and 1.2.1.

Minimal reproduction can be found here.

compileJava error: plug-in not found: ErrorProne

I'm trying to migrate Java project from plugin version 0.0.14 to 0.8 since JDK 11 is not supported in 0.0.14.

Getting error on compileJava task. compileJava error: plug-in not found: ErrorProne

dependencies { classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.8" }

apply plugin: "net.ltgt.errorprone"
apply plugin: 'java'

compileJava.dependsOn clean

Gradle Version: 5.2.1
JDK version : jdk-11.0.2

Applying dependency management to configuration 'apiElements' in project 'projectname'
Applying dependency management to configuration 'archives' in project 'projectname'
Applying dependency management to configuration 'bootArchives' in project 'projectname'
Applying dependency management to configuration 'compile' in project 'projectname'
Applying dependency management to configuration 'compileClasspath' in project 'projectname'
Applying dependency management to configuration 'compileOnly' in project 'projectname'
Applying dependency management to configuration 'default' in project 'projectname'
Applying dependency management to configuration 'errorprone' in project 'projectname'
Applying dependency management to configuration 'errorproneJavac' in project 'projectname'
Applying dependency management to configuration 'implementation' in project 'projectname'
Applying dependency management to configuration 'runtime' in project 'projectname'
Applying dependency management to configuration 'runtimeClasspath' in project 'projectname'
Applying dependency management to configuration 'runtimeElements' in project 'projectname'
Applying dependency management to configuration 'runtimeOnly' in project 'projectname'
Applying dependency management to configuration 'testAnnotationProcessor' in project 'projectname'
Applying dependency management to configuration 'testCompile' in project 'projectname'
Applying dependency management to configuration 'testCompileClasspath' in project 'projectname'
Applying dependency management to configuration 'testCompileOnly' in project 'projectname'
Applying dependency management to configuration 'testImplementation' in project 'projectname'
Applying dependency management to configuration 'testRuntime' in project 'projectname'
Applying dependency management to configuration 'testRuntimeClasspath' in project 'projectname'
Applying dependency management to configuration 'testRuntimeOnly' in project 'projectname'

Getting build error

I am getting this build error:

An exception occurred applying plugin request [id: 'net.ltgt.errorprone', version: '0.6']
> Failed to apply plugin [id 'net.ltgt.errorprone']
   > Could not create plugin of type 'ErrorPronePlugin'.

You can find the stacktrace and debug here.
My build.gradle:

plugins {
  // we assume you are already using the Java plugin
  id "java"
  id "application"
  id "net.ltgt.errorprone" version "0.6"

}

dependencies {
  annotationProcessor "com.uber.nullaway:nullaway:0.7.10"

  // Optional, some source of nullability annotations.
  // Not required on Android if you use the support 
  // library nullability annotations.
  compileOnly "com.google.code.findbugs:jsr305:3.0.2"

  errorprone "com.google.errorprone:error_prone_core:2.4.0"
  errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
}

import net.ltgt.gradle.errorprone.CheckSeverity

tasks.withType(JavaCompile) {
  // remove the if condition if you want to run NullAway on test code
  if (!name.toLowerCase().contains("test")) {
    options.errorprone {
      check("NullAway", CheckSeverity.ERROR)
      option("NullAway:AnnotatedPackages", "com.uber")
    }
  }
}


mainClassName = 'hello.HelloWorld'

jar {
    baseName = 'gs-gradle'
    version =  '0.1.0'
}

Could you please point out where am I going wrong?

disableWarningsInGeneratedCode not working on android

I am attempting to use this plugin with an Android Project, but cannot seem to disable the warnings in generated code. My app module build.gradle is as follows:

apply plugin: 'com.android.application'
apply plugin: "net.ltgt.errorprone"

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    def keystorePropertiesFile = rootProject.file("keystore.properties")
    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))


    defaultConfig {
        applicationId "com.nickwelna.issuemanagerforgithub"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        buildConfigField "String", "CLIENT_SECRET", keystoreProperties["CLIENT_SECRET"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-beta05'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
    implementation "androidx.navigation:navigation-fragment:2.2.0-beta01"
    implementation "androidx.navigation:navigation-ui:2.2.0-beta01"
    implementation 'com.google.android.material:material:1.1.0-beta01'
    implementation 'com.google.firebase:firebase-core:17.2.0'
    implementation 'com.google.firebase:firebase-auth:19.1.0'
    implementation 'com.google.firebase:firebase-database:19.1.0'
    implementation 'com.jakewharton:butterknife:10.2.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0'
    implementation 'com.google.code.gson:gson:2.8.5'
    implementation 'com.github.bumptech.glide:glide:4.10.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
    implementation 'com.squareup.retrofit2:retrofit:2.6.2'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.2'
    implementation 'com.squareup.retrofit2:converter-moshi:2.6.2'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3'
    debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.3'
    implementation 'com.google.flogger:flogger:0.4'
    implementation 'com.google.flogger:flogger-system-backend:0.4'
    implementation 'com.squareup.moshi:moshi:1.8.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.2.2'

    compileOnly 'com.jakewharton.nopen:nopen-annotations:1.0.1'
    errorprone "com.google.errorprone:error_prone_core:2.3.3"
    errorprone 'com.jakewharton.nopen:nopen-checker:1.0.1'
    errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
}

android.applicationVariants.all { variant ->
    variant.javaCompileProvider.configure {
        options.errorprone.disableWarningsInGeneratedCode = true
    }
}

apply plugin: 'com.google.gms.google-services'

And my project build.gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.1.0'
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'com.google.gms:google-services:4.3.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

However I am seeing nopen errors flagged in generated code under the directory app/build/generated/ap_generated_sources/debug/out, am I missing something?

ignore `$buildDir/generated/source`

so... due to craziness maybe have an inclusive option to ignore generated code? I have this

    disableWarningsInGeneratedCode.set(true)
    excludedPaths.set("$buildDir/generated/sources/.*")

I'm still not certain that how I'm specifying the path for excluded paths is the best way to do it... but it might be nice to have a

disableGeneratedCodeCheck()

or some such, that does this for you. Also it might be good to change excludedPaths to a collection, and then you can join them yourself, that way the above would "add" it to the collection, and not simply override it. at minimum might be good to document how to exclude this directory.

CheckSeverity is not exposed in extension

If you try to follow the readme and try to do

tasks.named("compileJava").configure {
    options.errorprone.check("NullAway", CheckSeverity.ERROR)
}
> Could not get unknown property 'CheckSeverity' for -XepDisableWarningsInGeneratedCode -Xep:EqualsHashCode:ERROR -Xep:EqualsIncompatibleType:ERROR -Xep:StreamResourceLeak:ERROR of type net.ltgt.gradle.errorprone.ErrorProneOptions.

You need to either add an import to your gradle file or otherwise this plugin has to expose CheckSeverity as a property on extension

How does one actually use java 10/11 with this?

used to be at least that it downloaded its own version of the compiler... but since it's a plugin, is that still required? is it possible to use the same version of the jdk that is running gradle? looking for docs on how to achieve.

Support JDK 16

According to https://errorprone.info/docs/installation some flags seem to be necessary when using JDK 16. I have no idea how to configure those with Gradle and I'd appreciate some plugin support.

$ ./gradlew build

> Task :subproject-one:compileJava FAILED
An exception has occurred in the compiler (16). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
java.lang.IllegalAccessError: class com.google.errorprone.BaseErrorProneJavaCompiler (in unnamed module @0x3b727f48) cannot access class com.sun.tools.javac.api.BasicJavacTask (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.api to unnamed module @0x3b727f48
        at com.google.errorprone.BaseErrorProneJavaCompiler.addTaskListener(BaseErrorProneJavaCompiler.java:94)
        at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:34)
        at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugin(BasicJavacTask.java:255)
        at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:229)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.prepareCompiler(JavacTaskImpl.java:204)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:101)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
        at org.gradle.internal.compiler.java.IncrementalCompileTask.call(IncrementalCompileTask.java:77)

error: plug-in not found: ErrorProne with android.enableSeparateAnnotationProcessing=true

When using android.enableSeparateAnnotationProcessing=true, the build fails with error: plug-in not found: ErrorProne

This is with plugin version 0.6.1, Gradle 5.1, AGP 3.3.0-rc03 or 3.4.0-alpha10
And:

dependencies {
    errorprone 'com.google.errorprone:error_prone_core:2.3.2'
    errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
}

Besides its regular purpose of enabling incremental compilation I have found the gradle property essential for working around google/error-prone#771

compileJava error: plug-in not found: ErrorProne

Running lint I get this error:

> Task :app:compileDebugJavaWithJavac FAILED
error: plug-in not found: ErrorProne

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        mavenCentral()
    }
}

plugins {
    id 'com.android.application'
    id 'net.ltgt.errorprone' version '0.8'
}

android {
    [...]
}

dependencies {
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    androidTestImplementation 'androidx.test:rules:1.1.1'

    implementation 'androidx.annotation:annotation:1.0.2'

    errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
}

disableWarningsInGeneratedCode doesn't working

buildscript {
    ext.kotlin_version = "1.3.11"

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jmailen.gradle:kotlinter-gradle:1.20.1"
        classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.16"
        classpath "com.jakewharton:butterknife-gradle-plugin:9.0.0-rc3"
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha09"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
}

subprojects { project ->
    apply plugin: "net.ltgt.errorprone"
    apply from: rootProject.file("ktlint.gradle")

    dependencies {
        errorprone "com.google.errorprone:error_prone_core:2.3.1"
    }

    project.afterEvaluate {
        preBuild.dependsOn formatKotlin
        preBuild.dependsOn lintKotlin

        tasks.withType(JavaCompile).configureEach {
            options.errorprone.disableWarningsInGeneratedCode = true // This is line 49
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

ktlint.gradle file

apply plugin: "org.jmailen.kotlinter"

kotlinter {
    ignoreFailures = false
    indentSize = 4
    continuationIndentSize = 4
    reporters = ["checkstyle", "html"]
}

output

* Where:
Build file '/media/mohamed/Data/Projects/2018/12/TruTed/build.gradle' line: 49

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > java.lang.reflect.InvocationTargetException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

another example

in module app/build.gradle file

apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "kotlin-kapt"
apply plugin: "kotlin-android-extensions"
apply plugin: "androidx.navigation.safeargs"
apply plugin: "net.ltgt.errorprone"

dependencies {
        ...
        errorprone "com.google.errorprone:error_prone_core:2.3.1"
        ...
}

afterEvaluate {
    tasks.withType(JavaCompile).configureEach {
        options.errorprone.disableWarningsInGeneratedCode = true // This is line 59
    }
}

output

* Where:
Build file '/media/mohamed/Data/Projects/2018/12/TruTed/app/build.gradle' line: 59

* What went wrong:
A problem occurred configuring project ':app'.
> Could not get unknown property 'errorprone' for object of type org.gradle.api.tasks.compile.CompileOptions.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

CONFIGURE FAILED in 0s
Could not get unknown property 'errorprone' for object of type org.gradle.api.tasks.compile.CompileOptions.
Open File

Use extension instead of convention

Conventions are an outdated concept and will be deprecated/removed in future Gradle versions. They are only still around because some old core plugins still use them.

Any new plugin should use extensions instead. This would also remove the last bits of internal API usage, making this plugin an excellent example for others to follow.

documentation

The following properties in kotlin seem incomplete.

first, this doesn't work anymore

    disableWarningsInGeneratedCode = true

you have to do this because now it's a Property<Boolean>

    disableWarningsInGeneratedCode.set(true)

ok, these don't appear to have docs on the properties, I'm not certain if you add javadoc/whatever to them in your plugin will it propagate to the generated kotlin dsl? imho, that would be preferred for all the things, if it doesn't work I may file or look for a bug in gradle.

what is checkOptions?

Gradle Error Prone Plugin breaks with Instant Execution

Using instant execution (a.k.a configuration caching), using following versions, I got :

  • AGP:4.1.0-alpha09
  • Kotlin:1.3.72
  • Gradle:6.5-20200519143217+0000
2 instant execution problems were found.
- field '$javacConfiguration' from type 'net.ltgt.gradle.errorprone.ErrorPronePlugin$apply$1': cannot deserialize object of type 'org.gradle.api.artifacts.Configuration' as these are not supported with instant execution.
  See https://docs.gradle.org/6.5-20200519143217+0000/userguide/configuration_cache.html#disallowed_types
- field '$javacConfiguration' from type 'net.ltgt.gradle.errorprone.ErrorPronePlugin$apply$1': value 'file collection' is not assignable to 'org.gradle.api.artifacts.Configuration'

For gradle command:
./gradlew -Dorg.gradle.unsafe.instant-execution.fail-on-problems=false -Dorg.gradle.unsafe.instant-execution=true -Dorg.gradle.unsafe.instant-execution.max-problems=655360 --no-scan :app:build

Basically: configurations are not allowed as inputs of task with instant execution. Solutions are:

  • replace it by an ArtifactView or a file collection. They are supported.
  • use any serializable class instead.

Here is an example of resolution for another plugin: square/wire#1560

java.lang.ClassNotFoundException: com.google.errorprone.BaseErrorProneJavaCompiler

We are successfully using errorprone 0.0.16 in a build, and now trying to update to 0.6, which fails with a ClassNotFoundException when trying to compile the main classes.

Is there something missing from my configuration? The one thing I wasn't sure about from reading the docs was the version I was supposed to be putting in for errorproneJava.

This is the configuration we ended up with:

buildscript {
    repositories {
        // ...
    }

    dependencies {
        classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.6'
    }
}

apply plugin: 'java'
apply plugin: net.ltgt.gradle.errorprone.ErrorPronePlugin

dependencies {
    errorprone 'com.google.errorprone:error_prone_core:2.3.2'
    errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
}

import net.ltgt.gradle.errorprone.CheckSeverity

tasks.withType(JavaCompile) {
    options.errorprone {
        disableWarningsInGeneratedCode = true

        check 'BadComparable', CheckSeverity.ERROR
        // ...
    }
}

When running the build, I get the following output:

$ ./gradlew check
Parallel execution is an incubating feature.

> Task :compileJava FAILED
warning: [options] bootstrap class path not set in conjunction with -source 1.8
An exception has occurred in the compiler (9-internal). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.NoClassDefFoundError: com/google/errorprone/BaseErrorProneJavaCompiler
        at com.google.errorprone.ErrorProneJavacPlugin.init(ErrorProneJavacPlugin.java:39)
        at com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:214)
        at com.sun.tools.javac.api.JavacTaskImpl.prepareCompiler(JavacTaskImpl.java:192)
        at com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:97)
        at com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:142)
        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:96)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:90)
        at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:89)
        at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:50)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:36)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:88)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:76)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:42)
        at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:46)
        at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:30)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:101)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: com.google.errorprone.BaseErrorProneJavaCompiler
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 36 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed

More diagnostics:

$ ./gradlew dependencies --configuration errorprone
...
errorprone
\--- com.google.errorprone:error_prone_core:2.3.2
     +--- com.google.errorprone:error_prone_annotation:2.3.2
     |    \--- com.google.guava:guava:23.5-jre
     |         +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.0
     |         +--- org.checkerframework:checker-qual:2.0.0 -> 2.5.3
     |         +--- com.google.errorprone:error_prone_annotations:2.0.18 -> 2.3.2
     |         +--- com.google.j2objc:j2objc-annotations:1.1
     |         \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
     +--- com.google.errorprone:error_prone_type_annotations:2.3.2
     +--- com.google.errorprone:error_prone_check_api:2.3.2
     |    +--- com.google.errorprone:error_prone_annotation:2.3.2 (*)
     |    +--- com.google.code.findbugs:jsr305:3.0.0
     |    +--- org.checkerframework:dataflow:2.5.3
     |    |    +--- org.checkerframework:checker-qual:2.5.3
     |    |    \--- org.checkerframework:javacutil:2.5.3
     |    |         \--- org.checkerframework:checker-qual:2.5.3
     |    +--- com.googlecode.java-diff-utils:diffutils:1.3.0
     |    +--- com.google.errorprone:error_prone_annotations:2.3.2
     |    \--- com.github.kevinstern:software-and-algorithms:1.0
     +--- com.github.stephenc.jcip:jcip-annotations:1.0-1
     +--- org.pcollections:pcollections:2.1.2
     +--- com.google.guava:guava:23.5-jre (*)
     +--- com.google.auto:auto-common:0.10
     |    \--- com.google.guava:guava:23.5-jre (*)
     +--- com.google.code.findbugs:jFormatString:3.0.0
     +--- com.google.code.findbugs:jsr305:3.0.0
     +--- org.checkerframework:dataflow:2.5.3 (*)
     +--- com.google.errorprone:error_prone_annotations:2.3.2
     \--- com.google.protobuf:protobuf-java:3.4.0
$ ./gradlew dependencies --configuration errorproneJavac
...

errorproneJavac
\--- com.google.errorprone:javac:9+181-r4173-1

"Could not get unknown property 'CheckSeverity' for of type net.ltgt.gradle.errorprone.ErrorProneOptions"

I try to get the plugin to work, using the most trivial example I can think of, but Gradle always complains with this error message:

Could not get unknown property 'CheckSeverity' for  of type net.ltgt.gradle.errorprone.ErrorProneOptions.

Gradle version is 4.10.1. This is a minimal build.gradle to reproduce the issue for me:

plugins {                                                                                                                                                                                                                                                                                                                                                                                        
  id "net.ltgt.errorprone" version "0.6"
}

apply plugin: 'java'
apply plugin: 'net.ltgt.errorprone'

tasks.withType(JavaCompile).configureEach {
  options.errorprone {
    check("ReferenceEquality", CheckSeverity.ERROR)
  }
}

I think this is exactly how the documentation wants me to do it.

Could not get unknown property 'errorprone' for object of type org.gradle.api.tasks.compile.CompileOptions.

I've been using the other plugin until now (net.ltgt.errorprone) but I decided to give this one a try with JDK9. I only change id 'net.ltgt.errorprone' version '0.0.14' to id 'net.ltgt.errorprone-javacplugin' version '0.2' and add options.errorprone.disableWarningsInGeneratedCode = true in my tasks.withType(JavaCompile) and I get the error from the title:

Could not get unknown property 'errorprone' for object of type org.gradle.api.tasks.compile.CompileOptions.

I'm not sure what I am doing wrong. Any ideas?

P.S. JDK 9.0.4 and Gradle 4.7.

ErrorProne Performance Problems

Hi! I'm noticing non-insignificant slowdowns when using Error Prone in our Android project, which is making it hard to fully adopt.

  errorProneVersion = '2.3.3'
  errorProneJavacVersion = '9+181-r4173-1'
  errorProneGradlePluginVersion = '0.8.1'
...
  core: "com.google.errorprone:error_prone_core:${errorProneVersion}",
  gradle_plugin: "net.ltgt.gradle:gradle-errorprone-plugin:${errorProneGradlePluginVersion}",
  javac: "com.google.errorprone:javac:${errorProneJavacVersion}",
...
  classpath deps.error_prone.gradle_plugin
...
  project.dependencies {
    errorprone deps.error_prone.core
    errorproneJavac deps.error_prone.javac
  }

Essentially I'm looking at the single task compilation speed drop from 2s to 8s after turning on Error Prone with the default checks. There's a margin of error but you can clearly see a trend 2s -> 8s, and 0.4s -> 3s after repeated runs.

Test Case Single task time after 2nd run (compileDebugKotlin) .. (compileDebugJavaWithJavac) Total task time
w/ Error Prone+NullAway 9873msย  ย ย 8343ms BUILD SUCCESSFUL in 3m 50s
large module w/ Error Prone only 10252msย ย  ย 8655ms BUILD SUCCESSFUL in 4m 4sย ย 
small module w/ Error Prone only ย ย 603ms ย ย ย 2823ms BUILD SUCCESSFUL in 59s
large module w/o Error Prone 13933msย  ย 1560msย  BUILD SUCCESSFUL in 4m 31sย ย 
small module w/o Error Prone ย ย 662msย  ย 350ms BUILD SUCCESSFUL in 56s

Would you have any advice on the matter?

usage problem

ran into two issues using errorprone in our project:

Could not find method errorprone() for arguments [build_ddm6vekag2igl3dhoydenrwzg$_run_closure3$_closure7$_closure15@460e695c] on object of type org.gradle.api.tasks.compile.CompileOptions.

This was resolved via:

subprojects {
    apply plugin: 'net.ltgt.errorprone'
}

Second issue:

> Could not resolve all files for configuration ':project-x:annotationProcessor'.
   > Could not find com.google.errorprone:error_prone_core:0.7.1.
     Required by:
         project :project-x

enhancement, varargs check with severity first

        ep.check( "MissingOverride", CheckSeverity.ERROR);
        ep.check( "Var", CheckSeverity.ERROR );

instead of that, be able to write

  ep.check( CheckSeverity.ERROR, "MissingOverride", "Var" );

Gradle 6 deprecation warnings

When running a compile task under Gradle 6, the following warning is emitted:

> Task :backend:compileBackendJava
Property 'options.compilerArgumentProviders.errorprone$0.name' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.

Is JDK8 still not recommended?

I just saw the announcement of version 2.4.0 or error-prone and that states that version 2.4.0 is compatible with JDK8. Does that mean that this plugin with error-prone-2.4.0 will work w/o "com.google.errorprone:javac:9+181-r4173-1"?

error: plug-in not found: ErrorProne

my gradle setting as flow:
buildscript {
dependencies {
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.3.0'
}
}
apply plugin: "net.ltgt.errorprone"
dependencies {
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
}

but i get a build error:
error: plug-in not found: ErrorProne

thanks~

In Kotlin DSL errorprone plugin with apply=false does not work

If you create an empty project using groovy DSL and add errorprone plugin with apply=false as follows:

build.gradle

plugins {
    id 'net.ltgt.errorprone' version '1.1.1' apply false
}

subprojects {
    apply 'net.ltgt.errorprone'

    repositories {
        mavenCentral()
    }

    dependencies {
        errorprone 'com.google.errorprone:error_prone_core:latest.release'
    }
}

then your build is successful.

However, if you create an empty project using Kotlin DSL and add errorprone plugin with apply=false as follows:

build.gradle.kts

plugins {
    id("net.ltgt.errorprone") version "1.1.1" apply false 
}

subprojects {
    apply(plugin = "net.ltgt.errorprone")

    repositories {
        mavenCentral()
    }

    dependencies {
        errorprone("com.google.errorprone:error_prone_core:latest.release")
    }
}

then your build fails:

FAILURE: Build failed with an exception.

* Where:
Build file 'build.gradle.kts' line: 13

* What went wrong:
Script compilation error:

  Line 13:         errorprone("com.google.errorprone:error_prone_core:latest.release")
                   ^ Unresolved reference: errorprone

1 error

Configuration caching issue

When running with

  • AGP 4.1beta04,
  • Gradle 6.6-rc1
  • kotlin 1.4 M3

using configuration cache, I see the following error:

* What went wrong:
Execution failed for task ':common:workflow:android:compileDebugJavaWithJavac'.
> Extension with name 'errorprone' does not exist. Currently registered extension names: [ext]
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':common:workflow:android:compileDebugJavaWithJavac'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:208)
        at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:263)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:206)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:187)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:409)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:399)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:94)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.gradle.api.UnknownDomainObjectException: Extension with name 'errorprone' does not exist. Currently registered extension names: [ext]
        at org.gradle.internal.extensibility.ExtensionsStorage.unknownExtensionException(ExtensionsStorage.java:144)
        at org.gradle.internal.extensibility.ExtensionsStorage.getByName(ExtensionsStorage.java:123)
        at org.gradle.internal.extensibility.DefaultConvention.getByName(DefaultConvention.java:174)
        at net.ltgt.gradle.errorprone.ErrorProneOptionsKt.getErrorprone(ErrorProneOptions.kt:124)
        at net.ltgt.gradle.errorprone.ErrorPronePlugin$apply$1$1.execute(ErrorPronePlugin.kt:87)
        at net.ltgt.gradle.errorprone.ErrorPronePlugin$apply$1$1.execute(ErrorPronePlugin.kt:32)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:731)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:704)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:570)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:395)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:387)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:84)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:555)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:538)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$300(ExecuteActionsTaskExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:279)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:268)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
        at java.util.Optional.map(Optional.java:215)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:67)
        at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:36)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:49)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:34)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:43)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
        at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:34)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:44)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:54)
        at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:38)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
        at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:159)
        at org.gradle.internal.execution.steps.CacheStep.executeAndStoreInCache(CacheStep.java:135)
        at org.gradle.internal.execution.steps.CacheStep.lambda$executeWithCache$2(CacheStep.java:112)
        at java.util.Optional.orElseGet(Optional.java:267)
        at org.gradle.internal.execution.steps.CacheStep.lambda$executeWithCache$3(CacheStep.java:112)
        at org.gradle.internal.Try$Success.map(Try.java:162)
        at org.gradle.internal.execution.steps.CacheStep.executeWithCache(CacheStep.java:81)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:71)
        at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:43)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:44)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:33)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:92)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:85)
        at java.util.Optional.map(Optional.java:215)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:94)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:49)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:79)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:53)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:78)
        at java.util.Optional.orElseGet(Optional.java:267)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:78)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:39)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:40)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:28)
        at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:195)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:187)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:114)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:409)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:399)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:157)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:242)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:150)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:94)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:372)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:359)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:352)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:338)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
        at java.lang.Thread.run(Thread.java:748)

Support Gradle 6.7 toolchain support to detect JDK 8

https://docs.gradle.org/6.7-rc-1/userguide/toolchains.html

For now, the plugin relies on the current JVM, but will disable configuring the bootclasspath based on fork options' executable and/or javaHome, which are being replaced with javaCompiler.
With toolchains, we could support JDK 11 builds compiling with JDK 8 and correctly configure the bootclasspath in those cases; and disable ErrorProne altogether (with a warning?) when compiling with an even older JDK.

[Wishlist] I wish to be able to get all of the BugPattern names

adding error bugs and counting

tasks.withType<JavaCompile>().configureEach {
  options.errorprone {
    nullaway {
      severity.set(CheckSeverity.ERROR)
      acknowledgeRestrictiveAnnotations.set(true)
      handleTestAssertionLibraries.set(true)
    }
    disableWarningsInGeneratedCode.set(true)
    error(
      "AnnotationPosition",
      "AssertFalse",
      "CheckedExceptionNotThrown",
      "DifferentNameButSame",
      "EmptyTopLevelDeclaration",
      "EqualsBrokenForNull",
      "ExpectedExceptionChecker",
      "InconsistentOverloads",
      "InitializeInline",
      "InterruptedExceptionSwallowed",
      "InterfaceWithOnlyStatics",
      "NonCanonicalStaticMemberImport",
      "PreferJavaTimeOverload",
      "ClassNamedLikeTypeParameter",
      "ConstantField",
      "FieldCanBeLocal",
      "FieldCanBeStatic",
      "ForEachIterable",
      "MethodCanBeStatic",
      "MultiVariableDeclaration",
      "MultiTopLevelClasses",
      "PackageLocation",
      "RemoveUnusedImports",
      "ParameterNotNullable",
      "NullOptional",
      "NullableConstructor",
      "NullablePrimitive",
      "NullableVoid",
      "Overrides",
      "MissingOverride",
      "Var",
      "WildcardImport"
    )
  }
}

I wish to write instead

val excluded = listOf("Excldued")
error( getAllPatterns.stream().map({ p -> p.name }).filter({ bug -> excluded.contains(bug) });

this of course makes the huge assumption that how you're consuming Error Prone, would allow you to get the Patterns directly from it.

semver still? 0.6.+ doesn't match 0.6

previously I could have matched 0.0.+ as a dep for my plugin (which is just shared settings), now however I can't match match 0.6.+ since the release wasn't 0.6.0, but 0.6. is this still using semantic versioning or will the next version be 0.7, 0.8 etc. is there still a safe way to match api versions? (this is a question but alos maybe a bug, if this is still semantically versioned, then the version should be 0.6.0)

Gradle 5.6 configuration

Apparently with Gradle 5.6 the Java task configuration got lazy, so this does no longer work:

 tasks.withType(JavaCompile) {
            options.errorprone.errorproneArgs += [
                        '-Xep:ImmutableEnumChecker:ERROR',
                        '-Xep:MissingOverride:ERROR',
                        ...
           ]
}

but spits out an error:

No signature of method: org.gradle.api.internal.provider.DefaultListProperty.plus() is applicable for argument types: (ArrayList) values: [[-Xep:ImmutableEnumChecker:ERROR, -Xep:MissingOverride:ERROR, ...]]
  Possible solutions: value(java.lang.Iterable), value(org.gradle.api.provider.Provider), value(java.lang.Iterable), value(org.gradle.api.provider.Provider), is(java.lang.Object), split(groovy.lang.Closure)

The configuration via the left-shift operator also does no longer work:

No signature of method: org.gradle.api.internal.provider.DefaultListProperty.leftShift() is applicable for argument types: (String) values: [-Xep:ImmutableEnumChecker:ERROR]

Changing errorproneArgs += [] to errorproneArgs = [] fixed it for me.

Cannot add to errorproneArgs

In 0.7.1 this was a mutable collection, but in 0.8 it does not support addition operators. For example,

options.errorprone.errorproneArgs << '-Xep:NullAway:ERROR'

Caused by: groovy.lang.MissingMethodException:
No signature of method: org.gradle.api.internal.provider.DefaultListProperty.leftShift()
is applicable for argument types: (String) values: [-Xep:NullAway:ERROR]

Error: plug-in not found: ErrorProne when using Kapt

I'm trying to migrate Android project from plugin version 0.0.16 to 0.6 however compilation fails with

> Task :app:compileDebugJavaWithJavac FAILED
error: plug-in not found: ErrorProne

When running build with ./gradlew --info compileDebugSources there is more info

Starting process 'Gradle Worker Daemon 13'. Working directory: /home/alapshin/.gradle/workers Command: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181.b15-5.fc29.x86_64/bin/java -Djava.security.manager=worker.org.gradle.process.internal.worker.child.BootstrapSecurityManager -Xbootclasspath/p:/home/alapshin/.gradle/caches/modules-2/files-2.1/com.google.errorprone/javac/9+181-r4173-1/bdf4c0aa7d540ee1f7bf14d47447aea4bbf450c5/javac-9+181-r4173-1.jar -Dfile.encoding=UTF-8 -Duser.country=IE -Duser.language=en -Duser.variant -cp /home/alapshin/.gradle/caches/4.9/workerMain/gradle-worker.jar worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Worker Daemon 13'
Successfully started process 'Gradle Worker Daemon 13'
Started Gradle worker daemon (0.262 secs) with fork options DaemonForkOptions{executable=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181.b15-5.fc29.x86_64/bin/java, minHeapSize=null, maxHeapSize=null, jvmArgs=[-Xbootclasspath/p:/home/alapshin/.gradle/caches/modules-2/files-2.1/com.google.errorprone/javac/9+181-r4173-1/bdf4c0aa7d540ee1f7bf14d47447aea4bbf450c5/javac-9+181-r4173-1.jar], classpath=[], keepAliveMode=SESSION}.
Compiling with JDK Java compiler API.
error: plug-in not found: ErrorProne

Versions of components:
java: 1.8.0_181
gradle: 4.9
android gradle plugin: 3.2.1
errorprone: 2.3.2
errorproneJavac: 9+181-r4173-1
gradle-errorprone-plugin: 0.6

Error prone plugin uses fork

Is there a reason why error-prone starts in a fork? If I'm not mistaken original javac just runs on a gradle daemon.

I was getting OOM with javac and I didn't find an easy way how to specify more memory for the error-prone java fork.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.