forked from apache/iceberg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
baseline.gradle
151 lines (142 loc) · 6.5 KB
/
baseline.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* 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.
*/
apply plugin: 'com.palantir.baseline-config'
allprojects {
apply plugin: 'com.palantir.baseline-idea'
}
subprojects {
if (it.name == 'iceberg-bom') {
// the BOM does not build anything, the below plugins are not necessary (and can fail)
return
}
// Currently, if any subproject applies the blanket Baseline plugin, it forces the Baseline plugin
// to be applied to ALL projects. And we are not prepared to address all of the build errors that
// occur as a result at this time. Furthermore, baseline-format will not work out of the box for
// us - see below.
// Thus we concede to applying all of the Baseline plugins individually on all the projects we are
// ready to enforce linting on.
apply plugin: 'org.inferred.processors'
if (!project.hasProperty('quick')) {
apply plugin: 'com.palantir.baseline-checkstyle'
apply plugin: 'com.palantir.baseline-error-prone'
}
apply plugin: 'com.palantir.baseline-class-uniqueness'
// What 'com.palantir.baseline-reproducibility' used to do, except the check for the
// `sourceCompatibility` Java compile option, which conflicts with the `release` compile option.
tasks.withType(AbstractArchiveTask.class).configureEach(t -> {
t.setPreserveFileTimestamps(false);
t.setReproducibleFileOrder(true);
t.setDuplicatesStrategy(DuplicatesStrategy.WARN);
});
apply plugin: 'com.palantir.baseline-exact-dependencies'
// We need to update Google Java Format to 1.17.0+ to run spotless on JDK 8, but that requires dropping support for JDK 8.
if (JavaVersion.current() == JavaVersion.VERSION_21) {
task spotlessApply {
doLast {
throw new GradleException("Spotless plugin is currently disabled when running on JDK 21 (until we drop JDK 8). To run spotlessApply please use a different JDK version.")
}
}
} else {
apply plugin: 'com.diffplug.spotless'
}
pluginManager.withPlugin('com.palantir.baseline-checkstyle') {
checkstyle {
// com.palantir.baseline:gradle-baseline-java:4.42.0 (the last version supporting Java 8) pulls
// in an old version of the checkstyle(9.1), which has this OutOfMemory bug https://github.com/checkstyle/checkstyle/issues/10934.
// So, override its checkstyle version using CheckstyleExtension to 9.3 (the latest java 8 supported version) which contains a fix.
toolVersion '9.3'
}
}
pluginManager.withPlugin('com.diffplug.spotless') {
spotless {
java {
target 'src/main/java/**/*.java', 'src/test/java/**/*.java', 'src/jmh/java/**/*.java', 'src/integration/java/**/*.java'
// we use an older version of google-java-format that is compatible with JDK 8
googleJavaFormat("1.7")
removeUnusedImports()
licenseHeaderFile "$rootDir/.baseline/copyright/copyright-header-java.txt"
}
}
}
pluginManager.withPlugin('com.palantir.baseline-error-prone') {
tasks.withType(JavaCompile).configureEach {
options.errorprone.errorproneArgs.addAll (
// error-prone is slow, don't run on tests/generated-src/generated
'-XepExcludedPaths:.*/(test|generated-src|generated)/.*',
'-Xep:AnnotateFormatMethod:ERROR',
'-Xep:CollectionUndefinedEquality:ERROR',
// specific to Palantir - Uses name `log` but we use name `LOG`
'-Xep:ConsistentLoggerName:OFF',
// TODO (https://github.com/apache/iceberg/issues/10853) this is a recently added check. Figure out whether we adjust the code or suppress for good
'-Xep:DangerousJavaDeserialization:WARN',
'-Xep:DangerousThreadPoolExecutorUsage:OFF',
// subclasses are not equal
'-Xep:EqualsGetClass:OFF',
// specific to Palantir
'-Xep:FinalClass:OFF',
'-Xep:FormatStringAnnotation:ERROR',
// TODO (https://github.com/apache/iceberg/issues/10855) this is a recently added check. Figure out whether we adjust the code or suppress for good
'-Xep:ImmutablesReferenceEquality:WARN',
'-Xep:IntLongMath:ERROR',
// prefer method references over lambdas
'-Xep:LambdaMethodReference:ERROR',
// enforce logging conventions
'-Xep:LoggerEnclosingClass:ERROR',
// patterns that are allowed
'-Xep:MissingCasesInEnumSwitch:OFF',
// Enforce missing override
'-Xep:MissingOverride:ERROR',
'-Xep:MissingSummary:ERROR',
// Enforce hashCode over hash
'-Xep:ObjectsHashCodeUnnecessaryVarargs:ERROR',
// Triggers false-positives whenever relocated @VisibleForTesting is used
'-Xep:PreferCommonAnnotations:OFF',
// specific to Palantir
'-Xep:PreferSafeLoggableExceptions:OFF',
'-Xep:PreferSafeLogger:OFF',
// specific to Palantir
'-Xep:PreferSafeLoggingPreconditions:OFF',
'-Xep:PreferStaticLoggers:ERROR',
// specific to Palantir
'-Xep:RawTypes:OFF',
// specific to Palantir
'-Xep:Slf4jLogsafeArgs:OFF',
'-Xep:Slf4jThrowable:ERROR',
// Added because it errors out compile, but we need to figure out if we want it
'-Xep:StrictUnusedVariable:OFF',
// Enforce safe string splitting
'-Xep:StringSplitter:ERROR',
'-Xep:TypeParameterShadowing:OFF',
'-Xep:TypeParameterUnusedInFormals:OFF',
// Palantir's UnnecessarilyQualified may throw during analysis
'-Xep:UnnecessarilyQualified:OFF',
)
}
}
pluginManager.withPlugin('com.github.alisiikh.scalastyle') {
scalastyle {
config = file("${rootDir}/project/scalastyle_config.xml")
inputEncoding = 'UTF-8'
outputEncoding = 'UTF-8'
failOnWarning = false
verbose = false
quiet = false
}
}
}