blob: 1f9bebed27bda688c76a43d89476bdf6fbe87add [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
def skipReason
if (rootProject.usesAltJvm && rootProject.runtimeJavaVersion > JavaVersion.VERSION_15) {
skipReason = "won't work with JDK ${rootProject.runtimeJavaVersion} if used as alternative java toolchain"
}
if (!propertyOrDefault("validation.errorprone", isCIBuild).asBoolean()) {
skipReason = "skipped on builds not running inside CI environments, pass -Pvalidation.errorprone=true to enable"
}
if (skipReason) {
configure(rootProject) {
task errorProneSkipped() {
doFirst {
logger.warn("WARNING: errorprone disabled (${skipReason})")
}
}
}
}
allprojects { prj ->
plugins.withType(JavaPlugin) {
// LUCENE-9650: Errorprone on master/gradle does not work with JDK-16+ when running as plugin
// inside a forked Javac process. Javac running inside Gradle works, because we have
// additional module system opens in place.
// This is a hack to keep the dependency (so that palantir's version check doesn't complain)
// but don't include the plugin (which fails on JDK16+).
if (skipReason) {
tasks.withType(JavaCompile) { task -> task.dependsOn ":errorProneSkipped" }
configurations {
errorprone
}
dependencies {
errorprone("com.google.errorprone:error_prone_core")
}
} else {
prj.apply plugin: 'net.ltgt.errorprone'
dependencies {
errorprone("com.google.errorprone:error_prone_core")
}
tasks.withType(JavaCompile) { task ->
task.dependsOn ":checkJdkInternalsExportedToGradle"
options.errorprone.disableWarningsInGeneratedCode = true
options.errorprone.errorproneArgs = [
'-Xep:InlineMeSuggester:OFF', // We don't use this annotation
// bug patterns related to our tests
'-Xep:ExtendingJUnitAssert:OFF', // we inherit from LuceneTestCase which extends Assert
'-Xep:UseCorrectAssertInTests:OFF', // and this is a consequence of the above
'-Xep:CatchFail:OFF', // our code is generally descriptive enough, fix case by case if tests fail
'-Xep:JUnit4TestNotRun:OFF', // RandomizedRunner finds unannotated test methods no problem
'-Xep:CatchAndPrintStackTrace:OFF', // TODO: there's a lot of these but they should be easy to address
'-Xep:FloatingPointLiteralPrecision:OFF', // TODO: a lot of these in our tests, likely unintentional
'-Xep:StaticAssignmentInConstructor:OFF', // we assign SolrTestCaseJ4.configString in many tests, difficult to untangle
'-Xep:ComparableType:OFF', // SolrTestCaseJ4.Doc and Fld are messy
'-Xep:AlmostJavadoc:OFF',
'-Xep:AlreadyChecked:OFF',
'-Xep:AmbiguousMethodReference:OFF',
'-Xep:ArgumentSelectionDefectChecker:OFF',
'-Xep:BadImport:OFF', // style preference that we don't want to enforce
'-Xep:BadInstanceof:OFF',
'-Xep:BadShiftAmount:OFF',
'-Xep:CanIgnoreReturnValueSuggester:OFF',
'-Xep:ClassCanBeStatic:OFF',
'-Xep:ComplexBooleanConstant:OFF',
'-Xep:DoubleBraceInitialization:OFF',
'-Xep:DoubleCheckedLocking:OFF',
'-Xep:EmptyCatch:OFF',
'-Xep:EqualsGetClass:OFF',
'-Xep:EqualsUnsafeCast:OFF',
'-Xep:EscapedEntity:OFF',
'-Xep:Finally:OFF',
'-Xep:FutureReturnValueIgnored:OFF',
'-Xep:HidingField:OFF',
'-Xep:IdentityBinaryExpression:OFF',
'-Xep:IdentityHashMapUsage:OFF',
'-Xep:ImmutableEnumChecker:OFF',
'-Xep:InconsistentCapitalization:OFF',
'-Xep:InlineFormatString:OFF', // this introduces redundancy in format strings
'-Xep:InputStreamSlowMultibyteRead:OFF',
'-Xep:IntLongMath:OFF',
'-Xep:InvalidBlockTag:OFF',
'-Xep:InvalidInlineTag:OFF',
'-Xep:InvalidParam:OFF',
'-Xep:JavaLangClash:OFF',
'-Xep:JavaUtilDate:OFF',
'-Xep:JdkObsolete:OFF',
'-Xep:LogicalAssignment:OFF',
'-Xep:MissingOverride:OFF',
'-Xep:MissingSummary:OFF',
'-Xep:MixedMutabilityReturnType:OFF',
'-Xep:ModifiedButNotUsed:OFF',
'-Xep:MutablePublicArray:OFF',
'-Xep:NarrowingCompoundAssignment:OFF',
'-Xep:NegativeCharLiteral:OFF',
'-Xep:NonAtomicVolatileUpdate:OFF',
'-Xep:NonCanonicalType:OFF',
'-Xep:ObjectToString:OFF',
'-Xep:ObjectsHashCodePrimitive:OFF',
'-Xep:OperatorPrecedence:OFF',
'-Xep:ProtectedMembersInFinalClass:OFF',
'-Xep:ReferenceEquality:OFF',
'-Xep:ReturnValueIgnored:OFF',
'-Xep:SameNameButDifferent:OFF',
'-Xep:ShortCircuitBoolean:OFF',
'-Xep:StaticGuardedByInstance:OFF',
'-Xep:StreamResourceLeak:OFF',
'-Xep:StringSplitter:OFF',
'-Xep:SynchronizeOnNonFinalField:OFF',
'-Xep:ThreadJoinLoop:OFF',
'-Xep:ThreadLocalUsage:OFF',
'-Xep:ThreadPriorityCheck:OFF',
'-Xep:TypeParameterShadowing:OFF',
'-Xep:TypeParameterUnusedInFormals:OFF',
'-Xep:UnescapedEntity:OFF',
'-Xep:UnicodeEscape:OFF',
'-Xep:UnnecessaryParentheses:OFF',
'-Xep:UnsynchronizedOverridesSynchronized:OFF',
'-Xep:UnusedMethod:OFF',
'-Xep:UnusedVariable:OFF',
'-Xep:WaitNotInLoop:OFF',
]
}
}
}
}