Partial sync of gradle conventions with sdk repo (#4836)

* Sync gradle conventions

* oops
This commit is contained in:
Trask Stalnaker 2021-12-08 03:50:32 -08:00 committed by GitHub
parent f5016109f2
commit d52f62522d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 52 deletions

View File

@ -8,78 +8,82 @@ dependencies {
errorprone("com.google.errorprone:error_prone_core") errorprone("com.google.errorprone:error_prone_core")
} }
val disableErrorProne = gradle.startParameter.projectProperties.get("disableErrorProne")?.toBoolean() val disableErrorProne = properties["disableErrorProne"]?.toString()?.toBoolean() ?: false
?: false
tasks { tasks {
withType<JavaCompile>().configureEach { withType<JavaCompile>().configureEach {
options.errorprone { with(options) {
isEnabled.set(!disableErrorProne) errorprone {
if (disableErrorProne) {
logger.warn("Errorprone has been disabled. Build may not result in a valid PR build.")
isEnabled.set(false)
}
disableWarningsInGeneratedCode.set(true) disableWarningsInGeneratedCode.set(true)
allDisabledChecksAsWarnings.set(true) allDisabledChecksAsWarnings.set(true)
excludedPaths.set(".*/build/generated/.*|.*/concurrentlinkedhashmap/.*") excludedPaths.set(".*/build/generated/.*|.*/concurrentlinkedhashmap/.*")
disable("BooleanParameter") disable("BooleanParameter")
// Doesn't work well with Java 8 // Doesn't work well with Java 8
disable("FutureReturnValueIgnored") disable("FutureReturnValueIgnored")
// Require Guava // Require Guava
disable("AutoValueImmutableFields") disable("AutoValueImmutableFields")
disable("StringSplitter") disable("StringSplitter")
disable("ImmutableMemberCollection") disable("ImmutableMemberCollection")
// Don't currently use this (to indicate a local variable that's mutated) but could // Don't currently use this (to indicate a local variable that's mutated) but could
// consider for future. // consider for future.
disable("Var") disable("Var")
// Don't support Android without desugar // Don't support Android without desugar
disable("AndroidJdkLibsChecker") disable("AndroidJdkLibsChecker")
disable("Java7ApiChecker") disable("Java7ApiChecker")
disable("StaticOrDefaultInterfaceMethod") disable("StaticOrDefaultInterfaceMethod")
// Great check, but for bytecode manipulation it's too common to separate over // Great check, but for bytecode manipulation it's too common to separate over
// onEnter / onExit // onEnter / onExit
// TODO(anuraaga): Only disable for auto instrumentation project. // TODO(anuraaga): Only disable for auto instrumentation project.
disable("MustBeClosedChecker") disable("MustBeClosedChecker")
// Common to avoid an allocation. Revisit if it's worth opt-in suppressing instead of // Common to avoid an allocation. Revisit if it's worth opt-in suppressing instead of
// disabling entirely. // disabling entirely.
disable("MixedMutabilityReturnType") disable("MixedMutabilityReturnType")
// We end up using obsolete types if a library we're instrumenting uses them. // We end up using obsolete types if a library we're instrumenting uses them.
disable("JdkObsolete") disable("JdkObsolete")
disable("JavaUtilDate") disable("JavaUtilDate")
// Limits API possibilities // Limits API possibilities
disable("NoFunctionalReturnType") disable("NoFunctionalReturnType")
// Storing into a variable in onEnter triggers this unfortunately. // Storing into a variable in onEnter triggers this unfortunately.
// TODO(anuraaga): Only disable for auto instrumentation project. // TODO(anuraaga): Only disable for auto instrumentation project.
disable("UnusedVariable") disable("UnusedVariable")
// TODO(anuraaga): Remove this, we use this pattern in several tests and it will mean // TODO(anuraaga): Remove this, we use this pattern in several tests and it will mean
// some moving. // some moving.
disable("DefaultPackage") disable("DefaultPackage")
// TODO(anuraaga): Remove this, all our advice classes miss constructors but probably should // TODO(anuraaga): Remove this, all our advice classes miss constructors but probably should
// address this. // address this.
disable("PrivateConstructorForUtilityClass") disable("PrivateConstructorForUtilityClass")
// TODO(anuraaga): Remove this, probably after instrumenter API migration instead of dealing // TODO(anuraaga): Remove this, probably after instrumenter API migration instead of dealing
// with older APIs. // with older APIs.
disable("InconsistentOverloads") disable("InconsistentOverloads")
disable("TypeParameterNaming") disable("TypeParameterNaming")
// We don't use tools that recognize. // We don't use tools that recognize.
disable("InlineMeSuggester") disable("InlineMeSuggester")
disable("DoNotCallSuggester") disable("DoNotCallSuggester")
if (name.contains("Jmh") || name.contains("Test")) { if (name.contains("Jmh") || name.contains("Test")) {
disable("HashCodeToString") disable("HashCodeToString")
disable("MemberName") disable("MemberName")
}
} }
} }
} }

View File

@ -32,5 +32,7 @@ jmhReport {
tasks { tasks {
named("jmh") { named("jmh") {
finalizedBy(named("jmhReport")) finalizedBy(named("jmhReport"))
outputs.cacheIf { false }
} }
} }