-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle
301 lines (254 loc) · 8.73 KB
/
build.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
import io.franzbecker.gradle.lombok.task.DelombokTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.springframework.boot.gradle.plugin.SpringBootPlugin
buildscript {
apply from: 'versions.gradle'
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootGradlePluginVersion}")
}
}
plugins {
id 'idea'
id 'nebula.release' version '17.2.2'
id 'nebula.lint' version '18.1.0'
id 'com.netflix.nebula.project' version '10.1.5'
id 'com.github.spotbugs' version '5.2.1' apply false
id 'org.springframework.boot' version "$springBootGradlePluginVersion" apply false
id 'io.franzbecker.gradle-lombok' version '5.0.0' apply false
}
contacts {
moniker 'theborakompanioni'
github 'theborakompanioni'
}
}
configurations.all {
resolutionStrategy {
// check for updates in modules every build
cacheChangingModulesFor 0, 'seconds'
preferProjectModules()
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
failOnVersionConflict()
}
}
allprojects {
apply plugin: 'nebula.lint'
group = 'io.github.theborakompanioni'
gradleLint {
alwaysRun = false // do not automatically run - must be executed manually
autoLintAfterFailure = false // only run lint after a successful build
criticalRules = [
'dependency-parantheses',
'overridden-dependency-version',
'unused-exclude-by-conf',
'dependency-tuple-expression'
]
// duplicate dependency false positives from "compileOnly 'javax.servlet:javax.servlet-api'"
excludedRules = ['duplicate-dependency-class']
}
}
configure(rootProject) {
defaultTasks 'clean', 'build', 'integrationTest'
task clean {
doLast {
delete fileTree("${rootProject.projectDir}") {
include '**/*.log'
include '**/*.log.*.gz'
include '**/*.log.*.tmp'
}
}
}
}
subprojects {
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'com.github.spotbugs'
apply plugin: 'com.netflix.nebula.project'
apply plugin: 'com.netflix.nebula.info'
apply plugin: 'com.netflix.nebula.integtest-standalone'
apply plugin: 'io.franzbecker.gradle-lombok'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
repositories {
mavenCentral()
maven {
// needed for netlayer
url "https://jitpack.io"
}
mavenLocal {
mavenContent {
snapshotsOnly()
}
}
}
dependencyManagement {
imports {
mavenBom SpringBootPlugin.BOM_COORDINATES
}
}
dependencies {
compileOnly "com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}"
testCompileOnly "com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}"
spotbugsPlugins "com.h3xstream.findsecbugs:findsecbugs-plugin:${findsecbugsPluginVersion}"
implementation 'org.slf4j:slf4j-api'
implementation "com.google.guava:guava:${guavaVersion}"
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
jar {
includeEmptyDirs false
}
sourcesJar {
duplicatesStrategy DuplicatesStrategy.EXCLUDE
archiveClassifier.set('sources')
from sourceSets.main.java
}
task testJar(type: Jar) {
archiveClassifier.set('test')
from sourceSets.test.output
}
pluginManager.withPlugin('org.springframework.boot') {
dependencies {
// 2021-12-05: disable devtools for now - restarts main app twice - annoying.
// developmentOnly 'org.springframework.boot:spring-boot-devtools'
}
jar {
enabled = true
}
bootJar {
// creates a launch script for the executable jar
launchScript()
archiveClassifier.set('boot')
}
bootRun {
environment "X_GRADLE", true
}
springBoot {
buildInfo {
properties {
// overwrite "time" property to enable reproducible builds
// see https://reproducible-builds.org/docs/timestamps/
time = System.getenv('SOURCE_DATE_EPOCH') ?: null
}
}
}
}
test {
environment "X_GRADLE", true
finalizedBy jacocoTestReport // report is always generated after tests run
useJUnitPlatform()
}
integrationTest {
environment "X_GRADLE", true
useJUnitPlatform()
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.required = true
html.required = true
csv.required = false
}
}
artifacts {
archives testJar
}
lombok {
version = "${lombokVersion}"
sha256 = null // skip verifyLombok task - will be done by gradle dependency verification
}
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.STARTED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED
showExceptions true
exceptionFormat TestExceptionFormat.FULL
showCauses true
showStackTraces true
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}
task dependencyTree(type: DependencyReportTask) {}
task delombok(type: DelombokTask, dependsOn: compileJava) {
def srcDirs = sourceSets.main.java.srcDirs.findAll { it.exists() }
enabled = subprojects.isEmpty() && !srcDirs.isEmpty()
ext.outputDir = file("$buildDir/delombok")
outputs.dir(outputDir)
srcDirs.each {
inputs.dir(it)
args(it, "-d", outputDir)
}
doFirst {
outputDir.deleteDir()
}
}
javadoc {
dependsOn delombok
source = delombok.outputDir
failOnError = false
}
spotbugs {
effort = 'max'
reportLevel = 'low'
ignoreFailures = false
excludeFilter = rootProject.file('./spotbugs-exclude.xml')
reportsDir = rootProject.file("$rootProject.buildDir/reports/spotbugs/$project.name")
}
spotbugsMain {
reports {
xml.required = false
html.required = true
}
}
checkstyle {
toolVersion = "${checkstyleVersion}"
configFile = rootProject.file('./checkstyle.xml')
maxErrors = 0
ignoreFailures = false
reportsDir = rootProject.file("$rootProject.buildDir/reports/checkstyle/$project.name")
}
tasks.withType(Checkstyle) {
reports {
xml.required = false
html.required = true
}
}
tasks.withType(AbstractArchiveTask) {
// activate reproducible archives
// see https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
preserveFileTimestamps = false
reproducibleFileOrder = true
}
infoBroker {
// exclude properties that prevent reproducible builds
excludedManifestProperties = [
'Created-By',
'Built-By',
'Build-Date',
'Build-Date-UTC',
'Build-Host',
'Built-OS',
'Build-Timezone',
'Build-Url',
]
}
}