-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
187 lines (161 loc) · 5.69 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "it.pagopa.qi"
version = "1.1.1"
description = "pagopa-qi-fdr-kpi-service"
plugins {
kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.25"
id("org.springframework.boot") version "3.3.6"
id("io.spring.dependency-management") version "1.1.6"
id("com.diffplug.spotless") version "6.18.0"
id("org.sonarqube") version "4.0.0.2929"
id("com.dipien.semantic-version") version "2.0.0" apply false
id("org.openapi.generator") version "6.6.0"
jacoco
application // configures the JAR manifest, handles classpath dependencies etc.
}
repositories {
mavenCentral()
mavenLocal()
}
object Dependencies {
const val ecsLoggingVersion = "1.5.0"
}
java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }
configurations { compileOnly { extendsFrom(configurations.annotationProcessor.get()) } }
configurations {
implementation.configure {
exclude(module = "spring-boot-starter-webflux")
exclude("org.apache.tomcat")
exclude(group = "org.slf4j", module = "slf4j-simple")
}
compileOnly { extendsFrom(configurations.annotationProcessor.get()) }
}
kotlin { compilerOptions { freeCompilerArgs.addAll("-Xjsr305=strict") } }
springBoot {
mainClass.set("it.pagopa.qi.fdrkpi.PagopaQiFdrKpiServiceApplicationKt")
buildInfo {
properties {
additional.set(mapOf("description" to (project.description ?: "Default description")))
}
}
}
tasks.named<Jar>("jar") { enabled = false }
tasks.create("applySemanticVersionPlugin") {
group = "semantic-versioning"
description = "Semantic versioning plugin"
dependsOn("prepareKotlinBuildScriptModel")
apply(plugin = "com.dipien.semantic-version")
}
dependencyLocking { lockAllConfigurations() }
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("jakarta.validation:jakarta.validation-api")
implementation("jakarta.annotation:jakarta.annotation-api")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-validation")
// Kotlin dependencies
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("co.elastic.logging:logback-ecs-encoder:${Dependencies.ecsLoggingVersion}")
implementation("com.microsoft.azure.kusto:kusto-data:6.0.0")
implementation("org.openapitools:jackson-databind-nullable:0.2.6")
implementation("io.swagger.core.v3:swagger-annotations:2.2.8")
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
toggleOffOn()
targetExclude("build/**/*")
ktfmt().kotlinlangStyle()
}
kotlinGradle {
toggleOffOn()
targetExclude("build/**/*.kts")
ktfmt().googleStyle()
}
java {
target("**/*.java")
targetExclude("build/**/*")
eclipse().configFile("eclipse-style.xml")
toggleOffOn()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
}
sourceSets {
main {
java { srcDirs(layout.buildDirectory.dir("generated/src/main/java")) }
kotlin { srcDirs("src/main/kotlin", layout.buildDirectory.dir("generated/src/main/kotlin")) }
resources { srcDirs("src/resources") }
}
}
tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("fdrkpi-v1") {
description =
"Generates API interfaces and DTOs from OpenAPI specification for the FDR KPI service"
group = "openapi tools"
generatorName.set("spring")
inputSpec.set("$rootDir/api-spec/v1/openapi.yaml")
outputDir.set(
layout.buildDirectory.dir("generated").get().asFile.absolutePath
) // buildDir is deprecated
apiPackage.set("it.pagopa.generated.qi.fdrkpi.v1.api")
modelPackage.set("it.pagopa.generated.qi.fdrkpi.v1.model")
generateApiTests.set(false)
generateApiDocumentation.set(false)
generateApiTests.set(false)
generateModelTests.set(false)
library.set("spring-boot")
modelNameSuffix.set("Dto")
configOptions.set(
mapOf(
"swaggerAnnotations" to "false",
"openApiNullable" to "true",
"interfaceOnly" to "true",
"hideGenerationTimestamp" to "true",
"skipDefaultInterface" to "true",
"useSwaggerUI" to "false",
"useSpringBoot3" to "true",
"useJakartaEe" to "true",
"oas3" to "true",
"generateSupportingFiles" to "true",
"enumPropertyNaming" to "UPPERCASE"
)
)
}
tasks.withType<Test> { useJUnitPlatform() }
tasks.withType<KotlinCompile> {
dependsOn("fdrkpi-v1")
kotlinOptions.jvmTarget = "21"
}
tasks.named("build") { dependsOn("spotlessApply") }
tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
jvmArgs(listOf("--enable-preview"))
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
classDirectories.setFrom(
files(
classDirectories.files.map {
fileTree(it).matching {
exclude("it/pagopa/qi/fdrkpi/PagopaQiFdrKpiServiceApplicationKt.class")
}
}
)
)
reports { xml.required.set(true) }
}
/**
* Task used to expand application properties with build specific properties such as artifact name
* and version
*/
tasks.processResources { filesMatching("application.properties") { expand(project.properties) } }