
plugins {
	id 'java'
	id 'org.springframework.boot' version '3.2.3'
	id 'io.spring.dependency-management' version '1.1.4'
	id 'jacoco'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
}

configurations {
	compileOnly {
		extendsFrom annotationProcessor
	}
}

repositories {
	mavenCentral()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
	implementation 'org.springframework.boot:spring-boot-starter-validation'
	implementation 'mysql:mysql-connector-java:8.0.33'
	implementation 'org.redisson:redisson-spring-boot-starter:3.31.0'
//	implementation 'org.springframework.kafka:spring-kafka'
	implementation 'com.google.code.gson:gson'
	implementation 'org.springframework.boot:spring-boot-starter-data-redis'

	compileOnly 'org.projectlombok:lombok'
	runtimeOnly 'com.h2database:h2'
	annotationProcessor 'org.projectlombok:lombok'

	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	testCompileOnly 'org.projectlombok:lombok'
	testAnnotationProcessor 'org.projectlombok:lombok'
}

tasks.named('test') {
	useJUnitPlatform()
}

test {
	exclude '**/*KakaoPayClientTest.class', '**/*PaymentServiceImplTest.class', '**/*OrderServiceTest.class'
	finalizedBy 'jacocoTestReport'
}

jacoco {
	toolVersion = "0.8.11"
	reportsDirectory = layout.buildDirectory.dir('reports/jacoco')
}

jacocoTestReport {
	finalizedBy 'jacocoTestCoverageVerification'
}

jacocoTestCoverageVerification {
	violationRules {
		rule {
			enabled = true
			element = 'CLASS'

			limit {
				counter = 'LINE'
				value = 'COVEREDRATIO'
				minimum = 0.75
			}
		}
	}
}

jacocoTestReport {
	afterEvaluate {
		classDirectories.setFrom(
				files(classDirectories.files.collect {
					fileTree(dir: it, excludes: [
							'**/*Application*',
							'**/*Exception*',
							'**/dto/**',
							'**/entity/**',
							// ...
					])
				})
		)
	}
}

jacocoTestCoverageVerification {
	violationRules {
		rule {
			excludes = [
					'*.*Application',
					'*.*Exception',
					'*.dto.*',
					'*.entity.*',
					// ...
			]
		}
	}
}