generated from yonatankarp/spring-starter
/
build.gradle.kts
137 lines (113 loc) · 4.17 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
plugins {
id("com.diffplug.spotless") version libs.versions.spotless
id("com.revolut.jooq-docker") version libs.versions.jooq.docker.plugin
id("io.spring.dependency-management") version libs.versions.spring.dependency.management
id("jacoco")
id("org.springframework.boot") version libs.versions.springboot
id("cat-fact-service.code-metrics")
id("cat-fact-service.java-conventions")
id("cat-fact-service.publishing-conventions")
kotlin("jvm") version libs.versions.kotlin
kotlin("plugin.spring") version libs.versions.kotlin
}
repositories {
mavenLocal()
mavenCentral()
maven { url = uri("https://packages.confluent.io/maven/") }
maven {
url = uri("https://maven.pkg.github.com/yonatankarp/cat-fact-service")
credentials {
username = findProperty("gpr.user")?.toString() ?: System.getenv("GITHUB_ACTOR")
password = findProperty("gpr.key")?.toString() ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
url = uri("https://maven.pkg.github.com/yonatankarp/cat-fact-client")
credentials {
username = project.findProperty("gpr.user")?.toString() ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key")?.toString() ?: System.getenv("PACKAGES_READ_TOKEN")
}
}
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(libs.versions.jvmTarget.get()))
target { JavaLanguageVersion.of(libs.versions.jvmTarget.get()) }
}
}
dependencies {
implementation("com.yonatankarp:cat-fact-client:${libs.versions.catFactClient.get()}")
// Spring Boot
implementation(libs.bundles.springboot.all)
// Kotlin
implementation(libs.bundles.kotlin.all)
// Persistence
runtimeOnly(libs.postgresql)
jdbc(libs.postgresql) // Required to generate JOOQ models
implementation(libs.bundles.persistence.support.all)
// Documentation
implementation(libs.springdoc.openapi.starter)
// Observability
implementation("io.honeycomb:honeycomb-opentelemetry-sdk:${libs.versions.honeycomb.get()}")
compileOnly("io.honeycomb:honeycomb-opentelemetry-javaagent:${libs.versions.honeycomb.get()}")
// Tests
testImplementation(libs.mockk.core)
testImplementation(libs.mockk.spring)
testImplementation(libs.testcontainers.jupiter)
testImplementation(libs.testcontainers.postgres)
}
dependencyManagement {
imports {
mavenBom("org.testcontainers:testcontainers-bom:${libs.versions.testcontainers.get()}")
}
}
tasks {
bootRun {
environment = mapOf(
"HONEYCOMB_API_KEY" to System.getenv("HONEYCOMB_API_KEY"),
"SERVICE_NAME" to "cat-fact-service",
"HONEYCOMB_API_ENDPOINT" to "https://api.honeycomb.io:443",
"ENVIRONMENT" to "test",
)
jvmArgs = listOf(
"-javaagent:${layout.buildDirectory.get().asFile}/output/libs/honeycomb-opentelemetry-javaagent.jar",
"-Dotel.resource.attributes=github.repository=https://github.com/yonatankarp/cat-fact-service",
)
}
getByName<Jar>("jar") {
enabled = false
}
build {
finalizedBy(spotlessApply)
dependsOn("copyOpenTelemetryAgent")
}
withType<Test> {
useJUnitPlatform()
finalizedBy(spotlessApply)
finalizedBy(jacocoTestReport)
}
jacoco {
toolVersion = libs.versions.jacoco.get()
}
jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(true)
}
}
register<Copy>("copyOpenTelemetryAgent") {
project.delete(
fileTree("${layout.buildDirectory.get().asFile}/output/libs"),
)
from(configurations.compileClasspath)
into("${layout.buildDirectory.get().asFile}/output/libs")
include("honeycomb-opentelemetry-javaagent*")
rename("-[1-9]+.[0-9]+.[0-9]+.jar", ".jar")
}
}
val tasksDependencies = mapOf(
"spotlessKotlin" to listOf("compileKotlin", "compileTestKotlin", "test", "jacocoTestReport", "copyOpenTelemetryAgent")
)
tasksDependencies.forEach { (taskName, dependencies) ->
tasks.findByName(taskName)?.dependsOn(dependencies)
}