Ignore proto-generated code for ErrorProne

Previously if protobuf-generated code triggered ErrorProne we'd have to disable
the failing check for all code in that task. With -XepExcludedPaths we can
disable the ErrorProne-checking just for protobuf. Note that we continue using
ErrorProne on our generated code. Also note this only applies to ErrorProne
checks; JDK checks still require task-level disabling.
This commit is contained in:
Eric Anderson 2018-03-08 16:55:16 -08:00
parent 7fd22080e9
commit 1fb72ef6c1
3 changed files with 11 additions and 9 deletions

View File

@ -175,8 +175,10 @@ subprojects {
[compileJava, compileTestJava, compileJmhJava].each() {
// Protobuf-generated code produces some warnings.
// https://github.com/google/protobuf/issues/2718
it.options.compilerArgs += ["-Xlint:-cast", "-Xep:MissingOverride:OFF",
"-Xep:ReferenceEquality:OFF", "-Xep:FunctionalInterfaceClash:OFF"]
it.options.compilerArgs += [
"-Xlint:-cast",
"-XepExcludedPaths:.*/src/generated/[^/]+/java/.*",
]
}
}

View File

@ -151,15 +151,16 @@ sourceSets {
}
compileTestJava {
options.compilerArgs += ["-Xlint:-cast", "-Xep:MissingOverride:OFF",
"-Xep:ReferenceEquality:OFF", "-Xep:FunctionalInterfaceClash:OFF"]
options.compilerArgs += [
"-Xlint:-cast",
"-XepExcludedPaths:.*/build/generated/source/proto/.*",
]
}
compileTestLiteJava {
options.compilerArgs = compileTestJava.options.compilerArgs
// Protobuf-generated Lite produces quite a few warnings.
options.compilerArgs += ["-Xlint:-rawtypes", "-Xlint:-unchecked",
"-Xep:MissingOverride:OFF", "-Xep:ReferenceEquality:OFF",
"-Xep:FallThrough:OFF"]
options.compilerArgs += ["-Xlint:-rawtypes", "-Xlint:-unchecked", "-Xlint:-fallthrough"]
}
compileTestNanoJava {

View File

@ -28,8 +28,7 @@ dependencies {
compileTestJava {
// Protobuf-generated Lite produces quite a few warnings.
options.compilerArgs += ["-Xlint:-rawtypes", "-Xlint:-unchecked", "-Xlint:-fallthrough",
"-Xep:MissingOverride:OFF", "-Xep:ReferenceEquality:OFF", "-Xep:FallThrough:OFF",
"-Xep:JavaLangClash:OFF" /* The Enum protobuf clashes */]
"-XepExcludedPaths:.*/build/generated/source/proto/.*"]
}
protobuf {