-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
261 lines (223 loc) · 8.76 KB
/
build.gradle.kts
File metadata and controls
261 lines (223 loc) · 8.76 KB
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
// Copyright (c) Cosmo Tech.
// Licensed under the MIT license.
import com.diffplug.gradle.spotless.SpotlessExtension
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.kotlin.dsl.implementation
plugins {
val kotlinVersion = "1.9.23"
kotlin("jvm") version kotlinVersion
id("com.diffplug.spotless") version "7.0.2"
id("org.springframework.boot") version "3.4.1" apply false
id("io.gitlab.arturbosch.detekt") version "1.23.8"
id("pl.allegro.tech.build.axion-release") version "1.18.18"
id("org.jetbrains.kotlinx.kover") version "0.7.6"
id("project-report")
`maven-publish`
// Apply the java-library plugin for API and implementation separation.
`java-library`
}
scmVersion {
ignoreUncommittedChanges.set(false)
useHighestVersion.set(true)
tag { prefix.set("") }
}
project.version = scmVersion.version
val kotlinJvmTarget = 21
java { toolchain { languageVersion.set(JavaLanguageVersion.of(kotlinJvmTarget)) } }
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/Cosmo-Tech/cosmotech-api-common")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}
publications {
create<MavenPublication>("maven") {
groupId = "com.github.Cosmo-Tech"
artifactId = "cosmotech-api-common"
version = scmVersion.version
pom {
name.set("Cosmo Tech API common")
description.set("Cosmo Tech API common library for Platform")
url.set("https://github.com/Cosmo-Tech/cosmotech-api-common")
licenses {
license {
name.set("MIT License")
url.set("https://github.com/Cosmo-Tech/cosmotech-api-common/blob/main/LICENSE")
}
}
}
from(components["java"])
}
}
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
configure<SpotlessExtension> {
isEnforceCheck = false
val licenseHeaderComment =
"""
// Copyright (c) Cosmo Tech.
// Licensed under the MIT license.
"""
.trimIndent()
java {
googleJavaFormat()
target("**/*.java")
licenseHeader(licenseHeaderComment)
}
kotlin {
ktfmt()
target("**/*.kt")
licenseHeader(licenseHeaderComment)
}
kotlinGradle {
ktfmt()
target("**/*.kts")
licenseHeader(licenseHeaderComment, "(import |// no-import)")
}
}
tasks.withType<JavaCompile>() { options.compilerArgs.add("-parameters") }
tasks.withType<Detekt>().configureEach {
buildUponDefaultConfig = true // preconfigure defaults
allRules = false // activate all available (even unstable) rules.
config.from(file("$rootDir/.detekt/detekt.yaml"))
jvmTarget = kotlinJvmTarget.toString()
ignoreFailures = project.findProperty("detekt.ignoreFailures")?.toString()?.toBoolean() ?: false
// Specify the base path for file paths in the formatted reports.
// If not set, all file paths reported will be absolute file path.
// This is so we can easily map results onto their source files in tools like GitHub Code
// Scanning
basePath = rootDir.absolutePath
reports {
html {
// observe findings in your browser with structure and code snippets
required.set(true)
outputLocation.set(
file("${layout.buildDirectory.get()}/reports/detekt/${project.name}-detekt.html"))
}
xml {
// checkstyle like format mainly for integrations like Jenkins
required.set(false)
outputLocation.set(
file("${layout.buildDirectory.get()}/reports/detekt/${project.name}-detekt.xml"))
}
txt {
// similar to the console output, contains issue signature to manually edit baseline files
required.set(true)
outputLocation.set(
file("${layout.buildDirectory.get()}/reports/detekt/${project.name}-detekt.txt"))
}
sarif {
// standardized SARIF format (https://sarifweb.azurewebsites.net/) to support integrations
// with Github Code Scanning
required.set(true)
outputLocation.set(
file("${layout.buildDirectory.get()}/reports/detekt/${project.name}-detekt.sarif"))
}
}
}
tasks.jar {
manifest {
attributes(
mapOf("Implementation-Title" to project.name, "Implementation-Version" to project.version))
}
}
tasks.test { useJUnitPlatform() }
// Dependencies version
// Required versions
val jacksonVersion = "2.18.2"
val springWebVersion = "6.2.1"
val springBootVersion = "3.4.1"
// Implementation
val swaggerParserVersion = "2.1.24"
val hashidsVersion = "1.0.3"
val springOauthAutoConfigureVersion = "2.6.8"
val springSecurityJwtVersion = "1.1.1.RELEASE"
val springDocVersion = "2.5.0"
val springOauthVersion = "6.4.2"
val servletApiVersion = "6.0.0"
val oktaSpringBootVersion = "3.0.7"
val tikaVersion = "3.1.0"
val redisOMVersion = "0.9.1"
val kotlinCoroutinesCoreVersion = "1.8.1"
// Checks
val detektVersion = "1.23.7"
// Tests
val jUnitBomVersion = "5.10.0"
val mockkVersion = "1.13.17"
val awaitilityKVersion = "4.2.2"
val testcontainersRedis = "1.6.4"
dependencies {
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
detekt("io.gitlab.arturbosch.detekt:detekt-cli:$detektVersion")
detekt("io.gitlab.arturbosch.detekt:detekt-formatting:$detektVersion")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-libraries:$detektVersion")
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.hashids:hashids:${hashidsVersion}")
implementation("io.swagger.parser.v3:swagger-parser-v3:${swaggerParserVersion}")
implementation(
"org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure:${springOauthAutoConfigureVersion}") {
constraints {
implementation("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("org.springframework:spring-web:$springWebVersion")
implementation("org.springframework.boot:spring-boot-autoconfigure:$springBootVersion")
}
}
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.security:spring-security-oauth2-jose:${springOauthVersion}")
implementation(
"org.springframework.security:spring-security-oauth2-resource-server:${springOauthVersion}")
implementation("org.springframework.security:spring-security-jwt:${springSecurityJwtVersion}")
implementation("org.springframework.boot:spring-boot-starter-web") {
exclude(group = "org.springframework.boot", module = "spring-boot-starter-tomcat")
}
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:${springDocVersion}")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.2")
implementation("jakarta.servlet:jakarta.servlet-api:${servletApiVersion}")
implementation("com.okta.spring:okta-spring-boot-starter:${oktaSpringBootVersion}")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("org.springframework.boot:spring-boot-starter-aop")
implementation("org.apache.httpcomponents.client5:httpclient5")
implementation("org.apache.tika:tika-core:${tikaVersion}")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinCoroutinesCoreVersion")
implementation("com.redis.om:redis-om-spring:${redisOMVersion}") {
constraints { implementation("ai.djl:api:0.28.0") }
}
implementation("com.redis.testcontainers:testcontainers-redis-junit:$testcontainersRedis")
implementation("org.springframework.boot:spring-boot-starter-test")
testImplementation(kotlin("test"))
testImplementation(platform("org.junit:junit-bom:${jUnitBomVersion}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("io.mockk:mockk:${mockkVersion}")
testImplementation("org.awaitility:awaitility-kotlin:${awaitilityKVersion}")
// Use the Kotlin test library.
testImplementation("org.jetbrains.kotlin:kotlin-test")
// Use the Kotlin JUnit integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
}
extensions.configure<kotlinx.kover.gradle.plugin.dsl.KoverReportExtension> {
defaults {
// reports configs for XML, HTML, verify reports
}
filters {
includes {
packages("com.cosmotech.api")
classes("com.cosmotech.api.id.*")
classes("com.cosmotech.api.rbac.*")
classes("com.cosmotech.utils.*")
}
}
}