-
Notifications
You must be signed in to change notification settings - Fork 33
usage problem #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm afraid this is Gradle 101 (a plugin applies to a project, and needs to be explicitly applied to a subproject if that's what you want) and dependency management 101 (know where your dependencies are coming from, and where to look for updates; in this case for Error Prone, that would be https://search.maven.org/search?q=g:com.google.errorprone%20AND%20a:error_prone_core&core=gav, vs. https://plugins.gradle.org/plugin/net.ltgt.errorprone for the Gradle plugin). Moreover, the very first line of the README says:
with a link that points to Error Prone itself. I couldn't make it clearer (IMO) –in addition to the repository URL, package name, etc.– that this is a third-party project bringing Error Prone (from Google) to Gradle. This is not the only way to use Error Prone with Gradle by the way (I should probably document that somewhere). |
(Sorry for reviving a closed issue.)
@tbroyer I would be very interested to learn about alternatives ways to use Gradle with Error Prone. Do you have any ideas or pointers that could lead me in the right direction? |
The simplest way to use Error Prone with Gradle, without any plugin, is (using Kotlin DSL here, adapt if you prefer Groovy): dependencies {
annotationProcessor("com.google.errorprone:error_prone_core:2.3.3")
testAnnotationProcessor("com.google.errorprone:error_prone_core:2.3.3")
}
tasks {
compileJava {
options.compilerArgs.addAll(arrayOf("-XDcompilePolicy=simple", "-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode"))
}
testCompileJava {
options.compilerArgs.addAll(arrayOf("-XDcompilePolicy=simple", "-Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode -XepCompilingTestOnlyCode"))
}
} (notice how Error Prone flags are all passed in the same compiler argument, separated by spaces) To make it work with Java 8, you need to fork the tasks and prepend Error Prone's JavaC to the bootstrap classpath, so this gets hard (I won't show you how to do it here; feel free to look at the plugin's code how it does it) What this plugin does is:
|
Thanks for the detailed writeup, @tbroyer. I'm actually trying to get Errorprone to work with Oracle JDK 8 and Gradle. I'm quite new to working with javac and Gradle, so forgive me if this is a stupid question, but can I confirm that the JDK 8 support that you have implemented essentially replaces the JDK8 P.S. I'm happy to open another issue to discuss this, if you think that makes more sense. |
Yes.
This is not specific to Gradle, so feel free to reach out to the ErrorProne Google Group if you have questions. |
Thanks. That answers my questions for now. I'll be sure to reach out to the ErrorProne Google Group if I have questions about |
ran into two issues using errorprone in our project:
This was resolved via:
Second issue:
The text was updated successfully, but these errors were encountered: