import com.google.protobuf.gradle.id import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.springframework.boot.gradle.tasks.bundling.BootJar plugins { kotlin("jvm") version "2.1.20" kotlin("plugin.spring") version "2.1.20" id("org.springframework.boot") version "3.4.3" id("io.spring.dependency-management") version "1.1.7" id("com.google.protobuf") version "0.9.6" // alias(libs.plugins.ktlint) // alias(libs.plugins.detekt) jacoco } apply(from = "$rootDir/gradle/docker.gradle.kts") group = "com.project" version = "0.0.1" description = "MovieNight project" java { sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 } configurations { compileOnly { extendsFrom(configurations.annotationProcessor.get()) } } repositories { mavenCentral() } extra["sentryVersion"] = "8.27.0" extra["springGrpcVersion"] = "1.0.1" dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springframework.boot:spring-boot-starter-data-jdbc") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("org.flywaydb:flyway-database-postgresql") implementation("org.jetbrains.kotlin:kotlin-reflect") developmentOnly("org.springframework.boot:spring-boot-devtools") runtimeOnly("org.postgresql:postgresql") testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } tasks.withType { compilerOptions { freeCompilerArgs.set( listOf( "-Xjsr305=strict", "-Xjvm-default=all", "-opt-in=kotlin.RequiresOptIn", "-opt-in=kotlin.ExperimentalStdlibApi", ), ) jvmTarget.set(JvmTarget.JVM_21) allWarningsAsErrors.set(false) } } tasks.withType { sourceCompatibility = "21" targetCompatibility = "21" options.encoding = "UTF-8" options.isIncremental = true } dependencyManagement { imports { mavenBom("io.sentry:sentry-bom:${property("sentryVersion")}") mavenBom("org.springframework.grpc:spring-grpc-dependencies:${property("springGrpcVersion")}") } } kotlin { compilerOptions { freeCompilerArgs.addAll("-Xjsr305=strict", "-Xannotation-default-target=param-property") } } protobuf { protoc { artifact = "com.google.protobuf:protoc:3.25.1" } plugins { id("grpc") { artifact = "io.grpc:protoc-gen-grpc-java:1.60.0" } } generateProtoTasks { all().forEach { it.plugins { id("grpc") { option("@generated=omit") } } } } } tasks.withType { useJUnitPlatform() testLogging { events("passed", "skipped", "failed") exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL showStandardStreams = false } maxParallelForks = maxOf(1, Runtime.getRuntime().availableProcessors() / 2) minHeapSize = "512m" maxHeapSize = "2048m" systemProperty("spring.profiles.active", "test") } tasks.processResources { filesMatching("**/application.y{a,}ml") { filter { line -> line.replace("\${project.version}", project.version.toString()) } } } tasks.named("bootJar") { archiveFileName.set("${project.name}-${project.version}.jar") layered { enabled.set(true) } } tasks.named("jar") { enabled = false } ktlint { version.set(libs.versions.ktlint.get()) debug.set(false) verbose.set(true) android.set(false) outputToConsole.set(true) ignoreFailures.set(false) enableExperimentalRules.set(true) filter { exclude("**/build/**") exclude("**/generated/**") } } /* detekt { buildUponDefaultConfig = true allRules = false config.setFrom("$projectDir/config/detekt/detekt.yaml") baseline = file("$projectDir/config/detekt/baseline.xml") } */ jacoco { toolVersion = "0.8.11" } tasks.jacocoTestReport { dependsOn(tasks.test) reports { xml.required.set(true) html.required.set(true) csv.required.set(false) } finalizedBy(tasks.jacocoTestCoverageVerification) } tasks.jacocoTestCoverageVerification { violationRules { rule { limit { minimum = "0.60".toBigDecimal() } } rule { element = "CLASS" excludes = listOf( "*.config.*", "*.dto.*", "*.entity.*", ) limit { counter = "LINE" value = "COVEREDRATIO" minimum = "0.60".toBigDecimal() } } } } tasks.check { dependsOn(tasks.ktlintCheck) // dependsOn(tasks.detekt) dependsOn(tasks.jacocoTestReport) }