generated from ministryofjustice/hmpps-template-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
144 lines (125 loc) · 5.66 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask
import org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
plugins {
id("uk.gov.justice.hmpps.gradle-spring-boot") version "6.0.9"
id("org.openapi.generator") version "7.10.0"
kotlin("plugin.spring") version "2.0.21"
kotlin("plugin.jpa") version "2.0.21"
}
allOpen {
annotations(
"javax.persistence.Entity",
"javax.persistence.MappedSuperclass",
"javax.persistence.Embeddable",
)
}
configurations {
testImplementation { exclude(group = "org.junit.vintage") }
}
dependencies {
// Spring boot dependencies
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("uk.gov.justice.service.hmpps:hmpps-kotlin-spring-boot-starter:1.0.8")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("uk.gov.justice.service.hmpps:hmpps-sqs-spring-boot-starter:5.1.1")
// CSV dependencies
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.18.1")
// Database dependencies
runtimeOnly("org.flywaydb:flyway-database-postgresql")
runtimeOnly("org.postgresql:postgresql:42.7.4")
// OpenAPI
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0")
// Gov Notify client
implementation("uk.gov.service.notify:notifications-java-client:5.2.1-RELEASE")
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-annotations:2.10.0")
// Test dependencies
testImplementation("io.jsonwebtoken:jjwt-impl:0.12.6")
testImplementation("io.jsonwebtoken:jjwt-jackson:0.12.6")
testImplementation("net.javacrumbs.json-unit:json-unit:4.0.0")
testImplementation("net.javacrumbs.json-unit:json-unit-assertj:4.0.0")
testImplementation("net.javacrumbs.json-unit:json-unit-json-path:4.0.0")
testImplementation("org.awaitility:awaitility-kotlin:4.2.2")
testImplementation("org.mockito:mockito-inline:5.2.0")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.testcontainers:localstack:1.20.4")
testImplementation("org.testcontainers:postgresql:1.20.4")
testImplementation("org.wiremock:wiremock-standalone:3.9.2")
}
kotlin {
jvmToolchain(21)
}
tasks {
withType<KotlinCompile> {
dependsOn("buildLocationsInsidePrisonApiModel", "buildActivitiesAppointmentsApiModel", "buildPrisonApiModel", "buildManageUsersApiModel")
compilerOptions.jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21
}
withType<KtLintCheckTask> {
// Under gradle 8 we must declare the dependency here, even if we're not going to be linting the model
mustRunAfter("buildLocationsInsidePrisonApiModel", "buildActivitiesAppointmentsApiModel", "buildPrisonApiModel", "buildManageUsersApiModel")
}
withType<KtLintFormatTask> {
// Under gradle 8 we must declare the dependency here, even if we're not going to be linting the model
mustRunAfter("buildLocationsInsidePrisonApiModel", "buildActivitiesAppointmentsApiModel", "buildPrisonApiModel", "buildManageUsersApiModel")
}
}
val configValues = mapOf(
"dateLibrary" to "java8-localdatetime",
"serializationLibrary" to "jackson",
"enumPropertyNaming" to "original",
"useSpringBoot3" to "true",
)
val buildDirectory: Directory = layout.buildDirectory.get()
tasks.register("buildLocationsInsidePrisonApiModel", GenerateTask::class) {
generatorName.set("kotlin")
inputSpec.set("openapi-specs/locations-inside-prison-api.json")
outputDir.set("$buildDirectory/generated/locationsinsideprisonapi")
modelPackage.set("uk.gov.justice.digital.hmpps.hmppsbookavideolinkapi.client.locationsinsideprison.model")
configOptions.set(configValues)
globalProperties.set(mapOf("models" to ""))
}
tasks.register("buildActivitiesAppointmentsApiModel", GenerateTask::class) {
generatorName.set("kotlin")
inputSpec.set("openapi-specs/activities-appointments-api.json")
outputDir.set("$buildDirectory/generated/activitiesappointmentsapi")
modelPackage.set("uk.gov.justice.digital.hmpps.hmppsbookavideolinkapi.client.activitiesappointments.model")
configOptions.set(configValues)
globalProperties.set(mapOf("models" to ""))
}
tasks.register("buildPrisonApiModel", GenerateTask::class) {
generatorName.set("kotlin")
inputSpec.set("openapi-specs/prison-api.json")
outputDir.set("$buildDirectory/generated/prisonapi")
modelPackage.set("uk.gov.justice.digital.hmpps.hmppsbookavideolinkapi.client.prisonapi.model")
configOptions.set(configValues)
globalProperties.set(mapOf("models" to ""))
}
tasks.register("buildManageUsersApiModel", GenerateTask::class) {
generatorName.set("kotlin")
inputSpec.set("openapi-specs/manage-users-api.json")
outputDir.set("$buildDirectory/generated/manageusersapi")
modelPackage.set("uk.gov.justice.digital.hmpps.hmppsbookavideolinkapi.client.manageusers.model")
configOptions.set(configValues)
globalProperties.set(mapOf("models" to ""))
}
val generatedProjectDirs = listOf("locationsinsideprisonapi", "activitiesappointmentsapi", "prisonapi", "manageusersapi")
kotlin {
generatedProjectDirs.forEach { generatedProject ->
sourceSets["main"].apply {
kotlin.srcDir("$buildDirectory/generated/$generatedProject/src/main/kotlin")
}
}
}
configure<KtlintExtension> {
filter {
generatedProjectDirs.forEach { generatedProject ->
exclude { element ->
element.file.path.contains("build/generated/$generatedProject/src/main/")
}
}
}
}