forked from emeraldpay/dshackle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
290 lines (252 loc) · 8.36 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
import io.gitlab.arturbosch.detekt.Detekt
import java.time.Instant
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
plugins {
id 'java'
id 'groovy'
id 'idea'
id 'application'
id 'jacoco'
alias(libs.plugins.kotlin)
alias(libs.plugins.jib)
alias(libs.plugins.spring)
alias(libs.plugins.git)
alias(libs.plugins.protobuf)
alias(libs.plugins.ktlint)
alias(libs.plugins.detekt)
}
group = 'io.emeraldpay.dshackle'
// Version schema:
// x.x.x for production, following SemVer model
// x.x.x-SNAPSHOT for development
version = '0.12.0-SNAPSHOT'
java {
sourceCompatibility = JavaVersion.VERSION_13
targetCompatibility = JavaVersion.VERSION_13
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://maven.emrld.io" }
}
configurations {
compile.exclude group: "commons-logging"
compile.exclude group: "ch.qos.logback"
compile.exclude group: "org.slf4j", module: "slf4j-jdk14"
compile.exclude group: "org.slf4j", module: "log4j-over-slf4j"
// should be used only for generation of the stubs, the lib contains grpc classes
compile.exclude group: "com.salesforce.servicelibs", module: "reactor-grpc"
}
dependencies {
implementation libs.bundles.kotlin
implementation libs.bundles.grpc
implementation libs.bundles.netty
implementation(libs.bundles.spring.framework) {
exclude module: 'spring-boot-starter-logging'
}
implementation libs.bundles.reactor
implementation(libs.reactor.grpc.stub)
implementation libs.micrometer.registry.prometheus
implementation libs.lettuce.core
implementation libs.bundles.etherjar
implementation(libs.emerald.api) {
exclude group: 'com.salesforce.servicelibs', module: 'reactor-grpc'
}
implementation libs.bitcoinj
implementation libs.snake.yaml
implementation libs.bundles.httpcomponents
implementation libs.bundles.jackson
implementation libs.bundles.apache.commons
implementation libs.bouncycastle
implementation libs.caffeine
implementation libs.javax.annotations
implementation libs.bundles.slf4j
testImplementation libs.cglib.nodep
testImplementation libs.spockframework.core
testImplementation libs.grpc.testing
testImplementation libs.reactor.test
testImplementation libs.objgenesis
testImplementation libs.mockserver.netty
testImplementation libs.java.websocket
testImplementation libs.equals.verifier
testImplementation libs.groovy
detektPlugins libs.detekt.formatting
}
compileKotlin {
kotlinOptions {
jvmTarget = "13"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "13"
}
}
test {
jvmArgs '-ea'
testLogging.showStandardStreams = false
testLogging.exceptionFormat = 'full'
finalizedBy jacocoTestReport
useJUnitPlatform()
// getting on CI:
// java.security.KeyStoreException: Key protection algorithm not found: java.security.UnrecoverableKeyException: Encrypt Private Key failed: unrecognized algorithm name: PBEWithSHA1AndDESede
// at java.base/sun.security.pkcs12.PKCS12KeyStore.setKeyEntry(PKCS12KeyStore.java:700)
// at java.base/sun.security.pkcs12.PKCS12KeyStore.engineSetKeyEntry(PKCS12KeyStore.java:597)
// at java.base/sun.security.util.KeyStoreDelegator.engineSetKeyEntry(KeyStoreDelegator.java:111)
// at java.base/java.security.KeyStore.setKeyEntry(KeyStore.java:1167)
// at io.netty.handler.ssl.SslContext.buildKeyStore(SslContext.java:1102)
// at io.netty.handler.ssl.ReferenceCountedOpenSslServerContext.newSessionContext(ReferenceCountedOpenSslServerContext.java:123)
// ----
// see
// https://github.com/bcgit/bc-java/issues/941
// https://bugs.openjdk.java.net/browse/JDK-8266279
//
systemProperty "keystore.pkcs12.keyProtectionAlgorithm", "PBEWithHmacSHA256AndAES_256"
}
application {
getMainClass().set('io.emeraldpay.dshackle.StarterKt')
}
jib {
from {
image = 'openjdk:13'
}
to {
// by default publish as:
// dshackle:shapshot,
// dshackle:t<yyyyMMddHHmm>,
// dshackle:<versionFull> and
// dshackle:<versionMajor.versionMinor>
// dshackle:latest only when publishing first version with zero patch (ex. 1.2.0)
image = [
project.hasProperty('docker') ? project.property('docker') : 'emeraldpay',
'/dshackle:',
'snapshot'
].join('')
tags = [project.version].with(true) {
add "t" + DateTimeFormatter.ofPattern("yyyyMMddHHmm").withZone(ZoneId.of('UTC')).format(Instant.now())
add project.version.toString().replaceAll('(\\d+\\.\\d+).+', '$1')
}
auth {
username = 'splix'
password = System.getenv('DOCKER_KEY')
}
}
container {
jvmFlags = ['-Xms1024m']
mainClass = 'io.emeraldpay.dshackle.StarterKt'
args = []
ports = ['2448', '2449', '8545']
}
}
jar {
enabled = true
}
afterEvaluate {
distZip.dependsOn(jar)
compileKotlin.dependsOn(generateVersion)
jar.dependsOn(generateVersion)
}
protobuf {
protoc {
// if $PROTOC_PATH is set then locally installed protoc is used otherwise it is downloaded remotely
path = System.getenv("PROTOC_PATH") ?: null
artifact = System.getenv("PROTOC_PATH") == null ? "com.google.protobuf:protoc:${libs.versions.protoc.get()}" : null
}
plugins {
}
generateProtoTasks {
}
}
sourceSets {
main {
resources.srcDirs += project.buildDir.absolutePath + "/generated/version"
}
}
task generateVersion() {
group = 'Build'
description = 'Generate project version'
doLast {
def version = versionDetails()
def resourcesDir = new File(project.buildDir.absolutePath + "/generated/version")
resourcesDir.mkdirs()
new File(resourcesDir, "version.properties").text = [
"# AUTOMATICALLY GENERATED",
"version.app=$project.version",
"version.commit=${version.gitHash}",
"version.tag=${version.lastTag}",
"version.date=${DateTimeFormatter.ISO_LOCAL_DATE_TIME.withZone(ZoneId.of('UTC')).format(Instant.now().truncatedTo(ChronoUnit.SECONDS))} UTC"
].join("\n")
}
}
// Show the list of failed tests and output only for them, helpful for CI
ext.failedTests = []
tasks.withType(Test) {
def stdout = new LinkedList<String>()
beforeTest { TestDescriptor td ->
stdout.clear()
}
onOutput { TestDescriptor td, TestOutputEvent toe ->
stdout.addAll(toe.getMessage().split('(?m)$'))
while (stdout.size() > 100) {
stdout.remove()
}
}
afterTest { TestDescriptor descriptor, TestResult result ->
if (result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE) {
failedTests << "${descriptor.className} > ${descriptor.name}"
if (!stdout.isEmpty()) {
println("-------- ${descriptor.className} > ${descriptor.name} OUTPUT ".padRight(120, "-"))
stdout.each { print(it) }
println("================".padRight(120, "="))
}
}
}
}
gradle.buildFinished {
if (!failedTests.empty) {
println "Failed tests for ${project.name}:"
failedTests.each { failedTest ->
println failedTest
}
println ""
}
}
jacocoTestReport {
dependsOn test
reports {
xml.required.set true
html.required.set true
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: 'io/emeraldpay/dshackle/proto/**')
}))
}
}
jacoco {
toolVersion = "0.8.7"
}
detekt {
toolVersion = "1.18.1"
parallel = false
basePath = projectDir
debug = false
ignoreFailures = true
reports {
xml {
enabled = true
destination = file("build/reports/detekt/detekt.xml")
}
html {
enabled = true
destination = file("build/reports/detekt/detekt.html")
}
}
}
tasks.withType(Detekt).configureEach {
jvmTarget = "13"
}