-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
283 lines (235 loc) · 7.31 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
import groovy.xml.MarkupBuilder
import org.jooq.codegen.GenerationTool
import javax.xml.bind.JAXB
buildscript {
repositories {
gradlePluginPortal()
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.glassfish.jaxb:jaxb-runtime:2.3.2"
classpath "org.postgresql:postgresql:42.2.14"
classpath "io.github.jklingsporn:vertx-jooq-generate:5.2.0"
}
}
plugins {
id 'idea'
id 'com.github.johnrengelman.shadow' version '6.0.0' apply false
id "net.ltgt.errorprone" version "1.2.1" apply false
id "com.github.ben-manes.versions" version "0.29.0" apply false
id "com.google.protobuf" version "0.8.12" apply false
id "org.flywaydb.flyway" version "6.5.5"
id 'nu.studer.jooq' version '5.0.1'
id "jacoco"
}
allprojects {
apply plugin: "java"
apply plugin: "idea"
apply plugin: "net.ltgt.errorprone"
apply plugin: "com.github.ben-manes.versions"
sourceCompatibility = 14
targetCompatibility = 14
repositories {
jcenter()
}
dependencies {
implementation 'com.google.guava:guava:29.0-jre'
// https://github.com/google/error-prone
// https://errorprone.info/
errorprone "com.google.errorprone:error_prone_core:2.4.0"
compileOnly "com.google.errorprone:error_prone_annotations:2.4.0"
// https://github.com/uber/NullAway
errorprone "com.uber.nullaway:nullaway:0.7.9"
// https://github.com/eclipse-ee4j/common-annotations-api
implementation "jakarta.annotation:jakarta.annotation-api:2.0.0-RC1"
}
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
options.errorprone {
// https://github.com/uber/NullAway
warn("NullAway")
option("NullAway:AnnotatedPackages", "com.hedera.hashgraph.stablecoin")
option("NullAway:TreatGeneratedAsUnannotated", "true")
// Enable _all_ error prone checks then selectively disble
// Checks that are default-disabled are enabled as warnings
allDisabledChecksAsWarnings = true
disable("Java7ApiChecker")
disable("AndroidJdkLibsChecker")
disable("FieldMissingNullable")
disable("CatchAndPrintStackTrace")
disable("ThrowSpecificExceptions")
// Ignore generated and protobuf code
disableWarningsInGeneratedCode = true
excludedPaths = "(.*proto.*)|(.*generated.*)|(.*db.*)"
}
}
jacoco {
reportsDir = file("$buildDir/jacoco")
toolVersion = "0.8.5"
}
}
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'com.google.protobuf'
group = "com.hedera.hashgraph.stablecoin.app"
version = "0.2.0"
description = "Hedera™ Hashgraph Stable Coin"
dependencies {
implementation 'com.hedera.hashgraph:sdk:1.1.4'
implementation 'io.github.cdimascio:java-dotenv:5.2.1'
implementation 'io.grpc:grpc-netty-shaded:1.30.2'
implementation "io.vertx:vertx-web:3.9.2"
implementation "io.vertx:vertx-pg-client:3.9.2"
implementation project(":proto")
implementation project(":sdk")
// flyway
compile "org.flywaydb:flyway-core:7.11.2"
// jOOQ
implementation 'org.jooq:jooq:3.13.4'
implementation 'org.jooq:jooq-meta:3.13.4'
implementation 'org.postgresql:postgresql:42.2.14'
// jOOQ database driver
jooqGenerator 'org.postgresql:postgresql:42.2.14'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
}
protobuf {
generatedFilesBaseDir = "$projectDir/src"
protoc {
artifact = "com.google.protobuf:protoc:3.12.4"
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
}
}
}
flyway {
def dbURL = System.getenv("HSC_DATABASE_URL") ?: "postgresql://localhost:5432/"
def dbSCHEMA = System.getenv("HSC_POSTGRES_DB") ?: "stable_coin"
def dbUSER = System.getenv("HSC_DATABASE_USERNAME")
def dbPASS = System.getenv("HSC_DATABASE_PASSWORD")
url = "jdbc:${dbURL}${dbSCHEMA}"
user = "${dbUSER}"
password = "${dbPASS}"
locations = ['filesystem:src/main/resources/migrations']
}
task jooqGenerate {
doLast() {
def writer = new StringWriter()
def dbURL = System.getenv("HSC_DATABASE_URL") ?: "postgresql://localhost:5432/"
def dbSCHEMA = System.getenv("HSC_POSTGRES_DB") ?: "stable_coin"
def dbUSER = System.getenv("HSC_DATABASE_USERNAME")
def dbPASS = System.getenv("HSC_DATABASE_PASSWORD")
new MarkupBuilder(writer)
.configuration('xmlns': 'http://www.jooq.org/xsd/jooq-codegen-3.13.0.xsd') {
jdbc {
driver('org.postgresql.Driver')
url("jdbc:${dbURL}${dbSCHEMA}")
user("${dbUSER}")
password("${dbPASS}")
}
generator {
name('io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveVertxGenerator')
database {
name('org.jooq.meta.postgres.PostgresDatabase')
inputSchema('public')
}
generate([:]) {
deprecated(false)
records(false)
interfaces(false)
fluentSetters(false)
pojos(false)
daos(false)
}
target() {
packageName('com.hedera.hashgraph.stablecoin.app.db')
directory("$projectDir/src/main/java")
}
strategy {
name('io.github.jklingsporn.vertx.jooq.generate.VertxGeneratorStrategy')
}
}
}
GenerationTool.generate(
JAXB.unmarshal(new StringReader(writer.toString()), org.jooq.meta.jaxb.Configuration.class)
)
}
}
application {
mainClassName = 'com.hedera.hashgraph.stablecoin.app.App'
}
jar {
enabled = false
manifest {
attributes 'Main-Class': 'com.hedera.hashgraph.stablecoin.app.App'
}
}
tasks.shadowJar.configure {
classifier = null
}
tasks.withType(Test) {
apply plugin: "jacoco"
useJUnitPlatform()
// this task will fail on the first failed test
failFast = true
// emit logs per passed or failed test
testLogging {
exceptionFormat = 'full'
events "passed", "skipped", "failed", "standardOut", "standardError"
}
// run coverage after the test
finalizedBy jacocoTestReport
}
task printJacoco {
doLast {
def csvFile = file("${buildDir}/reports/jacoco/report.csv")
InputStream inputFile = new FileInputStream(csvFile)
String[] lines = inputFile.text.split('\n')
List<String[]> rows = lines.collect { it.split(',') }
printf("\nCode Coverage:\n\n")
for (row in rows) {
if (row.contains("com.hedera.hashgraph.stablecoin.app.handler") ||
row.contains("com.hedera.hashgraph.stablecoin.app.handler.arguments") ||
row.contains("State") ||
row.contains("TopicListener")
) {
printf(row[2] + ": Instructions: " + (row[4].toInteger() / (row[3].toInteger() + row[4].toInteger())) * 100 + "%%, Branches: ")
if (row[5].toInteger() + row[6].toInteger() == 0) {
printf("100%%")
} else {
printf((row[6].toInteger() / (row[5].toInteger() + row[6].toInteger()) * 100).toString() + "%%")
}
printf("\n")
}
}
}
}
jacocoTestReport {
// make sure to use any/all test coverage data for the report
executionData fileTree(dir: buildDir, include: "jacoco/*.exec")
// remove generated files from report
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: ['**/proto/**', '**/db/**'])
}))
}
// configure it so only xml is generated for the report
reports {
xml.enabled true
xml.destination file("$buildDir/reports/jacoco/report.xml")
html.enabled true
html.destination file("${buildDir}/reports/jacocoHtml")
csv.enabled true
csv.destination file("${buildDir}/reports/jacoco/report.csv")
}
// make sure we run all tests before this report is made
dependsOn tasks.withType(Test)
finalizedBy printJacoco
}