integration-service/build.gradle

149 lines
5.0 KiB
Groovy

plugins {
id 'java'
id 'org.springframework.boot' version '3.5.4'
id 'io.spring.dependency-management' version '1.1.7'
id 'org.openapi.generator' version '7.9.0'
id 'io.qameta.allure' version '2.12.0'
}
group = 'template'
version = '1.0.0-SNAPSHOT'
description = 'Layered Architecture Template'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
// The repo contains two @SpringBootApplication classes (the leftover
// 'template.Application' and the real 'com.goi.integration.IntegrationServiceApplication').
// Pin the main class so bootJar/bootRun are unambiguous.
springBoot {
mainClass = 'com.goi.integration.IntegrationServiceApplication'
}
ext {
jacksonDatabindNullableVersion = '0.2.6'
springdocVersion = '2.8.6'
modelmapperVersion = '3.2.2'
allureVersion = '2.29.0'
guavaVersion = '33.4.8-jre'
}
// Equivalent of the Maven 'default' / 'dev' profiles, which only set the
// 'activeProfile' property that is filtered into application.yaml.
// Override with: ./gradlew bootRun -PactiveProfile=dev
def activeProfile = project.findProperty('activeProfile') ?: 'default'
repositories {
mavenCentral()
}
dependencies {
// spring
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
// api
implementation "org.openapitools:jackson-databind-nullable:${jacksonDatabindNullableVersion}"
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${springdocVersion}"
// persistence
runtimeOnly 'com.h2database:h2'
// util
implementation "com.google.guava:guava:${guavaVersion}"
implementation "org.modelmapper:modelmapper:${modelmapperVersion}"
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.rest-assured:rest-assured'
testImplementation "io.qameta.allure:allure-junit5:${allureVersion}"
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
}
// ---------------------------------------------------------------------------
// OpenAPI code generation (replaces openapi-generator-maven-plugin)
// ---------------------------------------------------------------------------
def openApiOutputDir = layout.buildDirectory.dir('generated/openapi')
openApiGenerate {
generatorName = 'spring'
inputSpec = layout.projectDirectory.file('src/main/resources/api.yaml').asFile.toString()
outputDir = openApiOutputDir.get().asFile.toString()
apiPackage = 'template.api'
modelPackage = 'template.api.model'
configOptions = [
interfaceOnly : 'true',
useSpringBoot3: 'true',
useTags : 'true'
]
// keep the generated output limited to interfaces + models
generateApiTests = false
generateApiDocumentation = false
generateModelTests = false
generateModelDocumentation = false
}
sourceSets {
main {
java {
srcDir openApiOutputDir.map { it.dir('src/main/java') }
}
}
}
tasks.named('compileJava') {
dependsOn tasks.named('openApiGenerate')
}
// ---------------------------------------------------------------------------
// Resource filtering: replaces Maven's @activeProfile@ token in application.yaml
// ---------------------------------------------------------------------------
tasks.named('processResources') {
inputs.property('activeProfile', activeProfile)
filesMatching(['**/application*.yaml', '**/application*.yml', '**/application*.properties']) {
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [activeProfile: activeProfile.toString()])
}
}
// ---------------------------------------------------------------------------
// Tests: 'test' runs unit tests, 'integrationTest' runs *IntegrationTest
// (replaces the Maven surefire/failsafe split)
// ---------------------------------------------------------------------------
tasks.named('test', Test) {
useJUnitPlatform()
exclude '**/*IntegrationTest.*'
}
tasks.register('integrationTest', Test) {
description = 'Runs integration tests (*IntegrationTest).'
group = 'verification'
useJUnitPlatform()
include '**/*IntegrationTest.*'
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
shouldRunAfter tasks.named('test')
}
tasks.named('check') {
dependsOn tasks.named('integrationTest')
}
// ---------------------------------------------------------------------------
// Allure reporting (replaces allure-maven)
// ---------------------------------------------------------------------------
allure {
version = allureVersion
adapter {
autoconfigure = true
aspectjWeaver = true
}
}