121 lines
3.9 KiB
Text
121 lines
3.9 KiB
Text
|
plugins {
|
||
|
java
|
||
|
id("org.springframework.boot") version "3.3.6"
|
||
|
id("io.spring.dependency-management") version "1.1.6"
|
||
|
id("org.openapi.generator") version "7.10.0"
|
||
|
idea
|
||
|
jacoco
|
||
|
}
|
||
|
|
||
|
group = "org.springframework.samples"
|
||
|
|
||
|
java {
|
||
|
toolchain {
|
||
|
languageVersion = JavaLanguageVersion.of(21)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
repositories {
|
||
|
mavenCentral()
|
||
|
}
|
||
|
|
||
|
dependencies {
|
||
|
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||
|
implementation("org.springframework.boot:spring-boot-starter-cache")
|
||
|
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
||
|
implementation("org.springframework.boot:spring-boot-starter-jdbc")
|
||
|
implementation("org.springframework.boot:spring-boot-starter-security")
|
||
|
implementation("org.springframework.boot:spring-boot-starter-validation")
|
||
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
||
|
implementation("org.springframework.data:spring-data-jdbc-core:1.2.1.RELEASE")
|
||
|
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0")
|
||
|
implementation("org.mapstruct:mapstruct:${project.property("mapstructVersion")}")
|
||
|
// implementation("org.openapitools:jackson-databind-nullable:0.2.6")
|
||
|
annotationProcessor("org.mapstruct:mapstruct-processor:${project.property("mapstructVersion")}")
|
||
|
runtimeOnly("org.hsqldb:hsqldb")
|
||
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||
|
testImplementation("org.springframework.security:spring-security-test")
|
||
|
testImplementation("com.jayway.jsonpath:json-path")
|
||
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||
|
}
|
||
|
|
||
|
openApiGenerate {
|
||
|
inputSpec.set("${projectDir}/src/main/resources/openapi.yml")
|
||
|
generatorName.set("spring")
|
||
|
library.set("spring-boot")
|
||
|
modelNameSuffix.set("Dto")
|
||
|
apiPackage.set("org.springframework.samples.petclinic.rest.api")
|
||
|
modelPackage.set("org.springframework.samples.petclinic.rest.dto")
|
||
|
supportingFilesConstrainedTo.set(listOf("ApiUtil.java"))
|
||
|
globalProperties.set(
|
||
|
mapOf(
|
||
|
"apis" to "",
|
||
|
"models" to ""
|
||
|
)
|
||
|
)
|
||
|
configOptions.set(
|
||
|
mutableMapOf(
|
||
|
"verbose" to "true",
|
||
|
"interfaceOnly" to "true",
|
||
|
"performBeanValidation" to "true",
|
||
|
"dateLibrary" to "java8",
|
||
|
"useSpringBoot3" to "true",
|
||
|
"openApiNullable" to "false",
|
||
|
"serializationLibrary" to "jackson",
|
||
|
"documentationProvider" to "springdoc",
|
||
|
)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
tasks.jacocoTestReport {
|
||
|
dependsOn(tasks.test) // tests are required to run before generating the report
|
||
|
classDirectories.setFrom(
|
||
|
files(classDirectories.files.map {
|
||
|
fileTree(it) {
|
||
|
exclude(
|
||
|
"**/org/springframework/samples/petclinic/rest/dto/**",
|
||
|
"**/org/springframework/samples/petclinic/rest/api/**"
|
||
|
)
|
||
|
}
|
||
|
})
|
||
|
)
|
||
|
}
|
||
|
|
||
|
tasks.jacocoTestCoverageVerification {
|
||
|
violationRules {
|
||
|
rule {
|
||
|
element = "BUNDLE"
|
||
|
limit {
|
||
|
counter = "LINE"
|
||
|
value = "COVEREDRATIO"
|
||
|
minimum = "0.85".toBigDecimal()
|
||
|
}
|
||
|
limit {
|
||
|
counter = "BRANCH"
|
||
|
value = "COVEREDRATIO"
|
||
|
minimum = "0.66".toBigDecimal()
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
tasks.withType<Test> {
|
||
|
useJUnitPlatform()
|
||
|
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
|
||
|
configure<JacocoTaskExtension> {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
java.sourceSets["main"].java {
|
||
|
srcDir(layout.buildDirectory.dir("generate-resources/main/src/main/java"))
|
||
|
}
|
||
|
|
||
|
tasks.withType<JavaCompile> {
|
||
|
dependsOn(tasks.openApiGenerate)
|
||
|
options.compilerArgs = listOf(
|
||
|
"-Amapstruct.suppressGeneratorTimestamp=true",
|
||
|
"-Amapstruct.suppressGeneratorVersionInfoComment=true",
|
||
|
"-Amapstruct.defaultComponentModel=spring"
|
||
|
)
|
||
|
}
|