152 lines
4.6 KiB
Text
152 lines
4.6 KiB
Text
import com.github.spotbugs.snom.Confidence
|
|
import com.github.spotbugs.snom.Effort
|
|
import com.github.spotbugs.snom.SpotBugsTask
|
|
import org.hidetake.gradle.swagger.generator.GenerateSwaggerCode
|
|
import org.openapitools.codegen.languages.JavaClientCodegen
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
plugins {
|
|
java
|
|
checkstyle
|
|
id("com.github.spotbugs") version "6.0.23"
|
|
id("org.springframework.boot") version "3.3.3"
|
|
id("io.spring.dependency-management") version "1.1.6"
|
|
id("org.hidetake.swagger.generator") version "2.19.2"
|
|
id("org.openapi.generator") version "7.8.0"
|
|
}
|
|
|
|
checkstyle {
|
|
toolVersion = "10.12.4"
|
|
configDirectory = file("src/main/resources/")
|
|
configFile = file("src/main/resources/checkstyle.xml")
|
|
}
|
|
|
|
spotbugs {
|
|
toolVersion = "4.8.6"
|
|
effort.set(Effort.MAX)
|
|
reportLevel.set(Confidence.LOW)
|
|
}
|
|
|
|
group = "de.hmmh"
|
|
version = "0.0.1-SNAPSHOT"
|
|
|
|
java {
|
|
toolchain {
|
|
languageVersion = JavaLanguageVersion.of(21)
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
compileOnly {
|
|
extendsFrom(configurations.annotationProcessor.get())
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
// Spring
|
|
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
|
|
implementation("org.springframework.boot:spring-boot-starter-validation")
|
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
|
implementation("org.springframework.boot:spring-boot-starter-security")
|
|
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
|
|
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
|
|
|
|
// Postgres
|
|
runtimeOnly("org.postgresql:postgresql")
|
|
|
|
// Lombok
|
|
compileOnly("org.projectlombok:lombok")
|
|
annotationProcessor("org.projectlombok:lombok")
|
|
|
|
// Test
|
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
|
testImplementation("org.springframework.boot:spring-boot-testcontainers")
|
|
testImplementation("org.springframework.security:spring-security-test")
|
|
testImplementation("org.testcontainers:junit-jupiter")
|
|
testImplementation("org.testcontainers:postgresql")
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
|
|
//OAS
|
|
swaggerCodegen("io.swagger.codegen.v3:swagger-codegen-cli:3.0.61")
|
|
implementation("io.swagger.core.v3:swagger-annotations:2.2.22")
|
|
implementation("jakarta.xml.bind:jakarta.xml.bind-api") //Needed for XML/HTML Validation
|
|
}
|
|
|
|
swaggerSources {
|
|
register("pmt") {
|
|
setInputFile(file("${rootDir}/src/main/resources/api.yml"))
|
|
code.configFile = file("${rootDir}/src/main/resources/gen-config.json")
|
|
val validationTask = validation
|
|
code(delegateClosureOf<GenerateSwaggerCode> {
|
|
language = "spring"
|
|
code.rawOptions =
|
|
listOf("--ignore-file-override=" + file("${rootDir}/src/main/resources/.codegen-ignore").absolutePath)
|
|
dependsOn(validationTask)
|
|
})
|
|
}
|
|
}
|
|
|
|
openApiGenerate {
|
|
remoteInputSpec = "https://employee.szut.dev/v3/api-docs.yaml"
|
|
apiPackage = "ignored"
|
|
modelPackage = "ignored"
|
|
invokerPackage = "de.hmmh.pmt.employee"
|
|
groupId = "de.hmmh"
|
|
packageName = "de.hmmh.pmt"
|
|
generatorName = "java"
|
|
generateModelTests = false
|
|
generateApiTests = false
|
|
generateApiDocumentation = false
|
|
generateModelDocumentation = false
|
|
library = JavaClientCodegen.RESTTEMPLATE
|
|
|
|
ignoreFileOverride.set(".openapi-generator-java-sources.ignore")
|
|
|
|
configOptions.putAll(
|
|
mapOf(
|
|
JavaClientCodegen.GENERATE_CLIENT_AS_BEAN to "true",
|
|
JavaClientCodegen.ANNOTATION_LIBRARY to "swagger2",
|
|
JavaClientCodegen.OPENAPI_NULLABLE to "false",
|
|
JavaClientCodegen.PERFORM_BEANVALIDATION to "true",
|
|
JavaClientCodegen.USE_BEANVALIDATION to "true",
|
|
JavaClientCodegen.USE_JAKARTA_EE to "true",
|
|
)
|
|
)
|
|
|
|
}
|
|
tasks {
|
|
|
|
withType<Checkstyle> {
|
|
reports {
|
|
xml.required.set(true)
|
|
html.required.set(false)
|
|
}
|
|
}
|
|
withType<SpotBugsTask> {
|
|
|
|
excludeFilter.set(file("${rootDir}/src/main/resources/spotbugs-exclude.xml"))
|
|
}
|
|
processResources {
|
|
dependsOn(generateSwaggerCode)
|
|
dependsOn(openApiGenerate)
|
|
}
|
|
withType<Test> {
|
|
useJUnitPlatform()
|
|
}
|
|
named("compileJava").configure {
|
|
dependsOn(swaggerSources.getByName("pmt").code)
|
|
dependsOn(openApiGenerate)
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
java.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/java")
|
|
resources.srcDir("${swaggerSources.getByName("pmt").code.outputDir}/src/main/resources")
|
|
|
|
java.srcDir("${openApiGenerate.outputDir}/src/main/java")
|
|
}
|
|
}
|