2020-09-07 17:42:48 -04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2021-03-26 16:42:15 -04:00
|
|
|
def skipReason
|
|
|
|
|
2022-01-07 13:19:46 -05:00
|
|
|
if (rootProject.usesAltJvm && rootProject.runtimeJavaVersion > JavaVersion.VERSION_15) {
|
|
|
|
skipReason = "won't work with JDK ${rootProject.runtimeJavaVersion} if used as alternative java toolchain"
|
2021-03-26 16:42:15 -04:00
|
|
|
}
|
|
|
|
|
2022-05-14 14:49:50 -04:00
|
|
|
if (!propertyOrDefault("validation.errorprone", isCIBuild).asBoolean()) {
|
|
|
|
skipReason = "skipped on builds not running inside CI environments, pass -Pvalidation.errorprone=true to enable"
|
2021-03-26 16:42:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (skipReason) {
|
2021-03-15 05:19:27 -04:00
|
|
|
configure(rootProject) {
|
|
|
|
task errorProneSkipped() {
|
|
|
|
doFirst {
|
2021-03-26 16:42:15 -04:00
|
|
|
logger.warn("WARNING: errorprone disabled (${skipReason})")
|
2021-03-15 05:19:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-28 17:20:52 -05:00
|
|
|
}
|
|
|
|
|
2020-09-07 17:42:48 -04:00
|
|
|
allprojects { prj ->
|
|
|
|
plugins.withType(JavaPlugin) {
|
2022-01-07 13:19:46 -05:00
|
|
|
// 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)
|
2021-03-15 05:19:27 -04:00
|
|
|
// but don't include the plugin (which fails on JDK16+).
|
2021-03-26 16:42:15 -04:00
|
|
|
if (skipReason) {
|
2021-03-15 05:19:27 -04:00
|
|
|
tasks.withType(JavaCompile) { task -> task.dependsOn ":errorProneSkipped" }
|
|
|
|
configurations {
|
|
|
|
errorprone
|
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
errorprone("com.google.errorprone:error_prone_core")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
prj.apply plugin: 'net.ltgt.errorprone'
|
2020-09-07 17:42:48 -04:00
|
|
|
|
2021-03-15 05:19:27 -04:00
|
|
|
dependencies {
|
|
|
|
errorprone("com.google.errorprone:error_prone_core")
|
|
|
|
}
|
2020-09-07 17:42:48 -04:00
|
|
|
|
2021-03-11 16:27:25 -05:00
|
|
|
tasks.withType(JavaCompile) { task ->
|
2022-10-02 14:41:46 -04:00
|
|
|
// Disable errorprone on the MR-JAR tasks
|
|
|
|
if (task.name ==~ /compileMain\d+Java/) {
|
2022-09-26 09:22:04 -04:00
|
|
|
options.errorprone.enabled = false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-04-10 14:35:45 -04:00
|
|
|
task.dependsOn ":checkJdkInternalsExportedToGradle"
|
|
|
|
|
2021-03-11 16:27:25 -05:00
|
|
|
options.errorprone.disableWarningsInGeneratedCode = true
|
|
|
|
options.errorprone.errorproneArgs = [
|
2022-11-15 06:42:41 -05:00
|
|
|
'-XepAllErrorsAsWarnings', // warnings still fail build by default, but allows usage of -Pjavac.failOnWarnings=false
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:InlineMeSuggester:OFF', // We don't use this annotation
|
|
|
|
|
2021-03-11 16:27:25 -05:00
|
|
|
// test
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:AlmostJavadoc:OFF',
|
2022-09-25 11:10:22 -04:00
|
|
|
'-Xep:AlreadyChecked:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:AmbiguousMethodReference:OFF',
|
|
|
|
'-Xep:ArgumentSelectionDefectChecker:OFF',
|
|
|
|
'-Xep:ArrayAsKeyOfSetOrMap:OFF',
|
|
|
|
'-Xep:ArrayEquals:OFF',
|
|
|
|
'-Xep:ArrayHashCode:OFF',
|
|
|
|
'-Xep:ArrayToString:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:AssertionFailureIgnored:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:BadImport:OFF',
|
|
|
|
'-Xep:BadInstanceof:OFF',
|
|
|
|
'-Xep:BadShiftAmount:OFF',
|
|
|
|
'-Xep:BoxedPrimitiveConstructor:OFF', // we have forbiddenapis for that
|
|
|
|
'-Xep:ByteBufferBackingArray:OFF',
|
2022-09-25 11:10:22 -04:00
|
|
|
'-Xep:CanIgnoreReturnValueSuggester:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:CatchAndPrintStackTrace:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:CatchFail:OFF',
|
|
|
|
'-Xep:CharacterGetNumericValue:OFF',
|
|
|
|
'-Xep:ClassCanBeStatic:OFF',
|
|
|
|
'-Xep:CollectionIncompatibleType:OFF',
|
|
|
|
'-Xep:CollectionUndefinedEquality:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:ComparableType:OFF',
|
|
|
|
'-Xep:ComplexBooleanConstant:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:DefaultPackage:OFF',
|
|
|
|
'-Xep:DoNotCallSuggester:OFF',
|
2022-09-25 11:10:22 -04:00
|
|
|
'-Xep:DoNotCall:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:DoubleBraceInitialization:OFF',
|
|
|
|
'-Xep:DoubleCheckedLocking:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:EmptyCatch:OFF',
|
2022-09-25 11:10:22 -04:00
|
|
|
'-Xep:EmptyTopLevelDeclaration:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:EqualsGetClass:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:EqualsIncompatibleType:OFF',
|
|
|
|
'-Xep:EqualsUnsafeCast:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:EscapedEntity:OFF',
|
|
|
|
'-Xep:ExtendingJUnitAssert:OFF',
|
2022-09-25 11:10:22 -04:00
|
|
|
'-Xep:ExtendsObject:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:FallThrough:OFF',
|
|
|
|
'-Xep:Finally:OFF',
|
|
|
|
'-Xep:FloatingPointLiteralPrecision:OFF',
|
|
|
|
'-Xep:FormatString:OFF',
|
|
|
|
'-Xep:FutureReturnValueIgnored:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:HidingField:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:IdentityBinaryExpression:OFF',
|
|
|
|
'-Xep:IdentityHashMapUsage:OFF',
|
|
|
|
'-Xep:ImmutableEnumChecker:OFF',
|
|
|
|
'-Xep:InconsistentCapitalization:OFF',
|
|
|
|
'-Xep:InconsistentHashCode:OFF',
|
|
|
|
'-Xep:InfiniteRecursion:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:InlineFormatString:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:InputStreamSlowMultibyteRead:OFF',
|
|
|
|
'-Xep:IntLongMath:OFF',
|
|
|
|
'-Xep:InvalidBlockTag:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:InvalidInlineTag:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:InvalidParam:OFF',
|
|
|
|
'-Xep:InvalidPatternSyntax:OFF',
|
|
|
|
'-Xep:JUnit4TestNotRun:OFF',
|
|
|
|
'-Xep:JavaLangClash:OFF',
|
|
|
|
'-Xep:JavaUtilDate:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:JdkObsolete:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:LockNotBeforeTry:OFF',
|
|
|
|
'-Xep:LogicalAssignment:OFF',
|
2022-09-25 11:10:22 -04:00
|
|
|
'-Xep:LongDoubleConversion:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:MathAbsoluteRandom:OFF',
|
|
|
|
'-Xep:MissingFail:OFF',
|
|
|
|
'-Xep:MissingOverride:OFF',
|
|
|
|
'-Xep:MissingSummary:OFF',
|
|
|
|
'-Xep:MisusedDayOfYear:OFF',
|
|
|
|
'-Xep:MixedMutabilityReturnType:OFF',
|
|
|
|
'-Xep:ModifiedButNotUsed:OFF',
|
|
|
|
'-Xep:MutablePublicArray:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:NarrowingCompoundAssignment:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:NonAtomicVolatileUpdate:OFF',
|
|
|
|
'-Xep:NonCanonicalType:OFF',
|
|
|
|
'-Xep:ObjectToString:OFF',
|
|
|
|
'-Xep:ObjectsHashCodePrimitive:OFF',
|
|
|
|
'-Xep:OperatorPrecedence:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
'-Xep:ProtectedMembersInFinalClass:OFF',
|
|
|
|
'-Xep:ReferenceEquality:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:ReturnValueIgnored:OFF',
|
|
|
|
'-Xep:SameNameButDifferent:OFF',
|
|
|
|
'-Xep:SelfAssignment:OFF',
|
|
|
|
'-Xep:ShortCircuitBoolean:OFF',
|
|
|
|
'-Xep:StaticAssignmentInConstructor:OFF',
|
2022-09-25 11:10:22 -04:00
|
|
|
'-Xep:StaticAssignmentOfThrowable:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:StaticGuardedByInstance:OFF',
|
|
|
|
'-Xep:StreamResourceLeak:OFF',
|
|
|
|
'-Xep:StringSplitter:OFF',
|
|
|
|
'-Xep:SynchronizeOnNonFinalField:OFF',
|
|
|
|
'-Xep:ThreadJoinLoop:OFF',
|
|
|
|
'-Xep:ThreadLocalUsage:OFF',
|
|
|
|
'-Xep:ThreadPriorityCheck:OFF',
|
|
|
|
'-Xep:ThrowNull:OFF',
|
|
|
|
'-Xep:ToStringReturnsNull:OFF',
|
|
|
|
'-Xep:TryFailThrowable:OFF',
|
|
|
|
'-Xep:TypeParameterShadowing:OFF',
|
|
|
|
'-Xep:TypeParameterUnusedInFormals:OFF',
|
|
|
|
'-Xep:UndefinedEquals:OFF',
|
2022-09-25 11:10:22 -04:00
|
|
|
'-Xep:UnnecessaryLongToIntConversion:OFF',
|
|
|
|
'-Xep:UnusedTypeParameter:OFF',
|
|
|
|
'-Xep:UnicodeInCode:OFF',
|
2022-01-07 13:19:46 -05:00
|
|
|
'-Xep:UnescapedEntity:OFF',
|
|
|
|
'-Xep:UnicodeEscape:OFF',
|
|
|
|
'-Xep:UnnecessaryLambda:OFF',
|
|
|
|
'-Xep:UnnecessaryParentheses:OFF',
|
|
|
|
'-Xep:UnsynchronizedOverridesSynchronized:OFF',
|
|
|
|
'-Xep:UnusedMethod:OFF',
|
|
|
|
'-Xep:UnusedVariable:OFF',
|
|
|
|
'-Xep:UseCorrectAssertInTests:OFF',
|
|
|
|
'-Xep:WaitNotInLoop:OFF',
|
2021-03-11 16:27:25 -05:00
|
|
|
]
|
|
|
|
}
|
2020-09-07 17:42:48 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|