-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
341 lines (298 loc) · 11.3 KB
/
build.gradle.kts
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
333
334
335
336
337
338
339
340
341
import io.gitlab.arturbosch.detekt.Detekt
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val detektVersion: String by project
val kotlinVersion: String by project
val kotlinCoroutinesVersion: String by project
val reactorVersion: String by project
val jacocoToolVersion: String by project
val logbackVersion: String by project
val javaxAnnotationApiVersion: String by project
val caffeineCacheVersion: String by project
val slf4jVersion: String by project
val bouncycastleVersion: String by project
val ioGrpcVersion: String by project
val ioGrpcKotlinVersion: String by project
val protobufVersion: String by project
val reactorBomVersion: String by project
val junitVersion: String by project
val hamcrestVersion: String by project
val mockkVersion: String by project
val wireMockVersion: String by project
val kotestVersion: String by project
val ktorVersion: String by project
val weMavenUser: String? by project
val weMavenPassword: String? by project
val sonaTypeMavenUser: String? by project
val sonaTypeMavenPassword: String? by project
val weMavenBasePath = "https://artifacts.wavesenterprise.com/repository/"
val sonaTypeBasePath = "https://s01.oss.sonatype.org"
val gitHubProject: String by project
val githubUrl: String by project
val feignVersion: String by project
val jacksonVersion: String by project
plugins {
kotlin("jvm") apply false
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin")
id("io.spring.dependency-management") apply false
id("io.gitlab.arturbosch.detekt")
id("com.palantir.git-version") apply false
id("com.gorylenko.gradle-git-properties") apply false
id("fr.brouillard.oss.gradle.jgitver")
id("org.jetbrains.dokka")
id("jacoco")
}
if (sonaTypeMavenUser != null && sonaTypeMavenUser != null) {
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("$sonaTypeBasePath/service/local/"))
snapshotRepositoryUrl.set(uri("$sonaTypeBasePath/content/repositories/snapshots/"))
username.set(sonaTypeMavenUser)
password.set(sonaTypeMavenPassword)
}
}
}
}
jgitver {
strategy = fr.brouillard.oss.jgitver.Strategies.PATTERN
versionPattern =
"\${M}.\${m}.\${meta.COMMIT_DISTANCE}-\${meta.GIT_SHA1_8}\${-~meta.QUALIFIED_BRANCH_NAME}-SNAPSHOT"
nonQualifierBranches = "master,dev,main"
}
allprojects {
group = "com.wavesenterprise"
version = "-" // set by jgitver
repositories {
mavenCentral()
maven {
name = "maven-snapshots"
url = uri("https://artifacts.wavesenterprise.com/repository/maven-snapshots/")
mavenContent {
snapshotsOnly()
}
credentials {
username = weMavenUser
password = weMavenPassword
}
}
maven {
name = "maven-releases"
url = uri("https://artifacts.wavesenterprise.com/repository/maven-releases/")
mavenContent {
releasesOnly()
}
credentials {
username = weMavenUser
password = weMavenPassword
}
}
mavenLocal()
}
}
subprojects {
apply(plugin = "maven-publish")
publishing {
repositories {
if (weMavenUser != null && weMavenPassword != null) {
maven {
name = "WE-artifacts"
afterEvaluate {
url = uri(
"$weMavenBasePath${
if (project.version.toString()
.endsWith("-SNAPSHOT")
) "maven-snapshots" else "maven-releases"
}"
)
}
credentials {
username = weMavenUser
password = weMavenPassword
}
}
}
if (sonaTypeMavenPassword != null && sonaTypeMavenUser != null) {
maven {
name = "SonaType-maven-central-staging"
val releasesUrl = uri("$sonaTypeBasePath/service/local/staging/deploy/maven2/")
afterEvaluate {
url = if (version.toString()
.endsWith("SNAPSHOT")
) throw kotlin.Exception("shouldn't publish snapshot") else releasesUrl
}
credentials {
username = sonaTypeMavenUser
password = sonaTypeMavenPassword
}
}
}
}
}
}
configure(
subprojects.filter { it.name != "we-node-client-bom" }
) {
apply(plugin = "io.spring.dependency-management")
apply(plugin = "kotlin")
apply(plugin = "signing")
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "jacoco")
apply(plugin = "org.jetbrains.dokka")
dependencies {
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
}
val jacocoCoverageFile = layout.buildDirectory.dir("jacocoReports/test/jacocoTestReport.xml").get().asFile
tasks.withType<JacocoReport> {
reports {
xml.apply {
required.set(true)
outputLocation.set(jacocoCoverageFile)
}
}
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events = setOf(
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED
)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
finalizedBy("jacocoTestReport")
}
val detektConfigFilePath = "$rootDir/gradle/detekt-config.yml"
tasks.withType<Detekt> {
exclude("resources/")
exclude("build/")
config.setFrom(detektConfigFilePath)
buildUponDefaultConfig = true
}
tasks.register<Detekt>("detektFormat") {
description = "Runs detekt with auto-correct to format the code."
group = "formatting"
autoCorrect = true
exclude("resources/")
exclude("build/")
config.setFrom(detektConfigFilePath)
setSource(files("src/main/java", "src/main/kotlin"))
}
val sourcesJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles sources JAR"
archiveClassifier.set("sources")
from(project.the<SourceSetContainer>()["main"].allSource)
}
val dokkaJavadoc by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)
val javadocJar by tasks.creating(Jar::class) {
dependsOn(dokkaJavadoc)
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles javadoc JAR"
archiveClassifier.set("javadoc")
from(dokkaJavadoc.outputDirectory)
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
versionMapping {
allVariants {
fromResolutionResult()
}
}
afterEvaluate {
artifact(sourcesJar)
artifact(javadocJar)
}
pom {
packaging = "jar"
name.set(project.name)
url.set(githubUrl + gitHubProject)
description.set("WE Node Client for Java/Kotlin")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("scm:$githubUrl$gitHubProject")
developerConnection.set("scm:git@github.com:$gitHubProject.git")
url.set(githubUrl + gitHubProject)
}
developers {
developer {
id.set("kt3")
name.set("Stepan Kashintsev")
email.set("kpote3@gmail.com")
}
developer {
id.set("bekirev")
name.set("Artem Bekirev")
email.set("abekirev@gmail.com")
}
developer {
id.set("donyfutura")
name.set("Daniil Georgiev")
email.set("donyfutura@gmail.com")
}
}
}
}
}
}
signing {
afterEvaluate {
if (!project.version.toString().endsWith("SNAPSHOT")) {
sign(publishing.publications["mavenJava"])
}
}
}
the<DependencyManagementExtension>().apply {
imports {
mavenBom("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion")
mavenBom("org.jetbrains.kotlinx:kotlinx-coroutines-bom:$kotlinCoroutinesVersion")
mavenBom("com.fasterxml.jackson:jackson-bom:$jacksonVersion")
mavenBom("com.google.protobuf:protobuf-bom:$protobufVersion")
mavenBom("io.grpc:grpc-bom:$ioGrpcVersion")
mavenBom("io.github.openfeign:feign-bom:$feignVersion")
mavenBom("io.ktor:ktor-bom:$ktorVersion")
mavenBom("io.projectreactor:reactor-bom:$reactorBomVersion")
mavenBom("org.junit:junit-bom:$junitVersion")
}
dependencies {
dependency("io.grpc:grpc-kotlin-stub:$ioGrpcKotlinVersion")
dependency("javax.annotation:javax.annotation-api:$javaxAnnotationApiVersion")
dependency("ch.qos.logback:logback-classic:$logbackVersion")
dependency("org.slf4j:slf4j-api:$slf4jVersion")
dependency("com.github.ben-manes.caffeine:caffeine:$caffeineCacheVersion")
dependency("org.bouncycastle:bcprov-jdk18on:$bouncycastleVersion")
dependency("org.bouncycastle:bcpkix-jdk18on:$bouncycastleVersion")
dependency("io.mockk:mockk:$mockkVersion")
dependency("org.hamcrest:hamcrest:$hamcrestVersion")
dependency("org.hamcrest:hamcrest-core:$hamcrestVersion")
dependency("org.hamcrest:hamcrest-library:$hamcrestVersion")
dependency("org.wiremock:wiremock:$wireMockVersion")
dependency("io.kotest:kotest-runner-junit5:$kotestVersion")
}
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JavaVersion.VERSION_17.toString()
}
}
jacoco {
toolVersion = jacocoToolVersion
reportsDirectory.set(layout.buildDirectory.dir("jacocoReports").get().asFile)
}
}