-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle
334 lines (279 loc) · 10.9 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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
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}")
classpath("com.google.protobuf:protobuf-gradle-plugin:${protobufGradleVersion}")
// some example projects use jmolecules which allows syntactic sugar via bytebuddy
// bytebuddy plugin is disabled by default and must be manually enabled via
// 1) `apply plugin: 'net.bytebuddy.byte-buddy-gradle-plugin'`
// 2) specify bytebuddy plugin `byteBuddy { transformation { plugin = JMoleculesPlugin.class } }`
// by submodules.
classpath platform("org.jmolecules:jmolecules-bom:${jmoleculesBomVersion}")
classpath 'org.jmolecules.integrations:jmolecules-bytebuddy'
}
}
plugins {
id 'idea'
id 'nebula.release' version '15.3.1'
id 'nebula.lint' version '16.17.0'
id 'nebula.project' version '7.0.9'
id 'nebula.info' version '9.3.0'
id 'com.github.spotbugs' version '4.7.1' apply false
id 'net.bytebuddy.byte-buddy-gradle-plugin' version "$bytebuddyPluginVersion" apply false
id 'org.springframework.boot' version "$springBootGradlePluginVersion" apply false
id 'io.franzbecker.gradle-lombok' version '4.0.0' apply false
}
contacts {
'theborakompanioni+github@gmail.com' {
moniker 'theborakompanioni'
github 'theborakompanioni'
}
}
def testcontainersRyukDisabled = System.getenv("TESTCONTAINERS_RYUK_DISABLED") ?: "true"
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
rules = [
// just warn because it has some false positives e.g. when excluding slf4j-log4j12 for moquette
'unused-exclude-by-dep'
]
criticalRules = [
'dependency-parantheses',
'overridden-dependency-version',
'unused-exclude-by-conf',
'duplicate-dependency-class',
'dependency-tuple-expression'
]
}
}
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: 'nebula.project'
apply plugin: 'nebula.info'
apply plugin: 'nebula.integtest-standalone'
apply plugin: 'io.franzbecker.gradle-lombok'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
repositories {
mavenCentral()
maven {
// needed for netlayer, consensusj and moquette packages
url "https://jitpack.io"
}
}
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 {
exclude('*-local.yml')
exclude('**/mainnet/**')
exclude('**/*.proto')
includeEmptyDirs false
}
task sourcesJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.java
}
task testJar(type: Jar) {
archiveClassifier.set('test')
from sourceSets.test.output
}
pluginManager.withPlugin('org.springframework.boot') {
dependencies {
developmentOnly 'org.springframework.boot:spring-boot-devtools'
}
jar {
enabled = true
}
bootJar {
archiveClassifier.set('boot')
}
bootRun {
environment "TESTCONTAINERS_RYUK_DISABLED", testcontainersRyukDisabled
}
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 "TESTCONTAINERS_RYUK_DISABLED", testcontainersRyukDisabled
finalizedBy jacocoTestReport // report is always generated after tests run
useJUnitPlatform()
}
integrationTest {
environment "TESTCONTAINERS_RYUK_DISABLED", testcontainersRyukDisabled
useJUnitPlatform()
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.enabled = true
html.enabled = true
csv.enabled = 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 = 'medium' // TODO: set to 'low' to also find 'low confidence issues'
ignoreFailures = false
excludeFilter = rootProject.file('./spotbugs-exclude.xml')
reportsDir = rootProject.file("$rootProject.buildDir/reports/spotbugs/$project.name")
}
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
onlyIf { gradle.taskGraph.hasTask('build') }
reports {
html.enabled = true
xml.enabled = false
}
}
checkstyle {
toolVersion = "${checkstyleVersion}"
configFile = rootProject.file('./checkstyle.xml')
maxErrors = 0
ignoreFailures = false
reportsDir = rootProject.file("$rootProject.buildDir/reports/checkstyle/$project.name")
}
tasks.withType(Checkstyle) {
onlyIf { gradle.taskGraph.hasTask('build') }
reports {
xml.enabled = false
html.enabled = 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', 'Build-Date', 'Built-OS', 'Built-By', 'Build-Java-Version']
}
}
// disable test tasks in check phase for all 'spring-testcontainer-*' subprojects.
// these subprojects tests are very expensive as they all start a lot of docker containers.
// you can invoke them manually via `./gradlew check -PtestcontainerTest`
configure(subprojects.findAll { project -> project.name.indexOf('spring-testcontainer-') == 0 }) {
test.onlyIf { project.hasProperty('testcontainerTest') }
integrationTest.onlyIf { project.hasProperty('testcontainerTest') }
}
// disable test tasks in check phase for all '*-example-application' subprojects.
// you can invoke them manually via `./gradlew check -PexampleTest`
configure(subprojects.findAll { project -> project.name.indexOf('-example-application') > 0 }) {
test.onlyIf { project.hasProperty('exampleTest') }
integrationTest.onlyIf { project.hasProperty('exampleTest') }
}
configure(subprojects.findAll { project -> project.subprojects.isEmpty() &&
(project.name.startsWith('bitcoin-fee'))
}) {
apply from: "${project.rootDir}/proto.gradle"
}
// enable publishing for all subproject except for "example applications"
configure(subprojects.findAll { project -> project.subprojects.isEmpty() &&
!project.pluginManager.hasPlugin('org.springframework.boot') &&
project.name.indexOf('-example-application') < 0 }) {
apply from: "${project.rootDir}/publish.gradle"
}