Update net.ltgt.errorprone to 0.6 and enable Error Prone on JDK 10+

This commit is contained in:
Thomas Broyer 2018-12-13 19:17:06 +01:00 committed by Eric Anderson
parent 219c486d4e
commit 2ffc46d6fa
9 changed files with 39 additions and 34 deletions

View File

@ -42,14 +42,8 @@ os:
- linux
jdk:
# net.ltgt.errorprone supports jdk8 and jdk9, but has problems with jdk10
# For jdk10, we need to switch over to using net.ltgt.errorprone-javacplugin,
# and likely update to the latest com.google.errorprone:error_prone_core.
# We have decided not to make our build.gradle support both plugins, so when
# we finally move off of jdk8 and jdk9 we will need use the javac annotation
# processor based plugin.
- oraclejdk8 # if both jdk 8 and 9 are removed, migrate to net.ltgt.errorprone-javacplugin (see above comment)
- oraclejdk9 # if both jdk 8 and 9 are removed, migrate to net.ltgt.errorprone-javacplugin (see above comment)
- oraclejdk8
- oraclejdk9
- openjdk11
notifications:

View File

@ -46,13 +46,15 @@ dependencies {
configureProtoCompilation()
import net.ltgt.gradle.errorprone.CheckSeverity
[compileJava, compileTestJava].each() {
// ALTS retuns a lot of futures that we mostly don't care about.
// protobuf calls valueof. Will be fixed in next release (google/protobuf#4046)
it.options.compilerArgs += [
"-Xlint:-deprecation",
"-Xep:FutureReturnValueIgnored:OFF"
"-Xlint:-deprecation"
]
// ALTS returns a lot of futures that we mostly don't care about.
it.options.errorprone.check("FutureReturnValueIgnored", CheckSeverity.OFF)
}
javadoc { exclude 'io/grpc/alts/internal/**' }

View File

@ -13,7 +13,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.13"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.6"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
@ -41,6 +41,9 @@ repositories {
}
dependencies {
errorprone 'com.google.errorprone:error_prone_core:2.3.2'
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
implementation 'io.grpc:grpc-core:1.18.0-SNAPSHOT' // CURRENT_GRPC_VERSION
testImplementation 'io.grpc:grpc-okhttp:1.18.0-SNAPSHOT' // CURRENT_GRPC_VERSION

View File

@ -36,9 +36,11 @@ dependencies {
compileOnly libraries.javax_annotation
}
import net.ltgt.gradle.errorprone.CheckSeverity
compileJava {
// The Control.Void protobuf clashes
options.compilerArgs += ["-Xep:JavaLangClash:OFF"]
options.errorprone.check("JavaLangClash", CheckSeverity.OFF)
}
configureProtoCompilation()

View File

@ -7,12 +7,14 @@ buildscript {
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.13.0"
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.5'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.6'
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.5'
}
}
import net.ltgt.gradle.errorprone.CheckSeverity
subprojects {
apply plugin: "checkstyle"
apply plugin: "java"
@ -25,23 +27,21 @@ subprojects {
apply plugin: "com.google.osdetector"
// The plugin only has an effect if a signature is specified
apply plugin: "ru.vyarus.animalsniffer"
// jdk10 not supported by errorprone: https://github.com/google/error-prone/issues/860
if (!JavaVersion.current().isJava10Compatible() &&
rootProject.properties.get('errorProne', true).toBoolean()) {
apply plugin: "net.ltgt.errorprone"
apply plugin: "net.ltgt.errorprone"
if (rootProject.properties.get('errorProne', true)) {
dependencies {
// The ErrorProne plugin defaults to the latest, which would break our
// build if error prone releases a new version with a new check
errorprone 'com.google.errorprone:error_prone_core:2.3.2'
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
annotationProcessor 'com.google.guava:guava-beta-checker:1.0'
}
} else {
// Remove per-project error-prone checker config
// Disable Error Prone
allprojects {
afterEvaluate { project ->
project.tasks.withType(JavaCompile) {
options.compilerArgs.removeAll { it.startsWith("-Xep") }
options.errorprone.enabled = false
}
}
}
@ -78,11 +78,11 @@ subprojects {
compileTestJava {
// serialVersionUID is basically guaranteed to be useless in our tests
// LinkedList doesn't hurt much in tests and has lots of usages
options.compilerArgs += [
"-Xlint:-serial",
"-Xep:JdkObsolete:OFF"
"-Xlint:-serial"
]
// LinkedList doesn't hurt much in tests and has lots of usages
options.errorprone.check("JdkObsolete", CheckSeverity.OFF)
}
jar.manifest {
@ -179,8 +179,8 @@ subprojects {
// https://github.com/google/protobuf/issues/2718
it.options.compilerArgs += [
"-Xlint:-cast",
"-XepExcludedPaths:.*/src/generated/[^/]+/java/.*",
]
it.options.errorprone.excludedPaths = ".*/src/generated/[^/]+/java/.*"
}
}

View File

@ -151,9 +151,9 @@ sourceSets {
compileTestJava {
options.compilerArgs += [
"-Xlint:-cast",
"-XepExcludedPaths:.*/build/generated/source/proto/.*",
"-Xlint:-cast"
]
options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
}
compileTestLiteJava {
@ -164,10 +164,12 @@ compileTestLiteJava {
"-Xlint:-unchecked",
"-Xlint:-fallthrough"
]
options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
}
compileTestNanoJava {
options.compilerArgs = compileTestJava.options.compilerArgs
options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
}
protobuf {

View File

@ -38,9 +38,11 @@ dependencies {
configureProtoCompilation()
import net.ltgt.gradle.errorprone.CheckSeverity
compileJava {
// This isn't a library; it can use beta APIs
it.options.compilerArgs += ["-Xep:BetaApi:OFF"]
options.errorprone.check("BetaApi", CheckSeverity.OFF)
}
test {

View File

@ -13,11 +13,11 @@ dependencies {
signature "org.codehaus.mojo.signature:java17:1.0@signature"
}
import net.ltgt.gradle.errorprone.CheckSeverity
[compileJava, compileTestJava].each() {
// Netty retuns a lot of futures that we mostly don't care about.
it.options.compilerArgs += [
"-Xep:FutureReturnValueIgnored:OFF"
]
it.options.errorprone.check("FutureReturnValueIgnored", CheckSeverity.OFF)
}
javadoc {

View File

@ -34,9 +34,9 @@ compileTestJava {
options.compilerArgs += [
"-Xlint:-rawtypes",
"-Xlint:-unchecked",
"-Xlint:-fallthrough",
"-XepExcludedPaths:.*/build/generated/source/proto/.*"
"-Xlint:-fallthrough"
]
options.errorprone.excludedPaths = ".*/build/generated/source/proto/.*"
}
protobuf {